SSH Commands

Visit to see ever SSH command. Knowing how to use the following SSH commands will greatly help you when doing anything with SSH.

Basic SSH Commands

catPrint file contents to the screen
cat filename.txtCat the contents of filename.txt to your screen
tar -zxvf archive-name.tar.gzExtract a .tar.gz archive (similar to .zip)
tar -czvf archive-name.tar.gz /Directory-NameCompress an entire directory (it's like .zip)
cd ..Go up a directory
cd /usr/local/apacheGo to /usr/local/apache/ directory
cd ~Go to your home directory
cp -a /home/burst/new_design/* /home/burst/public_html/Copies all files, retaining permissions form one directory to another.
cpCopy a file
cp filename filename.backupCopies filename to filename.backup
duShows disk usage.
du -shShows a summary in human-readable form of total disk space
used in the current directory, including subdirectories.
du -sh *Same thing goes with (du -sh), but for each file and directory.
This is helpful when finding large files taking up space.
fileAttempts to guess what type of file a file is by looking at its content.
file*Prints out a list of all files/directories in a directory
find * -type d|xargs -i cp --verbose php.ini {}Copies your php.ini file into all directories recursively.
grepLooks for patterns in files
grep -v root /etc/passwdShows all lines that do not match the root
grep root /etc/passwdShows all matches of root in /etc/passwd
killTerminate a system process
kill : 9 PID EGkill -9 431
kill PID EGkill 10550
Use top or ps ux to get system PIDs (Process IDs)
lastShows who logged in and when
last -20Shows only the last 20 logins
last -20 -aShows last 20 logins, with the hostname in the last field
lnCreate's "links" between files and directories
ln -s /home/username/tmp/webalizer webstatsNow you can display to show your Webalizer stats online.
You can delete the symlink (webstats), and it will not delete the original stats on the server.
lsList files/directories in a directory, comparable to dir in windows/dos.
ls -alShows all files (including ones that start with a period),
directories, and details attributes for each file.
moreLike a cat, but opens the file one screen at a time rather than all at once
more /etc/userdomainsBrowse through the userdomains file.
hit Space to go to the next page, q to quit
netstatShows all current network connections.
netstat -anShows all connections to the server, the source, and destination IPs and ports.
netstat -rnShows routing table for all IPs bound to the server.
picoFriendly, easy to use file editor
pico /home/burst/public_html/index.htmlEdit the index page for the user's website.
psps 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 auxShows all system processes
ps aux --forestShows all system processes like the above but organizes in a beneficial hierarchy
ps U usernameShows processes for a certain user
rmDelete a file
rm filename.txtDeletes filename.txt will more than likely ask if you really want to delete it
rm -f filename.txtDeletes filename.txt, will not ask for confirmation before deleting.
rm -rf tmp/Recursively deletes the directory tmp and all files in it, including subdirectories.

Tips and hints

  1. 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.
  2. Hit the up arrow to scroll back through previous commands – save yourself some typing!
  3. “q” or “CTRL+C” usually gets you out of any special mode.
  4. 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.
  5. The chmod command is used to change read/write permissions for nominated files or directories.
    • chmod options permissions filename – change permissions for filename based on the parameters listed in options.
    • chmod u+x filename – give execute permission for the user.
    • chmod 0744 filename – give read, write, and execute permissions for the owner and read permission for groups and others.
    • chmod –r – change file permissions recursively through the directory and its subdirectories.
  6. Permissions can be defined using alphanumeric characters or digits.
    • u – user
    • g – group
    • o – other
    • r – read
    • w – write
    • x – execute


  • Forums SSH Commands

  • You must be logged in to reply to this topic.