INTRODUCTION

Linux files system uses cd (change directory) command to navigate into the directories. You can use this command in two ways either provide full path of the directory which is called absolute path or just give directory name which is also known as relative path.

Table of Contents

`

SOLUTION

Let’s see practical example:

For example if we take the previous lecture directories, we started the terminal and use pwd command, the output was /home/haider which is indicating that we are logged in as user haider and standing in the home directory of user haider. Then we change our director to BroExperts which is subdirectory of /home/haider directory.

command we used:

cd BroExperts

Change Directory with Relative Path
Change Directory with Relative Path

So in this example we use only the directory name to move into BroExperts directory. Because our present working directory is parent directory of BroExperts.

Let’s see other example; now we want to change directory which is called LinuxBasics which is located at /tmp/LinuxBasics but our current location is /home/haider/BroExperts.

In this case you need to run:

cd /tmp/LinuxBasics

The full path of LinuxBasics Directory.
See Example:

Change Directory with Absolute Path
Change Directory with Absolute Path

If you want to quickly move into once step back from your present working directory, run:

cd ..
Or if you want to switch back to previous working directory, run:
cd -

I hope above mentioned examples giving clear understanding of using change directory command. I recommend you to do practice of this lecture at least 3 to 4 times. If you have any question please leave comment and don’t forget to say thanks, as it’s free. 🙂

Next: How to View Directory Contents in Linux

Similar Posts