Bash cheat sheet

Table of Contents

Getting information on commands

Access the manual:

man <command of interest>

If this doesn't work (the program doesn't have a manual), usually it is safe to try running the command with typical help flags:

<command of interest> --help
<command of interest> -h

Directory (folder) operations

listing the contents of a directory

ls

change directories

cd <directory>

~ stands for your home directory. So this would take you to your home directory:

cd ~

And this would take you to your downloads folder under you home directory:

cd ~/downloads

show your current (present) directory

pwd

File operations

copying a file

cp <file name> <new file name>

rename (move) a file

mv <file name> <new file name>

deleting (removing) a file

rm <file>

viewing the contents of a text file

Print the entire contents of a file to the terminal screen:

cat <file>

Load the file so that you can scroll and search the contents:

less <file>

When viewing a file with less, move down with j and up with k. Search by pressing / and then entering the search term. Leave the file with q.

Released under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Created with Emacs 24.4.1 (Org mode 8.3beta)

Validate