Skip to content

Instantly share code, notes, and snippets.

@webdevel
Last active December 6, 2021 14:43
Show Gist options
  • Save webdevel/e441f52e5409e0cb82ae22c21767b284 to your computer and use it in GitHub Desktop.
Save webdevel/e441f52e5409e0cb82ae22c21767b284 to your computer and use it in GitHub Desktop.

Bash Cheat Sheet

Bourne Again Shell Cheat Sheet

Table of Contents

Bash Keyboard Shortcuts

Herein shortcuts are using Alt as the Meta key. Shortcuts may be given numeric arguments.

Line Movement Shortcuts

Ctrl+A : Aft –– cursor back to start of line
Ctrl+E : End –– cursor to end of line
Ctrl+L : Less –– clear screen, only show current line at top
Ctrl+F : Forward –– to next character right of cursor
Ctrl+B : Back –– to next character left of cursor
Alt+F : Forward –– to next word right of cursor
Alt+B : Back –– to next word left of cursor
Ctrl+@ : At –– set mark at cursor
Ctrl+X Ctrl+X : Jump –– swap mark and cursor
Ctrl+] : Search –– search for character right of cursor
Alt+Ctrl+] : Search –– search for character left of cursor
TOC

Line Editing Shortcuts

Tab : Tab –– auto-complete file and directory names
Ctrl+D : Delete –– delete character under cursor
Ctrl+H : Hack –– delete character left of cursor
Ctrl+_ : Undo –– undo last line edit command
Ctrl+K : Kill –– cut from cursor to end of line
Ctrl+U : Unset –– cut from cursor to start of line
Ctrl+Y : Yank –– paste last cut text at cursor
Ctrl+W : Word –– cut from cursor to start of next word on left
Alt+D : Delete –– cut from cursor to end of next word on right
Alt+Delete : Delete –– cut from cursor to start of next word on left
Alt+& : Expand –– expand tilde to directory name
Ctrl+T : Transpose –– drag 2nd character left of the cursor to the right
Alt+T : Transpose –– drag word left of the cursor to the right
Alt+U : Uppercase –– change current or following word to uppercase
Alt+L : Lowercase –– change current or following word to lowercase
TOC

Command History Shortcuts

Ctrl+R : Reverse –– search command history, replace current line
Ctrl+P : Previous –– move back through command history
Ctrl+N : Next –– move forward through command history
TOC

Job Control and Standard Signal Shortcuts

Bash works closely with the underlying system to provide Job Control. Strictly speaking, these shortcuts are that of the terminal input/output system and not Bash.

Ctrl+C : Cancel –– SIGINT interrupt program, terminate process
Ctrl+\ : Quit –– SIGQUIT dump core and quit program
Ctrl+Z : Zombie –– SIGTSTP suspend execution, put process in background
Ctrl+T : Tip –– SIGINFO show status information of process
Ctrl+S : Stop –– suspend output of process
Ctrl+Q : Queue –– resume output suspended by Stop
TOC

Macro Shortcuts

Ctrl+X ( : Start –– start recording macro
Ctrl+X ) : Stop –– stop recording macro
Ctrl+X E : Execute –– execute macro
TOC

Miscellaneous Shortcuts

Ctrl+X Ctrl+V : Version –– show Bash version
TOC

Numeric Argument Shortcuts

Alt+2 Ctrl+D : Delete –– delete two characters
TOC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment