The Basic SSH Commands – List of Common SSH Commands

I’ve started my first blog by using a shared hosting with cPanel, so very easy to manager it. But after a few months, i have many websites and the number of visitor has increased daily, it made my shared hosting is overload so i’ve upgraded to VPS. Everything became difficult for me because of managing a vps is more difficult than managing a shared hosting. I must use Kloxo (a free, opensource web hosting control panel for the Red Hat and CentOS Linux distributions) instead of cPanel. Of course if you pay money to use cPanel ($200 per year) or DirectAdmin ($299 for lifetime), everything becomes much easier. Anyhow, you still have to know these ssh basic commands to manage a linux server.

In this page I list all necessary, most-used and common SSH commands useful to navigate through SSH client like Putty. I believe these commands are working on any Unix-based servers. This guide is intended as a very basic introduction to using command line SSH commands.

1. Commands related to system

exit: exit the command window
logout: same exit
reboot: reboot the system
halt: shutdown
startx: boot XWindows mode from the terminal window
mount: mounting file system from a storage device into the main directory tree
unmount: reverse with mount command
/usr/bin/system-config-securitylevel-tui: configuring the firewall and SELinux

2. Commands to see the information

cat /proc/cpuinfo: Find the specifications of the CPU (Read: http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-cpuinfo.html)
cat /proc/meminfo: Help explain what’s going on with your memory usage (Read: http://www.redhat.com/advice/tips/meminfo.html)
lspci: View information of mainboard (Read: http://linux.about.com/od/commands/l/blcmdl8_lspci.htm)
uname -r: View kernel version (Read: http://www.computerhope.com/unix/uuname.htm)
gcc -v: Compiler version I have installed
/sbin/ifconfig: View your IP address
netstat: View all the connections (Read: http://pcsupport.about.com/od/commandlinereference/p/netstat-command.htm)
lsmod: What kernel module is loaded
last: See who has logged into the system
df: View the amount of hard drive
free -m: See the amount of memory used (Read more: 5 Commands to check Memory usage on Linux via SSH)
netstat -an |grep :80 |wc -l: See how many connections to port 80

3. Commands to manipulate files

ls: get a list of all files and folders in the current directory
pwd: path of the working directory
cd: change the working directory to a new directory
mkdir: create a new folder
rmdir: delete an empty folder
cp: copy one or more files to a new folder
mv: change or move files, folders
rm: delete file
wc: count the number of lines, characters… in the file
touch: create a file
cat: view the content of file
vi: launch the text editor vi
df: check disk space
du: view the disk space used for a certain number of files
tar -cvzpf archive.tgz /home/admin/public_html/folder: compress a folder
tar -tzf backup.tar.gz: list compress file gz
tar -xvf archive.tar: extract (decompress) a .tar file
unzip file.zip: extract (decompress) a .zip file
wget: download a file
chown -R user:user folder/: Change owner for all files and folder
tail 100 log.log: View 100 latest lines of log.log file

4. Commands to work on the terminal

clear: clean up command line window
date: see date, time of system
find /usr/share/zoneinfo/ | grep -i pst: see the time zone
ln -f -s /usr/share/zoneinfo/America/New_York /etc/localtime: Change the timezone of server to New York time zone
date -s “09 Apr 2014 18:00:00”: Setup the time
cal: view calendar system

5. Commands to control system

rpm: checking installed package or not, or install a package, or used to remove a package
ps: checking processing system is running
kill: stop the process when the process crashes. Only the super-user user can stop the all process, ordinary user can only stop the process they created.
top: showing the operation of the process, especially information about system resources and use those resources for each process.
pstree: showing all process tree
sleep: stop system in a period of time
useradd: create a new user
groupadd: create a new user group
passwd: change password for a user
userdel: delete a user
groupdel: delete a user group
gpasswd: change password for a user group
su: allow login as another user
groups: display group of the current user
who: see who is logged in
w: same who command
man: see instructions about the command line as syntax, the parameters…

Notice: Linux Operating System discriminates uppercase characters and lowercase characters. “restart” can be replaced with “stop” to quit the service and “start” to start a stopped service.

Available permission type: (below is not command)

First number is for the owner, second for the group, and third for everyone.
7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied

Final tips

  • When you are typing a path or file name, hit “Tab” after the first few letters. If it’s the only file or folder matching the letters you’ve typed, the rest of it will auto-complete.
  • Hit the up arrow to scroll back through previous commands – save yourself some typing!
  • Always make a backup copy of the working version of a file before editing it.
  • q or CTRL-C usually gets you out of any special mode you might be in.
  • If you’ve encountered an unknown command, type “man” and then the command name to learn more about it. (Example: man ls) This will also show you special options like the -alh option for the list command.

This is by no means an exhaustive list of the commands and their options, however it should serve to get you started. Share this article if you feel it’s useful. Thanks.

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz