cd command in Linux

The cd command is used to change the working directory. cd stands for changing directory.

For example, We have to change the working directory to the bin directory. The command is

cd /bin

The / is given because the bin directory is inside the parent directory.

Absolute and Relative Paths

Linux file systems can be navigated with the help of an absolute path and relative path.

The absolute path starts with a '/'. This means that the path begins from the root directory[Parent directory].

For example, We can go to the Practice directory in Two methods as below

By using the absolute path

cd /home/saby/Documents/Practice


By using the relative path

cd /home
cd saby
cd Documents
cd Practice

The relative path does not start with a '/'. It determines the location relative to the present position.

For example,


Now to change the directory one step behind i.e from the bin directory to the / directory, the command is

cd ..


To change the directory from the /bin directory to the home directory of the user the command is

cd ~



By using the below command you can also change the directory from the /bin to the home directory.

cd --


pushd and popd command

The pushd and popd are Linux command in a bash shell and certain other shells which saves current working directory location to memory and bring to the directory from memory as the current working directory, respectively as well as changes directory.

The above command saves the current location to memory and changes to the requested directory. As soon as popd is fired, it fetches the saved directory location from memory and makes it the current working directory.

Troubleshoot Change of Directory Issues

If there are issues with the change directory, check the parameters:

  • The directory does not exist.
  • Absolute vs Relative path.
  • Permissions.
  • File Type.
  • Parent Directory Permissions.
  • Hidden directories.

PWD command in Linux

Let us run the command PWD from the prompt. The current working directory in /home/saby is displayed.

where the 1st slash is for the parent directory (i.e)Root. Inside the parent directory, the home directory is present and inside the home directory, the Saby user is present in which we are currently working.


0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions