cd command is used to move into another directory and make it the current working directory.
Syntax:
cd [directory]
For example, to change the current directory from animals
to birds
, you would type:
cd birds
animals directory should be one level up of birds directory (animals is the parent of birds). |
To change current directory to root, home, parent directories, refer the below table.
Directory | Command |
root | cd / |
parent(one level up) | cd .. |
home | cd ~ or cd |
Examples
To change directory from
/usr
to/usr/local/share
directory, you would type:
cd local/share
Suppose that you want to go to the Downloads directory from your current directory, and you know that the Downloads directory resides in the home directory, you type:
cd ~/Downloads
For Example, you are in the
/usr/local/share
directory, and you want to switch to the/usr/local/src
. You can do that by typing:
cd ../src