Some Interesting Linux commands

Some Interesting Linux commands

Here are some of the most notorious Linux commands

Table of contents

tac

Many people may have know some fundamental Linux commands like ls and cat. But have your heard about a command called tac. The command cat has the syntax,

cat file.txt

It is used to print the contents in the file. Similarly the command tac also prints the content in the file, but in reverse order.

tac file.txt

sed

This is a very useful command called as stream editor. This command is used to search for a particle text in a file and replace it with other text. It has the following syntax,

sed 's/text_to_be_replaced/new_text/g ' file.txt

The argument s implies the word to be searched and the argument g states a global search. Normally the command just replaces the first text_to_be_replcaed, but with g argument it replaces all the words.

ln

In windows and mac we have must have came across the word shortcut in our home screen or in any location. The ln command is similar to that, it creates a shortcut(link) to the original file. The syntax is,

ln -s target_location -T "shortcut name"

This command create a link to target_location which may be a file or application. There are two types of link, a hard link and a soft link. The command mentioned above is a soft link depicted by letter s. In a hard link the files are moved or copied from a location to another but the space is not consumed as it directly links the data of source

head and tail

The head and tail command are used to show the first 10 lines or last 10 lines in a file . it can also be modified to show 20 lines of code by using the n parameter. It's syntax is,

head -n 20 file.txt

This gives only the first 20 lines of the file.txt file.

sort

If you want to sort a file of words, you can use the sort command , it's syntax is

sort file.txt

Did you find this article valuable?

Support hari's blog by becoming a sponsor. Any amount is appreciated!