HomeTechnologyTerminal shortcuts for Linux - Knoldus Blogs

Terminal shortcuts for Linux – Knoldus Blogs

Reading Time: 5 minutes

Introduction – Terminal shortcuts

In this blog post, I share the top 12 terminal shortcuts that I consider are useful to the broadest range of the sysadmin community. These shortcuts are a vital part of any Linux terminal user and allow to save time and focus better on what the user enjoys doing. Whether you’re a terminal newbie or somebody who got over the fright lengthy ago, there are ways you can make things go more easily. Here are 10 shortcuts that can help you overcome some of the command line’s awkwardness.

NOTE: Do note that I have used the capital letters in the keyboard for terminal shortcuts but this does NOT mean that you have to press the shift key or caps lock while using these shortcuts.

keyboard Image

1. Tab

Pressing ‘Tab’ in terminal autocompletes instructions and/or paths. Pressing it twice while there is no part of any command/path is entered proposes to you to show all possible instructions. It is the handiest shortcut and time saver ever developed as It autocompletes instructions, file names, or directory names for you.

lets’s understand the tab completion with an example, if you want to go on desktop and you are already on Home then You can just type command $ cd De or $ cd Des into the terminal and press TAB if your system doesn’t have any other instructions that start with those letters, Bash will routinely fill in Desktop and you can press Enter to run the command.

auto-competion shown

after pressing TAB button

auto-competion shown

for more information about TAB key

2. tty

This shortcut is used to print the name of the terminal in which you are typing this command. If you prefer the number of the lively terminal (instead of its name), it can be printed using the command fgconsole (foreground console)

tty commnd output


Ctrl+C is a very wellliked shortcut that everybody uses all the time. Ctrl+C is used to abort the current task and regain user control. it’s just a shortcut key for sending the interrupt (terminate) signal SIGINT to the current process operating in the foreground. Once the process gets that signal, it’s terminating itself and returns the user to the shell prompt.

4. Ctrl+R/G/O – Terminal shortcuts

abort signal output

This shortcut is very useful when you are looking through command history.

Ctrl+R: Ctrl+R is used to recall the last command matching the characters you provide. Press this shortcut and start typing to search your bash history for a command.

Ctrl+R: It is used to navigate through the matching instructions.

Control+G: Leave history looking mode without operating a command.

Control+O:Ctrl+0 is used to run a command that you found with Ctrl+R

Terminal shortcut for reverse search

5. Ctrl+Z

Alternatively referred to as Ctrl+Z and C-z, ^z, Ctrl+Z is a keyboard shortcut most often used to undo the previous action. This shortcut is useful if you need to get the terminal back while working on something. It sends the SIGTSTP signal to the foreground process.

For example, you are working in a text editor and need to break out to find some data. You can use this shortcut to suspend and send the editor to the background, do your other task, and then run fg command to get back into your application.

terminal image

6. Ctrl+D

In the Linux command-line shell, pressing Ctrl+D logs out of the interface. If you used the sudo command to execute instructions as another user, pressing Ctrl+D exits out of that other user and places you back as the user you initially logged into.

7. Ctrl+U

Typed a inaccurate command? Instead of using the backspace to discard the current command, use Ctrl+U shortcut in the Linux terminal. This shortcut erases everything from the current cursor position to the beginning of the line.

8. Ctrl+K

This shortcut is identical to the Ctrl+U shortcut. The only difference is that instead of the beginning of the line, it erases everything from the current cursor position to the end of the line.

9. history

history command is used to view the previously executed command in the terminal. This feature was not available in the Bourne shell. Bash and Korn support this feature in which every command executed is handled as the event and is associated with an event number using which they can be recalled and changed if required. These instructions are saved in a history file. In Bash shell history command shows the whole list of the command

History commands output

10. Ctrl+P

Ctrl+P or Up Arrow: Go to the previous command in the command history.

You can use this shortcut to view the previous command. You can press it repeatedly to hold on going back in the command history.

11. Ctrl+N

Ctrl+N or Down Arrow: This shortcut is used to Go to the next command in the command history.

You can use this shortcut in conjugation with Ctrl+P. Ctrl+N displays the next command. If you are viewing previous instructions with Ctrl+P, you can use Ctrl+N to navigate back and forth. Many terminals have this shortcut mapped to the PgDn key.

12. Ctrl+L

Do you know how to clear your terminal screen? I guess using the clear command.

Instead of writing C-L-E-A-R, you can simply use Ctrl+L to clear the terminal.

Conclusion: Terminal shortcuts

In this blog, we have covered some basic instructions and signal interrupts for Linux. By now, we’ve seen that there are a variety of ways to find out more about your options on the terminal. Do visit the given link for more shortcuts https://blog.knoldus.com/basic-linux-instructions-for-beginners/

For more superior & informative blogs check out our blog site https://blog.knoldus.com/category/devops/



Scala Future


Most Popular