Skip to main content

Command Line Cheetsheet

SOME COMMON LINUX COMMANDS

tip: autocomplete the file or directory name by entering starting letter(s) then press tab

_________________________________________________________________________________

Control + Z # Use these keys if you get hung-up & can't get back to the COMMAND PROMPT

pwd # PRINT (to your screen) the current WORKING DIRECTORY
clear # clears the screen by moving it up, does not delete
cd directory # change the directory to a specific directory can use
up arrow # cycle through previous commands
down arrow # cycle back to more current commands and empty prompt (if you went back)
cd .. # move up a directory
cd / # move to the root directory
cd ~ # go to the home directory
cd # cd without an argument will take you to the home directory
cd - # go to the previous directory we just came from
cd ../.. # move up two directories
cd ~/.ssh # move into the user directory with a specific subdirectory

ls # list files and directories
ls -a # list all files including hidden files
ls -l # list long format
ls -la # list all files and in long format
cp one two # copy
mv # move and rename
rm # remove file (delete) NO UNDO FOR THIS!!! won't remove a directory
rm *.jpg # remove all files ending in .jpg
rm -r # remove recursively. Use this to delete directory and contents
mkdir # make a directory
rmdir # will only remove an empty directory use rm -r for directory with contents
cat # see two or more files, or use it to
just view one file (like our ssh public key)
| # pipe command; runs more that one command at once

> # used with the cat command to create one file out of two
Example: cat file1 file2 > file3

EDITORS
_________________________________________________________________________________
vi or vim # vim command line editor
nano # nano command line editor


more # see the link below
less # see the link below
head # see the link below
tail # see the link below

https://learnbyexample.gitbooks.io/command-line-text-processing/content/tail_less_cat_head.html