Blog
Shell and Bash shortcuts
Command line shortcuts in Linux
October 5, 2020
Bash is one of Linux’s interfaces for issuing commands to the system. In other words, the command line. This “interface for issuing commands to the system” is called the Shell. In fact, most programs that run on Linux issue commands to the shell and receive what the shell returns as a response.
Although it may seem complicated at first glance, the shell is extremely useful and it’s really important for Linux users to become as familiar with it as possible, because a large number of administrative tasks are more reliably performed through the shell.
Here’s an overview of several commands you can use while working in the shell to speed up your work.
1. Tab
Autocompletes the command line. If nothing happens, press Tab twice, as there may be multiple commands that can “complete” the command line. The command line will be completed with a command or a directory (either way, the shell will do its best to help).
2. Ctrl + C
Interrupts the started process in the terminal you’re working in.
3. Ctrl + Z
Sends the started process (or program) to the background.
4. Ctrl + D
Logout.
5. Ctrl + L
Clears everything from the terminal screen, and the command line will move to the very top of the screen, to the first line. Equivalent to the clear command.
6. Ctrl + A
Moves the cursor to the beginning of the command line. You can also use Ctrl+Home.
7. Ctrl + E
Moves the cursor to the end of the command line. You can also use Ctrl+End.
8. Ctrl + U
Deletes the entire content of the command line up to its beginning.
9. Ctrl + K
Deletes the entire content of the command line up to its end.
10. Ctrl + W
Deletes the word (if we can call it that) where the cursor is located.
11. Ctrl + Y
Performs the “paste” function for selected text. You can also perform this “paste” with Shift+Insert or even by clicking the middle mouse button, or by pressing both mouse buttons simultaneously. Or at least it should work — it depends on the hardware and its configuration.
12. Ctrl + P
Recalls the previous command. But you can also do this with the up arrow key. Or with PageUp.
13. Ctrl + N
Recalls the next command if possible (if you’ve already been browsing through command history). Or PageDown. Or the down arrow key.
14. Ctrl + R
Search through previously executed commands — press Ctrl+R and start typing the command.
15. !command
Executes the last command that starts with “command”. For example, if you executed the mysql command, type !mys and it will execute the mysql command.
16. !!
Repeats the previous command. Although we prefer to use the up arrow and see the command once more before executing it.
That’s it for now regarding some shortcuts in bash, or the command line. Do you have any “interesting” shortcuts that you use? Feel free to let us know!
Keep In Touch