Today we will learn Keyboard Shortcuts in Linux. Shortcuts are an efficient and effective way that you can use to avoid writing long commands or using manual long procedures to achieve a specific task in Linux. If you do a certain task more often than others, you should check out a shortcut for that command to save you a lot of time later. For example, if you want to open a specific link multiple times, instead of going to the browser and navigating to the link multiple times, you can set a keyboard shortcut using the curl command to open the link. Or if you visit a directory multiple times, you can set a keyboard shortcut by simply setting a command such as a nautilus or any other file manager you use to that directory path for a combination of keys.
As well as these, there are many shortcuts already available that you can use in place of how you would traditionally perform those operations. Generally, we divide such shortcuts on any Linux machine into two categories – keyboard key shortcuts and command-line shortcuts. In this comprehensive article, we will explain some of them from both categories.
To proceed with this article, please ensure that you have a Linux machine, a command-line terminal, and sudo privileges. Also, working with sudo privileges is always risky and you can make a mess of your system if you try to fiddle with configuration files. So, we request you to play safe with below mentioned commands to avoid any mishap.
Keyboard Shortcuts in Linux
Pressing a shortcut key or combination of keys brings up a command that runs a program or application based on the command associated with those keys. Also, some shortcuts may not be compatible with every flavor of Linux, but most of them work for all Linux/Unix distributions.
- Navigating Terminal Using Tab – We can use the tab key to auto-complete a directory while specifying one in a terminal. We just need to enter the name of the directory and press the tab key in between. You will see that Terminal will autocomplete the full directory path or name. This is very useful if the directory names are very long and can save you a lot of time.
- Many times you will find that you write long commands in the Linux terminal and type in at the beginning of the command. Now that your cursor is far away from the start position and you can’t use the normal mouse pointer to move your cursor inside a terminal, you start by pressing the left arrow key until you reach the beginning of the command. It works but is quite tedious. What you can do instead is press Ctrl + A to move the cursor directly to the beginning of the command.
- In a similar situation mentioned above, if you want to move the cursor to a previous character in the terminal, you can either use the left arrow button or press the Ctrl + B shortcut key.
- Suppose you are running a command in Linux, and you see that the command keeps running, and now you want to cancel the execution of that command. To do this, you press the shortcut key combination Ctrl + C.
- To log out of the current terminal session, you can simply use the following shortcut – Ctrl + D.
- If you are working with a file and want to delete the last word you typed, instead of selecting the word with the mouse cursor and pressing delete, you can just use the shortcut key combination Ctrl + W.
- If you want to move the typing cursor to one character forward or next position, you can use the shortcut key – Ctrl + F.
- If you want to search and change the previously used command, you can just use the key combination – Ctrl + R.
- An alternative to backspace that can be used to move the previous character is Ctrl + H.
- If you want to move an entire line (up to the next line break), you can use the following shortcut key combination – Ctrl + U.
- If you want to close all screens for output, you can use Ctrl + S and if you want to resume them, you can use Ctrl + Q.
- If you want to minimize all currently open windows and return to the desktop screen, you can use the shortcut – Ctrl + Alt + D.
- If you want to log out of the screen or lock/suspend, you can use the Ctrl + Alt + L key combination.
- To open a new window or terminal session, you can use Ctrl + Alt + T.
- If you want to switch to a different workspace, you can use the Ctrl + Alt + Down/Up key combination.
- If you are a root user and want to open the console and run a command, you can use – Alt + F2.
Command-line shortcuts in Linux
- You can use set aliases using the”<alias-name>=<command>“ command to replace long commands and assign them short names.
- If you have scheduled a shutdown and want to cancel it, you can use the command – “shutdown -c”.
- If you want to shut down the system after some time, you can do it using – “shutdown -h 4” which will shut it down after 4 seconds.
- You can always use the –help option to find all the options associated with any command.
- If you want to know the path of a file or current working directory, you need to use “pwd” command.
- Always use the less command instead of the cat command to print file contents in Linux. It gives better readability.
- You can use the “tree <path-to-file-or-directory>” command to get the complete structure of a directory in a tree format.
Conclusion
Apart from these, there are many shortcuts that may be common to all systems or specific to certain distributions. You can view the set of shortcut key directories from the GUI, and also set a few of them. Using shortcuts can save you a lot of time in the long run.
In this article, we have discussed some keyboard shortcuts as well as command-line shortcuts in Linux. We certainly hope that this informative article will help you use Linux more effectively than ever before.



