The command terminal on Linux is a CLI (Command-Line Interface), where you type the commands that would otherwise take time with the GUI. It is equivalent to the Command Prompt (CMD) provided in Windows. The terminal is the perfect way a user can truly feel that they are communicating with their system. It feels invigorating when you type commands on the terminal, and the computer performs exactly what you instructed it to do. The terminal is also great for people who want to know what exactly is going on deep inside the computer. You can understand the pathways and the steps taken by the computer to perform even the very basic tasks. In the end, it all comes down to preference.

To truly master the terminal, you first need to learn the basic navigation on it. We will guide you through the commands used to navigate the files and directories present on your Linux system. So, let’s get started.

The “pwd” Command

The Print Working Directory (pwd) command is one of the basic and primary commands users need to learn about. When you open the terminal, you are usually present in the home directory. If you execute any commands, you likely end up in a directory different from the one you started at. To know which directory you are currently in, you can use the pwd command.

The pwd command tells you about the directory you have ended up in. Knowing your whereabouts is crucial in a CLI environment. Hence pwd is important. The syntax for the command is simple; you just need to type:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/1-3.jpg" data-lazy- height="100" src="data:image/svg xml,” width=”729″>

You should get your directory in output.

The “cd” command

As mentioned earlier, you start in the home directory when you open the terminal. To move around the system to access files and folders, you must continuously change directories. For this purpose, we have the “Change Directory” or the “Cd” command. The name of the command explains its purpose. It is used for shifting from one directory to another.

The basic syntax for this command is:

For example, you must type the following if you want to access the “Downloads” folder.

$ cd /home/username/Downloads

Or you could access it with the following.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/2-3.jpg" data-lazy- height="45" src="data:image/svg xml,” width=”729″>

To go to the home directory, use this command:

To go to the previous directory, do this:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/3-3.jpg" data-lazy- height="43" src="data:image/svg xml,” width=”731″>

To go upwards in a directory, we use “../” with the command. For example, it works that you are currently in the “home/user/Downloads” directory. To move to “home/user” you need to type this:

For getting into the home directory, add another “../”

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/4-3.jpg" data-lazy- height="71" src="data:image/svg xml,” width=”732″>

These are the basic variety of commands associated with Cd.

The “ls” Command

Now, as you have learned to move from one directory to another, the next step is to view the contents of the directory you are in. The ls command is used to view all the files and folders present in the current directory.

The syntax for ls is as follows.

There are different options available with ls. For example, to view all the hidden files in the current directory, we use -a in tandem with ls.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/5-3.jpg" data-lazy- height="135" src="data:image/svg xml,” width=”726″>

If you prefer to see the contents of the directory in an extended form.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/6-3.jpg" data-lazy- height="221" src="data:image/svg xml,” width=”728″>

“l” over here signifies “long”.

To view files arranged according to time of modification, type the following.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/7-3.jpg" data-lazy- height="218" src="data:image/svg xml,” width=”732″>

The “mkdir” Command

To create new directories, we use the “Make Directory” or the “mkdir” command. The syntax for this command is given below.

For example, to make a directory named “wire” in your home directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/8-2.jpg" data-lazy- height="74" src="data:image/svg xml,” width=”731″>

Make sure you are in your home folder.

To make an extended directory, use -p with mkdir.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/9-2.jpg" data-lazy- height="18" src="data:image/svg xml,” width=”730″>

The “touch” Command

You have learned how to make a directory. Now it is time to learn how we can make files inside a directory. Step up the “touch” command. The syntax for touch is given below.

For example, just use the following to create a file named “doc1” inside any directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/10-1.jpg" data-lazy- height="74" src="data:image/svg xml,” width=”730″>

To create multiple files at once in the same directory, type the following.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/11-1.jpg" data-lazy- height="78" src="data:image/svg xml,” width=”733″>

You can also do this by using the absolute address.

$ touch home/username/doc 1 /home/username/doc2

We can use the touch command to create files in any directory if we use their absolute addresses.

The “mv” Command

So far, we have learned how to make directories and files, move within directories, tell which directory we are in, and see the contents of a directory. Now we move on to moving files within directories and to and from a directory. “Move” or “mv” is used for this purpose, and the syntax for this command is given below.

For example, we type the following to move a file named “ball” to a directory named “wire”.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/12-1.jpg" data-lazy- height="89" src="data:image/svg xml,” width=”731″>

If you want to move the file “ball” to your home directory, use the “.” operator at the end.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/13-1.jpg" data-lazy- height="91" src="data:image/svg xml,” width=”728″>

Make sure you are in the home directory before you try and execute this command.

The “cp” Command

To copy files and directories into others, we use the “cp” command. “cp” stands for “Copy” and its syntax is:

For example, to copy the file named ball into another file named ball1, type.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/14.jpg" data-lazy- height="76" src="data:image/svg xml,” width=”729″>

Cp created a file named ball 1 and copied the contents of the ball into ball1.

To copy directories, we use “-r” in addition to cp. It stands for “recursive”. The syntax for this is:

$ cp -r [directory] [directory]

The “rm” and “rmdir” Commands

We use “rm” and “rmdir” for removing files and directories, respectively. The syntax for these two commands is as follows.

$ rm file

$ rmdir directory

Let’s remove the file “ball” and the directory “wire” we created previously. Make sure you are present in the directory containing both items.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/15.jpg" data-lazy- height="144" src="data:image/svg xml,” width=”733″>

Conclusion

This article went through the ways you can navigate through the terminal in Linux. The commands that were gone through in this guide are the basic ones everyone needs to know about. If you master these commands first, the transition of doing much more complex tasks using the terminal should become easier. You should practice these commands continuously, and you should also try to play with them a bit. It should enable you to learn new tricks making it easier to do certain tasks on the terminal.

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/myAvatar-150×150.png" height="112" src="data:image/svg xml,” width=”112″>

Zeeman Memon

Hi there! I’m a Software Engineer by degree, Blogger by skills who loves to write about tech, develop websites & do SEO. You can reach out to me on LinkedIn.