Javatpoint Logo
Javatpoint Logo

Linux cd Command

The "cd" stands for 'change directory' and this command is used to change the current directory i.e; the directory in which the user is currently working.



It is the most important and common command and will be used many times. With the help of this command you can move all over your directories in your system. You can go to your previous directory or previous to previous directory, or anywhere. Now let's see how.

1) Change from current directory to a new directory

CD Command1

In the snapshot, first I have given pwd command, it brings me to the current directory, that is /home/sssit. Now I have given the command 'cd' to change my current directory and have mentioned the path for the new directory /home/sssit/Desktop. Now as you can see I'm on my new directory that is Desktop. And now my current working directory has changed toDesktop.

2) Change directory using absolute path

In absolute path we have to mention whole path starting from root.

CD Command2

In above example, we want to change our directory to 'certs' from 'cups'. So we are providing the whole path /run/cups/certs starting from the root (/). This is called absolute path.

3) Change directory using relative path

CD Command3

This exmple is same as the above one. Only difference is that we are providing relative path. Look, here also we have changed our directory from 'cups' to 'certs' but have not mentioned the whole path. This is the relative path.

cd Options

cd ~Brings you to your home directory.
cd -Brings you to your previous directory of the current directory.
cd ..Brings you to the parent directory of current directory.
cd /It takes you to the entire system's root directory.
cd ../ ../dir1/dir2It will take you two directories up then move to dir1 and then finally to dir2.

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA