Keyboard shortcuts in Linux terminal

A long time ago, words like “hot keys” and “keyboard shortcuts” were not always easy for me to translate into Russian without losing face. Once, I wrote “keyboard shortcuts”, which immediately attracted sidelong glances and caused bold medical fantasies … But it seems that now it is customary to say and write “hot keys” everywhere. Let’s talk about them.

This note is a cheat sheet on the Linux shell Bash and related components. Some of the commands below are related to the library Readlinepart – to signals Linux, but such details are not important to us here. If you often have to deal with the terminal in Linux (and you have not changed Bash to another shell), then it will be very useful to use these very “abbreviations” for your own benefit and for peaceful purposes. The text is written for novice users, but who knows – maybe you will find something new and useful for yourself in it.

For convenience, we will assume that by default, by terminal we mean the Gnome Terminal program standard in the desktop edition of Ubuntu.


Gnome Terminal has tabs, and they work like tabs in a web browser or file manager. In other words, if you need multiple terminals, you don’t have to open multiple windows. One window is enough multiple tabs. The following are the keyboard shortcuts related to tabs:

Ctrl+Shift+T – open a new tab;

Ctrl+Shift+W or Ctrl+D — close the current tab (or the entire terminal if there is only one tab);

Ctrl+Shift+N — open a new terminal window from the current one.

Over time, you may find yourself in a situation where there are really a lot of tabs, and then the question of navigating between them will arise. The following keyboard shortcuts will come in handy:

Ctrl+PgDn – go to the next (right) tab;

Ctrl+PgDn – go to the previous (left) tab;

Ctrl+Shift+PgDn – move the tab to the right;

Ctrl+Shift+PgUp – move the tab to the left.

Alt+1 – go to the first tab in a row. Substitute another number for the tab you want. This method allows you to “reach” a maximum of tenth tab count.


Three very commonly used combinations for copying and pasting text, as well as canceling a running command:

Ctrl+Shift+C — copying to the clipboard;

Ctrl+Shift+V – paste from the clipboard;

ctrl+c – interrupting a running command or clearing the current line.

In order to select the desired text in the terminal, you will need to use the mouse. However, the Gnome Terminal program has a built-in text search facility that allows you to search for both a regular fragment and a regular expression:

Ctrl+Shift+F – call the built-in search for any text in the terminal.

If the command in the terminal is too long, or you made a typo at the beginning and did not immediately notice it, you can return to the beginning of the line. And then back to the end. Here’s how to do it:

Ctrl+A – move to the beginning of the line;

ctrl+e – move to the end of the line.

In the Linux terminal, you can also move within a line by words and by individual characters (in the latter case, this is the same as using the side arrow keys):

ctrl+f – move 1 character forward;

ctrl+b – move 1 character back;

Alt+F – move to the next word;

Alt+B — move to the beginning of the previous word.

Team and process management

The previous commands dealt with navigating the terminal and the command input line. Next, consider the Bash control commands that you can use to start, stop, pause, and resume commands and processes. You already know that a process running in the terminal can be interrupted by ctrl+cbut it is also useful to know some of the nuances.

In the Linux terminal, you can not only end programs completely, but also pause them. Then the program execution can be resumed, both with and without the return of the interactive command line:

ctrl+z – suspension of the process;

team bg – resuming the process with the return of the command line (the process continues to run in the background);

team fg – resuming the process, in which he holds the command line behind him (the process is running in the “foreground”).

Processes can also be paused and resumed. Run some command like htopand press ctrl+z. At first, it will appear as if the command has completed, but it will be listed in the list of running processes (ps -a) and will reappear after issuing the fg command.

If you repeat the experiment with a graphical application, for example, by entering the command firefoxthen it can be used to “revive” it as fgand bg. In any case, the application will remain “pinned” to the current terminal: if you close it, it will also end.

After pausing the firefox process in the terminal, the Gnome desktop will assume that the application is
After pausing the firefox process in the terminal, the Gnome desktop will assume that the application is “not responding”.

There is another type of “suspension”: temporary withdrawal termination running command. Both console and graphical applications can be launched in the terminal, which will display the current diagnostic information. Sometimes it can be very convenient to temporarily stop constantly displaying messages without terminating the application itself. The following keyboard shortcuts are useful for this:

ctrl+s – stop updating the output of the command;

ctrl+q – resume command output.

Team History

Bash can remember all the commands you enter. While the terminal is running, they are stored in the RAM of the computer, and when the terminal is exited, they are written to the long-term storage in the file ~/.bash_history.

If you know for sure that you have entered the command you need before, look for it in the history:

history – command history output;

If you remember at least part of the command, you can refine your search:

history | grep <часть команды> – an example of a refinement search in the history of commands.

Every team in history has a number. Enter this number, preceded by an exclamation point, and Bash will execute the corresponding command:

!151 – execute command number 151 from the history;

!151: – show command number 151, but do not execute it;

!! – re-execute the last entered command.

Bash has an interactive command history search mode. Click ctrl+r and start typing part of the team. Bash will suggest the first matching option for you. If it doesn’t fit, click ctrl+r next to go through the options. When the desired option is found, click Enter.

Interestingly, this enter key has two analogues – instead of Enter you can click Ctrl+M or Ctrl+J.

The easiest way to navigate through the command history is with the up and down arrows on the keyboard. They also have duplicates:

ctrl+p – output the previous command;

Ctrl+N – issue the following command.

Command editing

It’s time to consider the command editing tools – they are very advanced in Bash. Convenient moving to the beginning and end of a line, selective deletion of characters and words – these are just some of the features that may be useful to the user. The following keyboard shortcuts are responsible for editing commands:

Ctrl+U – delete all text to the left of the cursor;

Ctrl+K – delete all text to the right of the cursor;

ctrl+w — delete 1 word or parameter to the left of the cursor;

Ctrl+D – deleting the current character (similarly Del);

ctrl+h – deleting the previous character (similarly backspace);

Alt+D – delete everything to the right of the cursor to the nearest space;

Alt+Backspace – delete everything to the left of the cursor to the nearest space;

Alt+T – swap the current word with the previous one;

Esc+T – swap the two previous words;

Tab — autocompletion of the command after entering its first characters.

Another interesting detail: Bash has its own clipboard, which works independently of the standard buffer (as we remember, copying Ctrl+Shift+Cinsertion by Ctrl+Shift+V). This is important, because the first three commands from the previous list have additional functions: they not only delete part of the text, but also copy it to that very separate Bash clipboard. Therefore, it would be fair to clarify:

Ctrl+U – cut and place on the clipboard all text to the left of the cursor;

Ctrl+K — cut and place on the clipboard all text to the right of the cursor;

ctrl+w — cut and place on the clipboard 1 word or parameter to the left of the cursor;

By the way, to paste the copied text back, the combination will work ctrl+y.


Of course, I did not describe all the hotkeys above: there are many more of them, and a full description would contain a bunch of bearded exotics inherited from the ancient UNIX university days. In any case, don’t forget to man bash (for example, there is a wonderful section there Commands for Moving) and about bind -P.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *