Job and Shortcut Management in Terminal
We often find ourselves needing to work quickly when dealing with the terminal. This is already helped by bash-completion, which allows us to type commands automatically by pressing the [TAB] key twice. However, in general the terminal also has shortcuts that help us work with Linux more easily and quickly. Below is a list of common terminal shortcuts. This list was taken from Hack The Box Academy.
Auto Completion
[TAB] - Initiates command auto completion.
Moving the cursor position without using arrow keys
[CTRL] + A - Moves the cursor to the very beginning of the command line.
[CTRL] + E - Moves the cursor to the very end of the command line.
[CTRL] + B / F Moves the cursor backward/forward by one character.
[ALT] + B / F - Moves backward/forward by one word.
Text Deletion
[CTRL] + U - Deletes all text behind the cursor.
[Ctrl] + K - Deletes all text in front of the cursor.
[Ctrl] + W - Deletes the previous word.
Paste Erased/Cutted Text
[Ctrl] + Y - Pastes the word / sentence that was previously deleted or cut.
Task Managing
[CTRL] + C - Cancel / Stop a running command.
[CTRL] + D - Logout or commonly known as End-of-File (EOF) or End-of-Transmission.
[CTRL] + L - Clears the terminal buffer / same as the clear command.
Background Process
[CTRL] + Z - Suspends the running command process.
For background processes you can use the fg command to return to the suspended process or use bg to move the process to the background.
$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1 (1.1.1.1): icmp_seq=1 ttl=57 time=22.6 ms
64 bytes from 1.1.1.1 (1.1.1.1): icmp_seq=2 ttl=57 time=22.8 ms
^Z (CTRL+Z Pressed)
[1]+ Stopped 1.1.1.1
$ fg
ping 1.1.1.1
64 bytes from 1.1.1.1 (1.1.1.1): icmp_seq=3 ttl=57 time=99.3 ms
64 bytes from 1.1.1.1 (1.1.1.1): icmp_seq=4 ttl=57 time=23.4 ms
Command History Search
[CTRL] + R - Search previous commands through command history.
[↑] / [↓] - Go to previous / next command.
Zoom
[CTRL] + [+] - Zoom in.
[CTRL] + [-] - Zoom out.
So, which shortcut is your favorite?