cd
command, also known as chdir
(change directory),
is a command-line shell command. It is used in navigating the Linux/Unix system and is widely used when writing Shell Script.
Change from Present Working Directory to another directory
cd <Directory Name>
Navigate to a Certain directory
~$ cd <directory_path>
~$ cd /home/nitendratech
Navigate to the home directory using tilde(~) symbol
cd ~
~$ cd ~
~$ pwd
/home/nitendratech
Navigates to the root directory
cd /
:~$ cd /
:/$ pwd
/
:/$
Move to the previous directory from the current directory
We can use the cd command with .. To move to the previous directory.
:~/tutorials$ pwd
/home/nitendratech/tutorials
:~/tutorials$ cd ..
:~$ pwd
/home/nitendratech
Move two directories back from the current directory
W can use this command
to move two directories backcd ../..
:~/tutorials/hive$ pwd
/home/nitendratech/tutorials/hive
:~/tutorials/hive$ cd ../..
:~$ pwd
/home/nitendratech