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, or support this blog with the poster size Bash references cheat sheet.
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.pngmv {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+d | delete from the cursor position to the end of the word |
esc+f | move forward a word |
esc+b | move backward a word |
esc+t | transpose two adjacent words |
Tabs keys bound (TT=TAB twice)
TT | list all available commands |
(string) TT | list all available commands starting with (string) |
/TT | list available dir (including hidden ones, use /*TT otherwise) |
~TT | list all system users |
$TT | list all system variables |
@TT | list hosts |
=TT | act as ls or dir |
Control keys bound (CTRL+key)
ctrl+a | move your cursor to the beginning of the line |
ctrl+e | move your cursor to the end of the line |
ctrl+k | delete any characters from your cursor to the end of the line |
ctrl+u | delete any characters from your cursor to the beginning of the line |
ctrl+w | delete previous word |
ctrl+t | transpose two previous characters |
ctrl+y | yank/recover the last deletion |
ctrl+d | delete one character at the cursor position |
ctrl+h | delete one character before the cursor |
ctrl+f | move forward |
ctrl+b | move backward |
ctrl+r | find character sequence in history (completion mode) |
ctrl+g | escape from completion mode |
ctrl+v | Literal next (LNEXT ) |
👉
LNEXT
interpret the next character as a string. eg : to symbolize aCR+LF
you must use the key combinationctrl+v+return
which will print^M
.
Alt keys bound (ALT+key)
alt+< | move to the first line of history |
alt+> | move to the last line of history |
alt+? | show current completion list |
alt+* | insert all possible completion |
alt+/ | attempt to complete filename |
alt+. | yank last argument to previous command |
alt+b | move backward |
alt+c | capitalize the word |
alt+d | delete word |
alt+f | move forward |
alt+l | make word lowercase |
alt+n | search the history forwards nonincremental |
alt+p | search the history backwards nonincremental |
alt+r | recall command |
alt+t | move word around |
alt+u | make word uppercase |
alt+backspace | delete backwards from cursor |