Useful BASH Shortcuts for Beginners
By default, BASH is default for most Linux distributions. BASH shell provides keyboard shortcuts for better interaction for users. So, let’s start now.
Moving Cursor
Ctrl+A
orHOME
- moves cursor to the start of the lineCtrl+E
orEND
- moves cursor to the end of the lineCtrl+B
orLeft Arrow
- moves cursor back for one characterCtrl+F
orRight Arrow
- moves cursor forward for one characterCtrl+Left Arrow
orAlt+B
orEsc+B
- moves cursor back for one wordCtrl+Right Arrow
orAlt+C
orEsc+F
- moves cursor forward for one word
Deleting Text
Ctrl+H
orBACKSPACE
- removes the character before the cursorCtrl+D
orDELETE
- removes the character under the cursorCtrl+K
- removes all text from the cursor to the end of the lineCtrl+U
- removes all text from the cursor to the start of the lineCtrl+W
- removes the word before the cursorAlt+D
- removes the word forward the cursor
Searching BASH History
Up Arrow
- gets previous entered command (multipleUp Arrow
results prior entered command)Ctrl+R
- search BASH history in reverse, type character you want to find in the historyCtrl+S
- search BASH history in forward, type character you want to find in the history
Cutting and Pasting
Ctrl+W
- cuts the word before the cursor to clipboardCtrl+K
- cuts the part of the line forward the cursor to clipboardCtrl+U
- cuts the part of the line before the cursor to clipboardCtrl+Y
- paste the last thing you cut from clipboard
Working with Processes
Ctrl+Z
- suspend current foreground process, same as sending SIGSTOP or 19 to processCtrl+C
- interrupt current foreground process, same as sending SIGINT or 2 to processCtrl+D
orexit
- exit current BASH shell
Dealing with Typos
Ctrl+T
- transposes the character before the cursor with the character under the cursorAlt+T
- transposes the current word with previous word
BASH Bang(!) Command
!!
- executes previous command!top
- executes recent command that starts with ‘top’!$
orAlt+.
- executes last word of previous command!*
- displays last word of previous command
TAB Completion
TAB Completion is a very useful feature provided by BASH shell. File, directory, and command name are automatically completed if possible with the press on TAB
key.
These are not all BASH shortcuts. Leave comment below and let me know if there is something new shortcuts, I would rather add here on this post. To conclude, cramming all BASH shortcuts is not necessary in our daily terminal usage. But mastering with some shortcuts is indeed useful.
Peace Out!!!