Bash Quick References: A One Page Cheat Sheet

Channel: cheat-sheets
Abstract: use /*TT otherwise)~TTlist all system users$TTlist all system variables@TTlist hosts=TTact as ls or dirControl keys bound (CTRL+key)ctrl+amove your cu

Have you ever forgot a command syntax while working in your Bash shell?

GNU Bash is the GNU command-line interface shell project with a complete implementation of the IEEE POSIX specification. It is one of the most used command-line shell. However, it may be overwhelming to know or remember all the possible commands at times.

This post includes a cheat sheet to help you get back to work quickly or improve your workflow. Some of the material covered in this current version include wildcards, escape keys bounds, tabs keys bounds, controls keys bounds, and alt keys bounds.

The cheat sheet is also available in an easy-to-print pdf and jpg format.

Note: Use exec bash to reload your current bash shell. See my post on How To Reload Or Change Your Current Shell?

Wildcards*match all characters?match a single character[]match a range of value{}match a list of value

Examples:

  • ls pic[13].{ jpg,gif} will list pic1.jpg pic2.gif and pic3.jpg but not pic1.png
  • mv {short,very_long}.txt will move short.txt to very_long.txt

You can learn more about bash wildcards with my post on How To Use Bash Wildcards For Globbing?

Escape keys bound (ESC+key)esc+ddelete from the cursor position to the end of the wordesc+fmove forward a wordesc+bmove backward a wordesc+ttranspose two adjacent wordsTabs keys bound (TT=TAB twice)TTlist all available commands(string) TTlist all available commands starting with (string)/TTlist available dir (including hidden ones, use /*TT otherwise)~TTlist all system users$TTlist all system variables@TTlist hosts=TTact as ls or dirControl keys bound (CTRL+key)ctrl+amove your cursor to the beginning of the linectrl+emove your cursor to the end of the linectrl+kdelete any characters from your cursor to the end of the linectrl+udelete any characters from your cursor to the beginning of the linectrl+wdelete previous wordctrl+ttranspose two previous charactersctrl+yyank/recover the last deletionctrl+ddelete one character at the cursor positionctrl+hdelete one character before the cursorctrl+fmove forwardctrl+bmove backwardctrl+rfind character sequence in history (completion mode)ctrl+gescape from completion modectrl+vLiteral next (LNEXT)

? LNEXT interpret the next character as a string. eg : to symbolize a CR+LF you must use the key combination ctrl+v+return which will print ^M.

Alt keys bound (ALT+key)alt+<move to the first line of historyalt+>move to the last line of historyalt+?show current completion listalt+*insert all possible completionalt+/attempt to complete filenamealt+.yank last argument to previous commandalt+bmove backwardalt+ccapitalize the wordalt+ddelete wordalt+fmove forwardalt+lmake word lowercasealt+nsearch the history forwards nonincrementalalt+psearch the history backwards nonincrementalalt+rrecall commandalt+tmove word aroundalt+umake word uppercasealt+backspacedelete backwards from cursor

Ref From: shell-tips

Related articles