DEV Community

Khaled Abdel-Fattah
Khaled Abdel-Fattah

Posted on

For Beginners : Maximize Your Efficiency with Must-Know Linux Shortcuts

Are you a beginner learning Linux and struggling with the command line interface? Don't worry, you are not alone. The command line interface can be frustrating at first, but with the right shortcuts, you can increase your productivity and become more efficient in no time. In this article, I will introduce you to some essential shortcuts that every beginner should know. These shortcuts will not only help you navigate through the terminal faster but also increase your productivity while learning Linux. So let's dive in!

1 >> When working in the terminal, your screen can quickly become messy with much text. This can make it difficult to read the output of your commands. So to clear the terminal screen, you have a couple of options:

  • when you start learning you considered to close and re-open your terminal window. This will give you a clean slate to work with, but it's not efficient
  • Typing the command "clear" in the terminal will empty the entire screen and give you a fresh start. However, if you need to clear the screen frequently, typing "clear" every time can be tedious and time-consuming
  • That's where the Ctrl + L shortcut comes in. When you press Ctrl + L, it sends a command to the terminal to clear the screen. This is much faster than typing the clear command.
 Ctrl + L ( The most efficent way to clear your terminal screen)
Enter fullscreen mode Exit fullscreen mode

2 >> Do you want to view a list of the previous command that you typed, The history command in Linux shows a list of all previously executed commands in the terminal session. This is useful for quickly accessing and re-executing a command that you used earlier. To use the history command, simply type **history **in the terminal, and it will display a numbered list of the commands.

$ history
  1  ls
  2  cd Documents/
  3  touch example.txt
  4  vim example.txt
  5  rm example.txt
  6  history
Enter fullscreen mode Exit fullscreen mode

*** To re-execute a specific command** from the history list, you can use the ! shortcut. Simply replace with the command number from the history list that you want to execute. For example, if you want to re-execute the command numbered 4 in the above example, type !4 and press enter. The command will be executed again.

$ !4
vim example.txt
Enter fullscreen mode Exit fullscreen mode

3 >> Take advantage of auto-complete with Linux, the TAB key in Linux is a powerful tool that can save you time and effort when working in the terminal. It is used for auto-completion of commands and file names, making it easier to type long or complex names. For example, if you want to navigate to a directory named "my-long-directory-name", you can start typing cd my and then press the TAB key. The terminal will automatically complete the name of the directory, saving you time and effort.

Another useful feature of the TAB key in Linux is that it can show you all the possible options for a command or file name. To use this feature, simply type the command or file name and then press the TAB key twice.

$ ls - 
--all  --almost-all  --author  --block-size=  --color=  --directory  --dired  --escape  --file-type  --format=  --full-time  --group-directories-first  --hide=  --hide-control-chars  --human-readable  --ignore=  --indicator-style=  --literal  --numeric-uid-gid  --quote-name  --quoting-style=  --recursive  --reverse  --show-control-chars  --si  --size  --sort=  --time=  --time-style=  --version
Enter fullscreen mode Exit fullscreen mode

4 >> Ctrl + C: This shortcut is used to interrupt the currently running command or process. For example, if you accidentally started a command that is taking too long or causing issues, you can use Ctrl + C to stop it.

$ sleep 10    # Press Ctrl + C to interrupt the command before it finishes
^C
Enter fullscreen mode Exit fullscreen mode

5 >> Ctrl + A: This shortcut is used to move the cursor to the beginning of the current line.


6 >> Ctrl + E: This shortcut is used to move the cursor to the end of the current line.


7 >> Ctrl + R: This shortcut is used to search the command history for a previously executed command. If you need to repeat a command that you've used before, you can use Ctrl + R to search for it in your command history.


8 >> Ctrl + T: is a useful shortcut that allows you to swap the two characters before the cursor. This can be particularly helpful when you mistype a command or when you want to switch the order of two characters quickly. For example, let's say you accidentally typed "sl" instead of "ls". With Ctrl + T, you can quickly swap the "s" and "l" characters to correct the mistake.


9 >> man : This command is used to display the manual page for a command. This can be useful when you need more information about a command and its options.

$ man grep  # if you want to learn more about the grep command, you can use the following command
Enter fullscreen mode Exit fullscreen mode

10 >> --help: is a common option available in many Linux commands that provides a brief description of the command and its available options. It can be very helpful for beginners who are not familiar with a particular command and want to learn more about it. Here are some examples of using the --help option with different commands:

$ ls --help  #This command will display a brief description of the ls command and its available options.
Enter fullscreen mode Exit fullscreen mode

But wait! Don't shut down that Linux machine just yet! I know it might be hard to remember all these shortcuts, and you must be confused now

If you want to view all the keyboard shortcuts available to you, you can use the bind -pcommand in your terminal. This will display a list of all currently defined keyboard shortcuts in your terminal, along with their corresponding commands. This can be a useful reference for learning new shortcuts or refreshing your memory on ones you may have forgotten. Don't be afraid to experiment with these shortcuts and find what works best for you


That's it for now! I hope these Linux shortcuts will help you increase your productivity as you continue to learn and use Linux. Do you have any other favorite shortcuts or tips that you would like to share? Let me know in the comments below! And if you found this article helpful, please give me your feedback.

Top comments (0)