Linux is a popular platform like Windows and it is much powerful as the latter. We have Interactive User Interfaces in most of the Linux Distributions such as RedHat, Debian, etc. Still, we can also use its Command Line Interface (CLI), if you are aware of the important Linux commands. In this article, let us discuss few important Linux commands that could help you to use those on the CLI. Read the Linux Guide for Beginners to understand what Linux is All about.

GREP Command

This command is much useful and, especially, in searching. With this command, you can search a string in a file, or files recursively. You can also print the matched file contents to understand what’s there in the file.


Syntax to Search a String in a File:

$ grep -i “the” demo_file

In the above syntax, ‘i’ represents the search and ‘the’ is the word to be searched in the file named ‘demo_file’. Obviously, searching is a basic feature that we expect in any OS and that is why we this command is one of the important Linux commands.

Syntax to Print  few Lines of Text from the Matched File:

$ grep -A 3 -i “example” demo_text

You can use the above syntax to print 3 lines after the matched or searched string i.e, ‘example’ from the file ‘demo_text’. It is much helpful to decide on whether the required file is the one that was picked. With no doubt, it is one of the important Linux commands!

Syntax to Search a String in all the Files Recursively:

$ grep -r “Universe” *

You can also do a recursive search on all the files in a directory or location to list out the matched ones. For this purpose, the above syntax works good and here we are searching for the term ‘Universe’. In the above syntax, ‘*’ says to search in all the files.

SSH Command

It is mainly used to login to a remote host easily and to look into the client version. you can also debug an ssh client with this command. Read here the Linux – Command Line Primer for Beginners for a quick start.


Syntax to Login to a Remote Host:

ssh -l john remotehost.demo.com

In this command, ‘john’ is the user and ‘remotehost.demo.com’ is the remote host address. It seems to be a simpler syntax to log in to a remote host and hence just have a try!

Syntax to Debug the ssh Client:

ssh -v -l john remotehost.demo.com

Here, you can simply debug the remote host ‘remotehost.demo.com’ with the help of the above syntax.

Syntax to Display Version of the ssh Client:

ssh -V

The above syntax would display the client version as below.

OpenSSH_3.9p1, OpenSSL 0.9.7a Mar 23 2005

Read here to know the 5 Basic Linux SSH Client Commands.

TAR Command

It is used to create a new archive or to view an existing archive of tar. With no doubt, it is one of the important Linux commands.


Syntax to Create a New Archive:

$ tar cvf arch_name.tar dirname/

You can create a new tar archive as we did in the above syntax where ‘arch_name.tar’ specifies the tar archive name and ‘dirname/‘ specifies the tar archive path.

Syntax to View an Existing Archive:

$ tar tvf arch_name.tar

It is simpler to view an existing tar archive with the above syntax where ‘arch_name.tar’ is an already archived file.

Syntax to Extract from Existing Tar Archive:

$ tar xvf arch_name.tar

The above syntax is used to extract an already existing tar archive named ‘arch_name’.

FIND Command

Searching is undoubtedly an important feature that we expect or need in any OS or application. It is where the usage of machines is highly expected as it is quicker than by the humans. You can use this FIND command to find files with the file name, execute commands on those files, or you can also find all the empty files in a directory.

Syntax to Find a File with the File Name:

# find -iname “MyFirstProgram.c”

The above syntax would search for the file named ‘MyFirstProgram.c’.

Syntax to Execute Commands on the found File(s):

$ find -iname “MyFirstProgram.c” -exec md5sum {} \;

Once you have identified the required file, you can also execute commands on it like how we did in the above syntax. Here, ‘MyFirstProgram.c’ is the searched file and ‘md5sum’ is the command that we have executed on it.

Syntax to find Empty the Files:

# find ~ -empty

The above syntax lists all the empty files in the current directory. It is an excellent means to thrash your empty files and that is why it is been added to the important Linux commands list. Read here to know the Top 10 Best Linux Apps of 2017.

IS Command

This common is helpful to display the files in a more human understandable format. With this command, you can display the file size, last modified date & time and also you can identify the files with special characters in its names.  


Syntax to Display the File Size:

$ Is -lh

The above syntax displays the output as below where ‘9.6M’ denotes the file size, ‘Mar 22 10:30’ denotes the present date & time and ‘arch-example.txt.gz’ is the file name.

-rw-r- – – – – 1 john team-dev 9.6M Mar 22 10:30 arch-example.txt.gz

Syntax to Order Files with its Last Modified Time:

$ ls -ltr

The above syntax orders the files in the reverse order of its Last Modified Time. So you can see the latest file first.

Syntax to Visually Classify the files with Special Characters in its Names:

$ ls -F

It is a much simpler syntax and it displays the files with special characters such as ‘-‘, ‘_’, etc in its names.

Conclusion-Important Linux Commands

We are done with the few important Linux commands such as GREP, SSH, TAR, FIND, and IS in this article and by no means, they form the complete list. But they are much helpful to get a quick start on Linux commands. You can also read the Basic Linux Commands for Beginners here.  

 

SHARE
Previous articleFacebook Ads Transparency Will Come Next Month
Next articleThe Best Mac Web Browser 2017
Jerold Forney is technology admirer and a computer specialist who is always curious for new technological advancements in the IT industry. With his extensive experience and apprehension of IT industry and technology, He writes after concrete research and analysis with the intention to aid the reader the content full of factual information. Being so ambitious to facilitate the readers, he intermittently tries his hand on the tech-gadgets and services popping frequently in the industry to reduce any ambiguity in his mind related to the project he works, that a huge sign of dedication to his work.

LEAVE A REPLY

Please enter your comment!
Please enter your name here