Show Menu
Cheatography

YABCS: Yet Another Bash Cheat Sheet (DRAFT) by

A sheet with basic bash shortcuts and commands. It is kept as 1 page on purpose: small enough to hang somewhere near the screen, and containing only the stuff I use regularly. Based upon the bash cheat sheet of CITguy, appended with input from the Learn Linux TV youtube channel, some rephrasing and other small shortcuts.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

bash - Movement

Ctrl + a
Go to the start of the command line.
Ctrl + e
Go to the end of the command line.
Ctrl + xx
Exchange point and mark and highlight the region inbetween.
Ctrl + @
Set the mark (see Ctrl + xx). The mark defaults to start of line.
Alt + b
Back to start of word.
Alt + f
Forward to end of word.
Ctrl + b
Back one character.
Ctrl + f
Forward one character.

bash - Command control

Ctrl + l
Clear screen.
Ctrl + s
Stop screen output (for verbose commands).
Ctrl + q
Resume screen output.
Ctrl + c
Terminate command.
Ctrl + z
Suspend command (use fg to bring forward).

bash - Font size

Ctrl + '+'
Increase font size.
Ctrl + -
Decrease font size.
'reset'
Return to default size. (and other default variab­les).
 

bash - Manipu­lation

Ctrl + _
Undo.
Alt + r
Undo all changes to the line.
Alt + c
Capitalize current character and move to end of word..
Alt + u
Uppercase from cursor to end of word.
Alt + l
Lowercase from cursor to end of word.
Alt + t
Swap current word with previous word.
Ctrl + t
Swap current character with previous character.

bash - Command history

Ctrl + r
Search history (new->old).
Enter search string and repeat Ctrl + r to go through results.
Ctrl + g
End history search.
Ctrl + p
Previous command in history.
Ctrl + n
Next command in history.
Alt + .
Last word of previous command.
"­his­tor­y"
Output indexed history of commands.

bash - Command chaining

<co­mma­nd>­;<c­omm­and>
Chain commands, ignore return values.
<co­mma­nd> && <co­mma­nd>
Chain commands, only continue on no errors.
 

bash - Cut/ Paste/ Delete

Ctrl + u
Delete from cursor to start of line.
Ctrl + k
Delete from cursor to end of line.
Ctrl + w
Delete from cursor to start of word.
Alt + d
Delete from cursor to end of word.
Ctrl + y
Paste cut/ deleted text.
Ctrl + d
Quit the bash shell.

bash - Chitty chitty bang bang

<bang comman­d>:p
Print the command instead of running.
E.g. !!:p or !foo:p.
!!
Run last command.
E.g. Rerun, or use as "sudo !!"
!foo
Run most recent command starting with 'foo'.
!$
Last word of previous command.
!
*
Previous command without last argument.
!<h­istory index>
Execute numbered command from history.

bash - Directory refere­ncing and movement

cd -
Go back to previous directory.
pushd <di­rec­tor­y>
Move to directory and push it to the stack.
popd
Pop latest dir from the stack and move to previous dir on the stack.