In this guide, we will be taking a look at how to navigate the file system with the Linux terminal. I would say this is probably the next most important task for beginners to perform, as it will be quite useful. To begin, let’s open up a terminal. If you don’t know how to open a terminal, I would recommend referring to part one of this series and walk through that guide first.

Linux Terminal Basics

By default, your terminal is running “inside” the logged-in user’s home directory. You can find where you are relative to the rest of the file system via the pwd command.

We can also see the files and folders in the directory we’re currently in. To see the list of these files and folders, we can utilize the ls command.

If we want to move around the file system, the cd command is what we’re looking for. Let’s say we want to move into the Documents folder, which we can access since we’re in our home directory. We can move into the Documents folder by running the command:

cd Documents

You may notice that our current path (highlighted by the blue text on our current line) changed from ~ to ~/Documents. This means that we are now in the Documents folder! Fantastic.

But what if we want to go back to our previous directory? Well, there’s a couple ways we can do this. If we want to move up a level (move back to the parent directory), we can type:

cd ../

If we run this, you will notice our path changed from ~/Documents back to ~. Let’s go back to our Documents folder. It’s your turn to try it!

Once you’re back in the Documents folder, how can we move back to our home directory without moving up a level? The answer is we can enter an absolute path. Let’s try typing the following, just be sure to change jared to the username of your user account.

cd /home/jared

Once you have, you should now see the blue tilde again.

Perhaps you might want a shortcut to navigate to your home directory. There is one. Let’s go back into our documents folder with cd Documents. Remember the tilde? Let’s try entering that into our cd command!

cd ~

If we run this, you should now be back in your home directory! Pretty cool, huh?

Let’s put these commands into practice by visiting the root directory. This directory is the root of all the files in the Linux file system. We know that we’re in our home directory currently, as represented by the tilde. Something neat that we can do is chain multiple ../ strings together to move up more than one level. In our case, we will need to move up two levels to get to the root directory. This is because, if we only move up one level, we will only be in our /home directory (not to be confused with our user account’s home directory as represented by the name of your user account.) Let’s try running the following command:

cd ../../

Try running the command we covered earlier to list the files and folders, you should see the following list of files and directories:

With that, you now know how to move within your file system using the terminal! You’re on the way to becoming a pro at using the terminal!

If you found this guide valuable, please consider sharing it on your social media platform of choice. Also, if you would like to receive news of new tutorials and courses we publish, be sure to fill out the form to sign up for our newsletter.