Linux Keyboard Shortcuts

For those who have had any experience with Linux command terminal before, we could also been in the need of removing the whole command line due to a word which was misspelled or maybe the order or commands is incorrect, and this is not always the best options.

Linux terminal has by default many keyboard shortcuts (hotkeys) which could help us to improve our productivity or speed, just to mention some of them we have the following:

  • Clean screen.
  • Exchange words or characters.
  • Go to the end or the beginning of the command.
  • Repeat last executed commands.
  • And others…

I will explain below some of them giving an image of its usage.

Keyboard shortcuts

Ctrl + L

Clean the screen: this is useful when the screen is full of text, and itś also easier and fastest and execute clear command.

Ctrl + L

Ctrl + C

Exit and cancel process: this is maybe one of the most known commands, it’s used when we want to stop/interrupt any process execution.

Ctrl + C

Ctrl + A

Go to the beginning of the line: in case we forgot a parameter/command (for example sudo) which is at the beginning of the command we could return character by character with the left arrow key, but this is a faster way.

Ctrl + A

Ctrl + E

Go to the end of the line: similar to the last hotkey, if we need to return to the end of the line command to complete the command or fix any typo, we could use this one.

Ctrl + E

Ctrl + T

Exchange two characters: maybe you have written a command in which you exchange unintentionally two letters, and although we could just remote those characters and type them again in the right order we could use this hotkey instead.

Ctrl + T

Alt + T

Exchange two words: similar to the last one, we could forget the order of parameters of any command, so this shortcut can exchange two words in a simple way.

Alt + T

Ctrl + W

Remove/cut a word: a common activity is to remove character by character a command when we made a mistake in a command or we want to change parameters. This keyboard shortcut could help us to do it faster, just be aware that if you need to remove the whole command there is a better way to do it and it’s not Ctrl + C (continue reading).

Ctrl + W

Ctrl + K

Remove/cut from current position to the end of the line: this description is self-explanatory.

Ctrl + K

Ctrl + Y

Paste a cut text before: in the last two previous commands I described the commands for removing or cut, which means that actually we do not remove the text but cut it, so we can paste it where needed with Ctrl + Y. This can help to exchange some parameters or commands position/order for example.

Ctrl + Y

Ctrl + U

Remove the whole command: as I mentioned before, this is useful when we want to clear all line, either because it’s not the command we need or because most of the parameters are not correct.

Ctrl + U

Ctrl + R

Find a previously executed command: I consider this one of the most useful and least known functions as repeating a command is a common task and many commands can be very long or difficult to remember. With this combination of keys followed by some words or even characters of the desired command a previously executed command can be easily found.

Ctrl + R

Summary

HotkeyUsage
Ctrl + LClear screen
Ctrl + CInterrupt/stop process.
Ctrl + AGo to the beginning of the command.
Ctrl + EGo to the end of the command.
Ctrl + TExchange current character and the one behind it.
Alt + TExchange current word and the one behind it.
Ctrl + WRemove full current word.
Ctrl + KRemove text from current position to the end to the command.
Ctrl + YPaste removed text.
Ctrl + UClear all command line.
Ctrl + RSearch in previous executed commands.
Keyboard shortcuts summary.

As we saw in this post, these shortcuts can help us to improve our speed in the command line in which some action that can take a some types in the keyboard we can do the same with just a simple shortcut. We could not see the speed improvement at the beginning while we get used to it, but this with help definitely help in the long term, for example in server administration where we could see very long commands.