SSH Commands to Remember

A list of SSH commands that I use most and should remember.

Feel free to add your own via the comments section.

List disc usage in readable format sorted by size

du -hs * | sort -h

Find the path to the loaded php.ini file

php -i | grep php.ini

Show uptime and load averages

uptime

Access MYSQL server

mysql -uroot

Show top 10 running processes

ps axo %mem,pid,euser,cmd | sort -nr | head -n 10

Restart Apache on a cPanel setup

/scripts/restartsrv_apache

Apache status and Restart

Status shows uptime of Apache so you can check restart happened

/etc/rc.d/init.d/httpd restart
/etc/rc.d/init.d/httpd status

Load averages for today

sar -q

Current CPU usage

Also shows commands running which can identify the script in question

top -c

Find a folder

find -type d -name "fancybox-for-wordpress"

can use wildcards

find -type d -name "*fancybox*"

Find File including wild cards

find  -name “myFile*”

List files sorted by Modified Time

find . -printf '%T@ %c %p\n' | sort -k 1nr,1 -k 7 | cut -d' ' -f2-

Piping it through less lets you paginate the results

find . -printf '%T@ %c %p\n' | sort -k 1nr,1 -k 7 | cut -d' ' -f2- | less