Cheatsheet: Productivity-boosting Bash shortcuts
The default Linux Bash shell might, at first, feel like a rather restrictive environment to work in. Many users get stuck on the inability to select text with the mouse, or having to rely heavily on the arrow keys to fix a small issue toward the end of a long command.
The truth is that Bash is actually quite user-friendly—once you know how to control all of its nuances. So, if you’re going to spend any meaningful amount of time on your VPS, maintaining it or installing new services via the command line, you’ll benefit from learning these Bash shortcuts.
First off, let’s just throw all the shortcuts at you, and then follow that up with some more detail on a select few, plus video!
Get THE BEST DEALS IN CLOUD HOSTING from Los Angeles!Grab a huge 32GB RAM & 320GB of SSD storage for just $109/year!
|Go to the beginning of the line.|
|Go to the end of the line.|
|Move the cursor forward one word.|
|Move the cursor back one word.|
|Move the cursor forward one character.|
|Move the cursor back one character.|
|Toggle between the current cursor position and the beginning of the line.|
|Undo! (And, yes, that’s an underscore, so you’ll probably need to use |
|Edit the current command in your $EDITOR.|
|Delete the word after the cursor.|
|Delete the word before the cursor.|
|Delete the character beneath the cursor.|
|Delete the character before the cursor (like backspace).|
|Cut the line after the cursor to the clipboard.|
|Cut the line before the cursor to the clipboard.|
|Cut the word after the cursor to the clipboard.|
|Cut the word before the cursor to the clipboard.|
|Paste the last item to be cut.|
|Clear the entire screen (like the |
|Place the currently running process into a suspended background process (and then use |
|Kill the currently running process by sending the |
|Exit the current shell.|
|Exit a stalled SSH session.|
|Bring up the history search.|
|Exit the history search.|
|See the previous command in the history.|
|See the next command in the history.|
All of these keyboard shortcuts are enabled by Emacs mode in Bash. If you’d like to use Vi shortcuts instead, you can enable that mode and use different shortcuts instead. In addition, most of these are compatible with Zsh as well, although you might find that a few don’t work or require slightly altered shortcuts.
As promised, let’s take a slightly longer dive into some of the more complex shortcuts, particularly the ones that could benefit from some visual reinforcement as to their function.
Ctrl + x + x
Technically, this command is activated by hitting
x twice, but it also works to just hold down
Ctrl and hit
This command is particularly useful if you want to quickly hop to the beginning of a lengthy command to fix something at the beginning, and then hop to the end.
Ctrl + _
The magical undo keystroke! If you accidentally delete a character or even a whole word via some of the shortcuts listed above, not all is lost. This even works after deleting a whole line with
u, but doesn’t work after you’ve executed the command.
Ctrl + l
Clearing the terminal is less about productivity, perhaps, and more about aesthetics, or starting from a clean slate. Whatever your reason, this simple command will help you keep track of your prompt and put the past behind you.
Ctrl + c
SIGINT shortcut is, truly, one of the most used shortcuts out there. It will attempt to interrupt the currently running process, and is used frequently to stop commands entered with a typo, or those that appear to have hung up.
The next steps
We hope this is a useful resource as you work to become more proficient in navigating the Linux terminal with ease. Learning all of these shortcuts—or even a select few of them—will take some time, but your efforts won’t go unrewarded.
If you have a favorite Bash shortcut that you’d like to share, we would love to hear it! Let us know the details in the comments and we’ll add it to the list. We hope this will become an ever-growing and ever-improving resource, so we’re always looking for more contributions.
- Added exit a stalled SSH session, exit the current shell, edit the current command in your $EDITOR.
- Added the History section.
- 2017.07.13: Initial version!