Linux is one of the best – if not the best operating systems out there. Well, the jury is still out on that. While often considered as the third option in the midst of more common operating systems like Windows and Mac, Linux has acquitted itself pretty well and has gained traction among tech enthusiasts and ordinary operating system users as well.

Essential Linux Commands

Linux is a hardy operating system that can deliver the goods – whether you are looking for a secure or an efficient system – once you get the hang of it. And that’s where the problem is – getting the hang of it.

Many have opted against Linux because of its seemingly precipitous learning curve. Unlike GUI-based operating systems like Windows and Mac, Linux is a command-based operating system. The Linux Command Line (CLI) is a set of commands that allow you to navigate and use your Linux system effectively.

These essential Linux commands run in a terminal/shell that functions just like the command prompt of Windows. Granted, it can feel like a herculean task mastering the commands needed to enjoy your Linux use. However, these commands become easier the more you use them.

Recommended Read: Linux commands you should never run on your system

Also Read: Top 7 commands for Linux Network Traffic Monitoring

Linux is a free operating system and thus comes at no cost. It is also open source which means its source code is accessible without any trouble. Because Linux is a project that functions by a community approach, various experts and teams work to continuously advance the functionality of the Linux operating system.

Viruses. That is another factor that sets Linux apart from other operating systems. While a ton of viruses thrives on other operating systems, notably Windows, Linux is averse to viruses: it is robust and resistant to many kinds of viruses. Little wonder over 90% of the internet thrives on the efficiency of Linux servers.

If you are now learning the ropes when it comes to Linux, don’t be discouraged. Getting to grips with the essential Linux CLI commands will make your Linux experience all too exciting and effective. If you are a connoisseur in all things Linux, this may be a vital refresher for your Linux experience.

But Let’s Begin by Understanding Linux

If you are new to Linux, you may be wondering what is so special about this much heralded operating system. To understand Linux, we have to delve into the mind of a man known as Linus Torvalds.

Linux, just like Windows 10, Windows Vista or Mac, is an operating system on which systems run and function. What truly sets Linux apart is that it is an open source platform and runs like a UNIX system.

Torvalds, in 1991 released the Linux kernel. Although originally intending to name it “Freax” he settled for a combination of Linus and UNIX – eventually naming it Linux. He then invited any interested developer and operating system enthusiasts to take part in modifying and developing the kernel provided they would do it for free and the platform remains free for use.

For the last 25 years, Linux has chalked significant successes. While it is a bit more difficult to familiarize with, compared to other options such as Windows, it offers more navigation and flexibility options. To put it simply, with Linux, you can do more.

Essential Linux Commands

While there are a ton of Linux commands, this article will focus on a few key ones you need to know to make your Linux operational. Here are ten Linux CLI commands you should know to be an effective user of Linux.

Do you want to maneuver and manage files within your Linux system? Use these commands:


cp

Every so often, you may have to copy a file or a directory in your Linux system. The command used is the “cp” command. With this command, you can make copies of one or even multiple files. For instance, if you have:

$ cp Folderone Foldertwo

The command will copy contents from Folderone to Foldertwo. Even if perchance, Foldertwo doesn’t exist, the command will create Foldertwo and copy the contents into it.


mv

In Linux, just like in any other operating system, you may need to move or rename files. Sometimes you may even have to do both. The mv command, also known as the move command, allows you to move or rename files.

Think of Windows OS – you can move a file from the downloads folder to the desktop for instance. In the same vein, with Linux, you can move a file or folder to a different directory. Here’s an example of the mv command at work.

Assuming we want to move an application named Canary from folder one to folder two, this command-line below is what we would enter.

$ mv/Canary/applications/Folderone /Canary/applications/Foldertwo

The initial part of the command: mv/Canary/applications/Folderone denotes that the application named Canary should be moved.

The tail-end of the command: Canary /applications/Foldertwo pinpoints that the Canary application should be moved from Folderone to Foldertwo.


rm

Once in a while, you may need to remove files or directories from your system for whichever reason. The rm or remove command is used to get rid of a file or a directory from Linux.

To remove a single file, type the rm command followed by the file name as shown below:

$ rm filename

Once you enter this, one of two things can happen. If the file is write-protected, you will receive a notification asking for confirmation as depicted below:

Output

rm: remove write-protected regular empty file 'filename'?

To confirm and delete the file, simply type y and press enter. The file will be promptly deleted. However, if the file is not write-protected, the file will be deleted immediately when you hit enter without further questions.

You can also delete multiple files at a go by typing the rm command followed by file names, each differentiated by a space as shown below:

$ rm filename1 filename2 filename3

Linux has wildcard characters. These characters can be used to handle more than one file at a go. For instance, if you want to remove all files with the extension .pdf files in a directory, use the following command:

$ rm *.pdf

Because it’s hard to retrieve files after they have been deleted, it is advised that before using the rm command to get rid of files or directories, use the “ls” command to list all files under consideration so that you can make an informed choice about what to delete.

There are a number of options you can consider under the rm command. Depending on the option, you will receive a different return. Here are some options and the ensuing results:

-f (force): Does away with the file without prompting

-i: Receive notification before files are removed

-v (verbose): With this command, you’ll receive an explanation concerning what is being done

-r, -R (recursive): deletes empty directories and their contents without prompting.

-d: removes directories that are empty


cd

Sometimes, when you might be working within a specific directory, but you may need to move to another directory. By using the cd command, you can move from one directory to another.

For instance, if you are in the Applications folder, and you want to go to the Downloads directory, all you have to do is to enter “cd Downloads” and voila, you will be in the Downloads directory.

If you are in, say, the home directory and you want to move to the downloads folder, just type in:

$ cd Downloads

and you’ll access the Downloads folder.

However, there is a caveat. Because Linux is case sensitive, if you type in the wrong name, you’ll face problems. Also, when you make mistakes in typing the name of the directory, you will not be able to access it.

There’s also another thing to take note of. If your folder’s name is, say, John Stones, and you type in “cd John Stones,” the Linux terminal will take the second argument, in this case, “Stones,” as a separate argument. Thus, you will get an error message saying in effect that the directory you are attempting to access does not exist.

To get around this challenge, you can use a backward slash, e.g. “cd John\Stones.” The backward dash resolves the problem.


ls

One of the most important features for any Linux user is the ability to access files, folders, and directories. In Linux, the “ls” function allows a user to access and examine all necessary files, folders, and directories.

The “ls” command is commonly known as the list command. And rightly so, because it outlines the key directories once a file range has been specified. All you have to do to access a directory is to input the accurate directory name after the “ls” command.

For example:

$ ls /applications…

When you enter the above command, you will see all the folders stockpiled in the universal applications folder.

$ ls /a…

Will show you the hidden files.

$ Is /i…

The above command outputs file permissions and sizes as well as the last observed date/time.

Do you want to visualize information on Linux? Use these commands:


man

Often, you would need to scrutinize information on various commands issued on the Linux terminal. The “man” command, otherwise known as the manual command, is employed to show the user manual of any command.

Features like description, options, errors, files, versions, status, etc. are shown using the man command. Through the “man” command, a thorough description of the command is given.

The man command is often described as the meta command of the Linux CLI. Inputting the “man” command will show you all the information about the command you are using.

To use the man command, all you have to do is type in the name of the command whose reference manual you want to access.

$ man [command/tool name]

For instance, if you want to access the user manual of the “ls” command, all you have to do is to type:

$ man /ls

…and you would have access to the user manual.

The man command can be divided up into the following sections: executable programs or shell commands, system calls, library calls, special files, file formats and conventions, games, miscellaneous, system administration commands, and kernel routines.


find

It’s almost impossible to use Linux effectively without using the find command at one point or the other. You might be looking for a specific file or directories. The find command can be used to find files by file names, permissions, owners and groups, date and time, and also based on their size.

The find command can comb through the whole file system to find files and directories based on the search criteria you spell out.

What’s more, the find command – aside from being used to fish out files – can be used to execute other Linux commands such as grep, mv, and rm on the files and directories discovered.

For instance, if you are interested in finding the Linux file named Book1, one may type

$ find. -name Book1

However, this command may yield files as well as directories with matching file names. For Linux to return only the file(files) matching this description, you should enter:

$ find. -name Book1 -type f

If you want to search only the home directory for any file titled Book1, enter:

$ find /home -name Book1.txt -type f


grep

Sometimes the search for files can be daunting particularly if you have to look for a specific pattern or a string within a file. In such a case, the “find” function may not suffice. That is where the grep command comes in.

Grep command in Unix/Linux refers to the ‘global search for the regular expression.’ The grep command searches for patterns according to the given stipulations and returns a line if there is a match.

For instance, if you are searching for a pattern/string with “found” within the folder named Folder1, then you should enter:

$ grep “found” /Folder1

This command will find and return all results with the word “found,” including “foundation,” “founder,” etc.

Conversely, to find and return all files without “found,” insert the -v option.

$ grep -v found /Folder1

Want to create a file(s) in Linux? Use these commands:


touch

One of the most basic functions any operating system should be able to carry out is creating or making new files. In Linux, the “touch” command is employed to create new files. This command is also known as the “make file command.”

It is the easiest and the most effective way of creating new, empty files. Additionally, the touch command can be used to change the times and dates (timestamp) on existing files and directories.

The syntax for the touch command is:

$ touch [option] filename(s)

The touch command also makes it possible to create more than one file simultaneously. The touch command below will create three files.

$ touch file1 file2 file3

One feature that makes the touch command stand out from other commands is that it does not overwrite existing files with the same name, by default. Instead, it just alters the timestamp for such files.


cat

If you are looking to make or read a new text file, show text file on screen, modify a file or you are interested in concatenating a file, then the cat command is just what you need.

The cat command shortened for concatenation is one of the most popular and commonly used commands in Linux. In essence, the cat command is for making files, merging files, and showing files. So, if you need to do any of the three, you can use the cat command.

If you want to create a new file, you can simply enter:

$ cat filename

If you want to create a new file named Book1, you can simply use the command line below followed by the text you want to include and finally saving with ctrl-d:

$ cat > Book1.txt

If you want to create and concatenate two files, start by creating the files:

$ cat > Book1.txt

My first book

$ cat > Book2.txt

My second book

Then, you can concatenate:

$ cat Book1.txt Book2.txt > Book3.txt

$ cat Book3.txt

My first book

My second book

 

Commands for monitoring your system:

iptables

If you are a systems admin, you know how valuable this command can be. This is simply because it can help you to track and manage both internal and external traffic with regards to internet use.

With this command, you can verify the authenticity and validity of the traffic you encounter and ensure no suspicious or malicious program or entry is made into your system.

watch

Hackers with ulterior motives are perpetually hounding systems trying to orchestrate one break-in or another. Keeping a watchful eye on your system and its processes is a fail-safe way of ensuring safety and optimum performance.

However, executing a monitoring command such as head, tail, cat over and over can be arduous and back-breaking. The watch command overcomes this hurdle by making it possible to easily repeat commands.

The watch command operates within a 2-second cycle.

The syntax for the watch command is as follows:

$ watch [options] command


Wrapping it Up

The future of computing is not too far away. In years to come, computers will not just be laptops and smartphones, but computers will be able to process at an incredibly fast rate.

Case-in-point the much-vaunted Quantum Computer. You can read more about quantum computing and the concepts associated with it here.

Currently, it is operating systems like Linux which are changing the landscape of computing. Windows and Mac seem to be the more popular operating systems, however, Linux – often considered the third wheel – is gaining not just traction but converts at a fast rate.

And for a good reason. It is safe, secure, and reliable. But to use it, you’ll have to be familiar with a plethora of commands. Once you get around these commands, your Linux experience will be one to relish.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of your hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.