cd command in Linux with Examples
cd command in linux known as change directory command. It is used to change current working directory.
Syntax:
$ cd [directory]
To move inside a subdirectory : to move inside a subdirectory in linux we use
$ cd [directory_name]

In the above example, we have checked number of directories in our home directory and moved inside the Documents directory by using cd Documents command.
Different functionalities of cd command :
- cd /: this command is used to change directory to the root directory, The root directory is the first directory in your filesystem hierarchy.
$ cd /

Above, / represents the root directory.
- cd dir_1/dir_2/dir_3: This command is used to move inside a directory from a directory
$ cd dir_1/dir_2/dir_3

In above example, we have the document directory and inside the document directory we have a directory named geeksforgeeks and inside that directory we have example directory. To navigate example directory we have used command cd Documents/geeksforgeeks/example. - cd ~ : this command is used to change directory to the home directory.
$ cd ~

or
$ cd
cd : this commad also work same as cd ~ command.

- cd .. : this command is used to move to the parent directory of current directory, or the directory one level up from the current directory. “..” represents parent directory.
$ cd ..

- cd “dir name”: This command is used to navigate to a directory with white spaces.Instead of using double quotes we can use single quotes then also this command will work.
$ cd "dir name"

In above example, we have navigated the My songs directory by using cd “My songs” command.
or
$ cd dir\ name :
this command work same as cd “dir name” command.

Recommended Posts:
- du command in Linux with examples
- df command in Linux with Examples
- ZIP command in Linux with examples
- pwd command in Linux with Examples
- apt-get command in Linux with Examples
- wc command in Linux with examples
- cc command in Linux with Examples
- rev command in Linux with Examples
- fmt command in Linux with examples
- Cat command in Linux with examples
- atd command in Linux with examples
- col command in Linux with Examples
- atq command in linux with examples
- w command in Linux with Examples
- sum command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



