Here are some common SSH commands that our server administrators find they use quite often. Hopefully these SSH commands will be useful for others too.
Some Useful SSH Commands |
|
---|---|
SSH Command Description | SSH Command |
Delete a directory with all content and subdirectories: | rm -fR /tmp/hacks |
Displays everything in the current directory: | ls |
Displays all files, including hidden any hidden files: | ls -a |
Displays all files, along with the size and timestamp: | ls -l |
Uncompresses tar.gz files: | tar -zxpf <file.tar.gz> |
Uncompresses .gz files: | gunzip <file> |
Copies a file to a new file: | cp <file> |
Moves a file to a new file, or renames it: | mv <file> |
Create a new directory: | mkdir <dir> |
Deletes a directory: | rmdir <dir> |
Deletes a file: | rm <file> |
Move into a directory: | cd <dir> |
Move to a lower directory: | cd .. |
Move to your home directory: | cd ~ |
Moves to the previous directory: | cd – |
Displays the current directory that you are in: | pwd |
Edit a file: | pico <file> |
Displays the hard drive status: | df |
Displays the uptime of a server: | uptime |
Displays others connected to the server: | who |
Displays previous logins: | last |
Displays processes running: | ps -x |
Displays all processes running: | ps -a |
Displays running processes, with CPU/Memory usage: | ps -ux |
Kills a process: | kill <pid> |
Kills all running process of the same type: | killall <program> |
Process list, 1 minute and 5 minute average load every 10 minutes since midnight server time: | sar -q |
Useful to see who is connected to your server: | netstat -n -p |
Edit the crontab file and see what is set to run in there: | crontab -e |
To edit a users cron jobs: | crontab -u username -e |
Gives you the last 10 lines of a file. Can change the # to whatever you want: | tail -10 <filename> |
Restart cPanel services: | /etc/init.d/cpanel restart |