Bourne Again Shell Cheat Sheet

Bourne Again Shell Cheat Sheet

Keyboard Commands

Description
Double Tab Displays possible commands
Ctrl-A Move to the beginning of the line
Ctrl-E Move to the end of the line
Ctrl-Left arrow Move backward a word
Ctrl-Right arrow Move forward a word
Ctrl-U Deletes from the cursor position to beginning of line
Ctrl-K Deletes from the cursor position to end of the line
\ Escape characters ( cd My\ Documents )
cd - Go back to the previous folder
ls -h Show file size in kilobytes
mkdir -p parent/sub/child Creates all 3 folders
rm startswith?.txt Deletes files like startswith1.txt, startswith2.txt
find DIR -name "*filename" Looks for files in a directory
sudo -k Suspend root privileges
cat FILE Output file in the terminal
less FILE Peek and scroll to a file
vi FILE --> i (insertion mode) --> ESC :q! Exit w/o save or :wq to save
standard output (stdout) : 1 ls -al 1> output.txt
standard error (stderr) : 2 ls -al 2> errors.txt
ls -al > output.txt Creates a new file
ls -al >> output.txt Appends to a file


Octal File Permissions

Read (4) Write (2) Execute (1) Result
User r w x 7
Group r - x 5
Others r - - 4