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.

</>
Copy
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.

</>
Copy
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.

</>
Copy
root@tutorialkart# cd tutorialkart/logs

Check the current working directory.

</>
Copy
root@tutorialkart# pwd
/tutorialkart/logs

We have changed the working directory.

Example 2 – Change directory with Complete Path

Change Directory in Linux

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

</>
Copy
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.

</>
Copy
root@tutorialkart# cd /etc/

Check the current working directory.

</>
Copy
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.