SSH command Basic for newbie :b

In linux terminal / server, is a must to memorize some important command so that we can do something more quickly, the command that include navigation commands, move, copy or search. With these command memorized at least we can work on a black screen terminals that: b, and perhaps this post at create a dedicated newbie, if you feel you’ve master please close this web page …. hehehe

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 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
Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *