Using Linux means using command line interface aka CLI aka terminal on regular basis. Being good at using CLI is what separates a casual Linux user & an expert.

In this tutorial, we will learn about some useful Linux keyboard shortcuts that can increase your efficiency as well as your productivity.

Recommended Read: Cloning Disks using dd & cat commands for Linux systems

Also Read: Use of du & df commands (with examples)


Useful Linux Shortcuts


Using HISTORY in bash

Most of you guys must be aware of this. We can run the command that we have already executed from the terminal by navigating with the UP arrow or DOWN arrow keys. Now what most people don’t know is that there are other ways to do the same, these are mentioned below

  • CTRL+L --This is a nice, important shortcut that every Linux user should know. When using CLI, if you want to look for a particular, you can use CTRL+L followed by the command keyword. For example, if we need to look for the OpenVPN command, press CTRL+L & start typing OpenVPN & we should see the complete command in the terminal screen.
  • !123 – Running history command produces a list of all the commands that were executed from the system, so if we want to run a particular command from the list, we should take note of the command number & then execute the command, run

$ !123

where 123 is the number in history when the command was executed.

!! – To use the last command again type !! . It comes extremely handy in a scenario where you have forgotten to use SUDO before the command, so use the following command without having to type the whole command again

$ sudo !!

  • CTRL + P – Another way to access the last command in bash history is to use !-1 , where 1 is the last command in the history. If need to run the second last command, then we can user !-2. CTRL+ P can also be used to view the last commands that were executed in bash. Pressing the key combination again & again will produce other commands from history.

 

Linux keyboard shortcuts for navigating the terminal

Now let’s discuss some more shortcuts that can be used to easily navigate the terminal.

  • Tab – Though technically not used for navigating the terminal, we can press the TAB key to complete an incomplete Linux command or other Linux arguments like filename, directory address, etc.
  • CTRL+ALT+F1 (F1 to F6) – To shift between the terminals in Linux, press CTRL+ALT+F1 or F2 up to F6.
  • CTRL+Left or Right Arrow – We can use CTRL + Left key or CTRL + Right key to jump between the command arguments.
  • CTRL+A and CTRL+E – To get the cursor to the beginning of a line, press CTRL + A & to get the cursor at the end of the line, press CTRL + E. Alternatively we can also use the HOME & END button to accomplish the same.
  • CTRL+ W -- To delete the word that is before the position of the cursor, press CTRL+W.
  • CTRL+K -- To delete all the words from the current position of the cursor till the end of the line, press CTRL + K.
  • CTRL+U – Delete an entire line of the terminal using CTRL+U.

 

Shortcuts for working with system Processes

  • CTRL+Z – To send a running process to the background, press CTRL+Z. Once in the background, we can bring the process to the foreground by typing

$ fg

but if you have sent a number of processes to the background then we need to check the process number for the process we want in the foreground. To do that type

$ bg

& we should have a list of all the processes in the background with a number. Now bring a process to the foreground, type

$ fg 3

  • CTRL+C – Use this shortcut to kill a running process.
  • CTRL+S & CTRL+Q – To stop printing all output to screen, use CTRL+S & to start the output on screen again, press CTRL+Q.

 

Some other shortcuts

  • CTRL+L – To clear the complete terminal screen, use the CTRL+L key combination.
  • CTRL+D – To log out or exit the bash shell, use CTRL+D.

This was our tutorial on useful Linux shortcuts that we should be aware of. I know this list is not complete & there are plenty more of the useful Linux shortcuts that can be used. Do mention your favorite Linux shortcuts in the comment box below.

If you have found this article to be useful, please share it among your friends/colleagues/followers. THANKS !!!

We are giving you exclusive deals to try Linux Servers for free with 100$ credit, check these links to claim your 100$,

DigitalOcean - 100$ free credit & Linode - 100$ free credit

Check some Exclusive Deals, HERE.

Also, check out DevOps Book You should read section.