Skip to content

SantaBarbaraDataSystems

— IT happens.

  • /SBDS.com/etc/
  • /SBDS.com/root/

Category: useful commands

Linux commands I use so much I should write them down.

delete

Posted on March 9, 2017 - March 14, 2017 by elijah

Find and delete a bunch of files:

find /var/log/ -name '*.gz' -exec rm {} +

Note: Concluding with ‘+’ rather than ‘\;’ should be faster by not running rm on every instance from find.

Confirm before delete:

find /var/log/ -name '*.gz' -exec rm -i {} +

Include directories:

find /var/log/ -name '*.gz' -exec rm -r {} +

Truncate instead:

find /var/log/ -name '*log' -type f -exec truncate -s 0 {} +

Delete empty directories:

find /path/to/dir -empty -type d -delete

 

Posted in Centos7, useful commands

curl for public IP address

Posted on January 12, 2017 - March 7, 2017 by elijah
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

 

Posted in networking, useful commands

kill an SSH session in Linux

Posted on December 28, 2016 - March 7, 2017 by elijah

kill the host’s oldest session:

pkill -o -u YOURUSERNAME sshd

 

Posted in Centos7, useful commands

kill a defunct process in Linux

Posted on October 17, 2016 - March 7, 2017 by elijah
ps -ef | grep defunct | grep -v grep | cut -b8-20 | xargs kill -9

 

Posted in Centos7, useful commands

Recent Posts

  • delete
  • cabon-cache TLS error after update
  • setup Firewalld
  • Apache security settings
  • curl for public IP address

Categories

  • Apache
  • Centos7
  • errors
  • Firewalld
  • installs
  • Mutt
  • networking
  • Python
  • server configs
  • useful commands

Recent Comments

    Archives

    • March 2017
    • January 2017
    • December 2016
    • October 2016
    • August 2016

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    Proudly powered by WordPress | Theme: micro, developed by DevriX.