cd – Change the shell working directory.

cd [-L|-P] [dir]

Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable.

The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used.

If the directory is not found, and the shell option `cdable_vars’ is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR.

-L force symbolic links to be followed
-P use the physical directory structure without following symbolic

The default is to follow symbolic links, as if `-L’ were specified.

Exit Status:
Returns 0 if the directory is changed; non-zero otherwise

Usage of “cd” command

To Navigate to your home directory.
$ cd
$ cd ~

To Navigate previous working directory
$ cd –

To Navigate root directory
$ cd /

To Navigate to the home-related directory where ever you in another directory
$ cd ~/folder/path/

To change the current working directory
$ cd /folder/path/

To change the current directory to its parent directory
$ cd ..

To change the current directory to its two parent directory
$ cd ../../

To change the working directory to the current working directory
$ cd .

To change directory which contains space
$ cd ‘test folder’ or $cd “test folder”
$ cd test\ folder/

***To change the working to a symbolic path
$ cd -P synbolic_link_name

This is about cd command for now. We will be adding more information about ‘cd’ command if we found the use case about cd command.

Here our interest to share knowledge about all command Linux in friendly understanding. Stay tuned to our blog for more knowledge. Please provide your valuable feedback about this blog to encourage to share the knowledge.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.