Technology

6 Terminal Command Line Tips on Linux

Most of Linux’s system administration tasks such as installing and configuring software packages and services are done on the command-line also popularly known as the terminal. Therefore, working on the command-line is mostly preferred to GUI and most system administrators usually work away on the terminal. As such, a few tips and tricks are quintessential for you to work seamlessly and effectively on the terminal. They not only help you avoid wasting time on otherwise simple tasks but also make your work easy by avoiding issuing repetitive commands. Learning some of the Linux terminal command line tips will give you a solid foundation on the Linux terminal.

In this guide, I have six Linux command practices that if you follow you will enjoy working on tasks that require you to use commands.

1. Linux screen command

Our tutorial wouldn’t be complete without us mentioning the Linux screen command.  The Linux screen command is handy especially when you have a command that you need to run in the background but do not want to terminate it and you want to have interactions with it later on. For example, if you are pinging a server or a website, the ping command output will go on and on until you interrupt it. With Screen command, you can interrupt the process and later come back and continue where you left. In other words, it helps you attach and detach from a screen.,

If you are running a command with very lengthy output, run  screen command

# screen

On the terminal  run the command e.g

# ping 8.8.8.8

Next, press   Ctrl + A  on your keyboard

Then

Hit the d key on your keyboard to detach the screen. This takes the process to the background.

To resume the session that’s running in the background, type

# screen  -dr

2.! (Execute Previous Command)

When you need to execute what a command previously did,  you can always do so with the! (exclamation mark) followed by the command. For example, if you want to execute the ping command in exactly the same way it was used, run

!ping

ping

From the output above, we can see that ping has sent ping requests to  google.com and that was how it was last used. 

3. CTRL+R (Repeat the last matching command)

If you are at a loss of how the command was last used on a Linux terminal, worry not. Simply press

Ctrl + R, then followed by the command

4. Use the history Command

You will come to learn that history command is a helpful command that gives you a history of previously used command in a list.

To get a list of previously used commands simply run

# history

history

5. Use grep and Find Expressions

There is always something to look for in your machine. Knowing how to implement grep and find will save you a lot of time by typing fewer commands.

For example, when searching for case sensitive letters use grep – i Error logfile and to search for ZIP patterns inside a ZIP file use zgrep – I Error *.gz 

6. Use of Aliases and Defining in Bash Profile (bashrc file)

Use aliases for common commands in the .bashrc and .profile file. The most common alias is the “l” that looks for hidden files, the “ls” identifies all options available for use, and the “-lrtH shows relevant information.

These are some of the useful command-line tips that you can use to make your work easier. Give them a try and see your productivity improve!

Related Articles

Back to top button
India’s Space Journey: From Carrying Rockets on Bicycles to Chandrayaan-3 Chandrayaan-3 landing Time Bitcoin Could Drop to $10K-$12K by Q1 2023