DEV Community

yash sugandh
yash sugandh

Posted on • Updated on • Originally published at Medium

Linux Navigation For Beginners

In this post, we are going to explore commands related to navigation in the Linux Operating System(OS). Although I am using Ubuntu these commands will work on any Linux distribution.So let's start

Now for navigating from one directory/folder to another directory we first need to find out where we currently are.

So how can we do that?

1.pwd command

pwd stands for print working directory. We use pwd command to find out which directory we are currently working in.

pwd command example

From the above image, we can see that we called the pwd command and it gave us the result that we are currently working on the /Downloads directory/folder of user linux-learning.

Now that we know how to check for the current working directory, the next question is how do we find out all the files and folders in our current directory.

2. ls command

To solve the problem we discussed above we use the ls command. ls stand for list.

Okay, ls means list but list of what?

The command ls is used to List information about the files and folders.

ls command example

From the above image, we can see that we called ls command and it gave us the result that there are currently 10 folders inside our current directory.

Now the next question that comes up is ok we found out that we have 10 folders in our current directory but how can we go inside one of those folders?

3. cd command

To go inside another directory from our current directory we use the cd command. cd stands for change directory.

Okay but how?

The syntax for the cd command

cd <directoy_name>

cd command example

From the above example, we can see that we first use

ls command to list all the files and folders

then we decided to go into folder1 so we use our newly found command

cd to move into folder1

To verify that we have reached our destination folder can you guess which command we can use?

Yeah! you guessed it right pwd

cd with pwd example

Okay now we checked our current working directory with pwd then we checked all the files and folders in our current working directory with ls. Then we moved into a new directory using cd.

Now the only step that is remaining is how do we go back to the previous folder?

To go back to the previous folder we again use our cd command

cd back example

From the above example, we can see that we can use cd .. for going back to the previous folder.

Now the biggest question is what is the meaning of ..?

In Linux OS there are two references that are stored in each and every folder.
1. The ..(double dot) which is a reference to the previous folder.
2. The .(dot) is a reference to our current folder.

But if these references are present in each folder how come we did not see them when we use ls command?

So these references are hidden and to view these references using ls command we use the option ls -a which returns us all the files and folders even the hidden ones.

ls -a example

Okay, so that’s all the basic navigation we need to explore Linux filesystem.

I hope you understood the basics of navigation in Linux. Please, let me know if there are any questions.

Top comments (3)

Collapse
 
maxdevjs profile image
maxdevjs

Is previous folder used as a synonymous of parent folder, right?

Collapse
 
yashsugandh profile image
yash sugandh

correct it's used as a synonym for parent folder

Collapse
 
long_yoda profile image
Vo Hoang Long

Very nice series. Please keep to future !