Common SSH Commands or Linux Shell Commands
Common SSH Commands or Linux Shell Commands
page 1 of 3
http://www.linuxhowtos.org/System/shellcommands.pdf
netstat -rn : shows routing table for all ips bound to the server. top : shows live system processes in a nice table, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn't bogged down. top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage ps: ps is short for process status, which is similar to the top command. It's used to show currently running processes and their PID. A process ID is a unique number that identifies a process, with that you can kill or terminate a running program on your server (see kill command). ps U username : shows processes for a certain user ps aux : shows all system processes ps aux --forest : shows all system processes like the above but organizes in a hierarchy that's very useful! file : attempts to guess what type of file a file is by looking at it's content. file * : prints out a list of all files/directories in a directory du : shows disk usage. du -sh : shows a summary, in human-readble form, of total disk space used in the current directory, including subdirectories. du -sh * : same thing, but for each file and directory. helpful when finding large files taking up space. wc : word count wc -l filename.txt : tells how many lines are in filename.txt cp : copy a file cp filename filename.backup : copies filename to filename.backup cp -a /home/burst/new_design/* /home/burst/public_html/ : copies all files, retaining permissions form one directory to another. kill: terminate a system process kill -9 PID EG: kill -9 431 kill PID EG: kill 10550 Use top or ps ux to get system PIDs (Process IDs)
EG: PID TTY TIME COMMAND 10550 pts/3 0:01 /bin/csh 10574 pts/4 0:02 /bin/csh 10590 pts/4 0:09 APP
Each line represents one process, with a process being loosely defined as a running instance of a program. The column headed PID (process ID) shows the assigned process numbers of the processes. The heading COMMAND shows the location of the executed process.
page 2 of 3
http://www.linuxhowtos.org/System/shellcommands.pdf
grep User /usr/local/apache/conf/httpd.conf |more This will dump all lines that match User from the httpd.conf, then print the results to your screen one page at a time. last -a > /root/lastlogins.tmp This will print all the current login history to a file called lastlogins.tmp in /root/ tail -10000 /var/log/exim_mainlog |grep domain.com |more This will grab the last 10,000 lines from /var/log/exim_mainlog, find all occurances of domain.com (the period represents 'anything', -- comment it out with a so it will be interpretted literally), then send it to your screen page by page. netstat -an |grep :80 |wc -l Show how many active connections there are to apache (httpd runs on port 80) mysqladmin processlist |wc -l Show how many current open connections there are to mysql
page 3 of 3