useful command line or terminal commands

10 Quick and Simple Command Line Commands to Boost Efficiency

In this post, I want to introduce you to 10 super useful command line or terminal commands to improve your productivity. If you’re a beginner I’d suggest you read our previous post on beginners guide to Linux commands. Otherwise, let’s start.

grep apple fruits.txt
The ‘grep’ command is used to find specific text within a file. This particular command will find all occurrences of the word “apple” in the file “fruits.txt”.

cut -f2 -d',' -g'30+' name_file.csv
We can use the ‘cut’ command to extract specific columns from a CSV file. This command extracts the names of people who are 20 years old or older from a CSV file with three columns (name, age, and salary).

awk '/even/{sum+=$1} END{print sum}" filename.txt
If you have a file with numbers, this specific ‘awk’ command will add up all the even numbers. The ‘awk’ command is a very powerful and useful one. It is widely used by data scientists across the world. It is used for manipulating text and performing calculations.

sed -i 's/oldtext/newtext/g'" filename.txt
This specific ‘sed’ command will convert all the text in a file to uppercase. Just like ‘awk’, the ‘sed’ command is also a very powerful and useful one. It enables you to search for and replace text within files.

sort filename.txt
The ‘sort’ command is used for sorting lines of text within a file in ascending order.

uniq filename.txt
The ‘uniq’ command is used to remove duplicate lines from a file.

tail -n 10 logfile.log
The ‘tail’ command displays the last few lines in a file. For example, If you have a log file that is too large to read, you can use the ‘tail’ command to display the last few lines of it. If you add the option “-n 10” then the tail command will display the last 10 lines from the file.

head -n 5 filename.txt
The ‘head’ command is similar to the tail command but instead of displaying the last lines, the ‘head’ command will display the first lines.

history
The ‘history’ command is useful for displaying a list of previously executed commands in the terminal.

alias
The ‘alias’ command is a very helpful one. It is used for creating a shortcut for another longer command. For example, if you frequently run the command “ls -al” to list files in long format. You can create an alias by typing “alias ll=’ls -al’” in your terminal. After that, whenever you type “ll”, it will run the “ls -la” command for you.

Also, read our simple guide to mastering Git

See also  Top 10 Most Expensive Metals in the World