Back to Technical Support

List Of Basic SSH Commands


Here is a list of some of the more common SSH commands. Many of the following examples have words that are surrounded with brackets ( [ ] ). You will need to make sure that you replace those bracketed words (including the brackets) with the correct substitution. For example, the command to remove a file is rm [filename].

If you had a file named test.html that you wanted to delete, you would take the above command and substitute the filename of the file you wish to delete. The result would be rm test.html.

Navigating

  • /
    • refers to the root directory on the server
  • ./
    • the current directory that you are in
  • ../
    • parent directory of your current directory
  • pwd
    • shows what your current directory is - giving the full path
  • ls
    • lists all the files in your current directory
  • ls -al
    • lists filenames + information
  • ls -aR
    • lists filenames + information in all subdirectories
  • ls -aR | more
    • lists filenames + information in all subdirectories, pausing when the screen becomes full
  • ls -alR > result.txt
    • lists filenames + information and outputs the results to a file
  • ls *.html
    • lists all files ending with .html
  • ls -al/home/usr/sam/
    • lists files + info for /home/usr/sam
  • cd
    • changes you to a new directory
  • cd /
    • changes you to the root directory

Moving, Copying, and Deleting Files

  • mv [old name] [new name]
    • move/rename a file
  • cp [filename] [new filename]
    • copy a file
  • rm [filename]
    • delete a file

Moving, Copying, and Deleting Directories

  • mkdir [directoryname]
    • creates a new directory
  • ls -d */
    • lists all directories within the current directory
  • cp -r [directoryname] [new directoryname]
    • copy a directory and all files/directories in it
  • rm -r [directoryname]
    • remove a directory. You will be prompted to answer "Yes" or "No" for whether you would like to delete each file in the directory
  • rm -rf [directoryname]
    • remove a directory and all files and folders in it (no prompting).

Searching Files and Directories

  • find / -name [filename] 2>/dev/null
    • search the whole server for a file
  • find ./ -name [filename]
    • search for a file starting with the current directory
  • grep [text] [filename]
    • search for text within a file

Related Articles

How To Backup Your Website In WordPress
How To Clean Your Site In WordPress
How To Configure Miva Store Utility
How To Find Your Site Manager Account's IP Address
How To Install CGI Software

Can’t Find what you need?

No worries, Our experts are here to help.