Change Directory in Linux

To change directory in Linux, we can use the change directory cd command.

Execute the cd command and pass the directory path as argument to the command, as shown in the following.

cd path/to/directory

The path can be a complete path, or relative path.

Example 1 – Change directory with Relative Path

Change Directory in Linux

In this example, we are at the current working directory /, that is we are at the root of the file system.

root@tutorialkart# pwd
/

Now, let us navigate to the tutorialkart/logs location using change directory cd command. This is kind of an example for using relative path.

root@tutorialkart# cd tutorialkart/logs

Check the current working directory.

root@tutorialkart# pwd
/tutorialkart/logs

We have changed the working directory.

ADVERTISEMENT

Example 2 – Change directory with Complete Path

Change Directory in Linux

In this example, we are at the current working directory /tutorialkart/logs.

root@tutorialkart# pwd
/tutorialkart/logs

Now, let us navigate to the /etc/ location using change directory cd command. This is kind of an example for using complete path.

root@tutorialkart# cd /etc/

Check the current working directory.

root@tutorialkart# pwd
/etc/

We have changed the working directory.

Conclusion

In this Linux Tutorial, we learned how to change current working directory using change directory cd command.