cd command

To move from current working directory to another directory, use this command.

Syntax:

cd [option]  DIR_NAME /DIR_PATH

Some use of this command is as follows.

1. cd  DIR_NAME :

Useful to go to the directory present inside the directory

 Example:-









The directory named king is our current working directory, many sub directories and files are present inside this directory. If we want to go to the directory named android then we will use cd android command.

2. cd  ABSLUTE_PATH :-

To go to a directory, you can go to that directory with the help of the absolute path of that directory. 

The absolute path of a directory relative to the root directory is called. 

example :-

You can  go from king directory to android directory with the help of absolute path. 

$ cd   /home/king/android 

3. cd  RELATIVE_PATH :-

If you want to go from current working directory to any other directory then path of destination directory with respect to current working directory is called relative path of destination directory. 

  You can go to the directory in which you want to go with the help of relative path of that directory. 

$ cd ./android/view 







RELATIVE_PATH= ./android/view 

Here . (Dot) denotes current working directory .

Destination directory= view 

                          OR 

$cd  android/view 








We go from current working directory to another directory so it is not necessary to display dot (.).

4. cd  .  :- Here the dot represents the current working directory so the directory will not change.





5. cd  ..  :-   The double dot(..) represents the parent directory, thus we can go to the parent directory.





Here the parent directory of Android is king, after the cd .. command, moved to the king directory.

6. cd ~ :-  The user uses this shortcut to go to his home directory.  





User's home directory is king and we moved from view directory to king directory with the help of this shortcut.

7. cd  -  :-  to go to the previous directory  





We moved from the king directory to the view directory, after that with the help of the shortcut , we came back to the king directory again.

8. cd "dir name" :-u If you have a directory name containing a space, then you would use something like this format.






Inside the view directory, there is a space  in the directory named my name , double quotes have been used to go inside it, you can also use single quotes if you want.


I have tried to make it easy to understand by taking the Linux manual page as a reference.


If you liked this article, please help others by sharing.If there is anything incorrect in this or it needs more improvement then you can comment me in the comment box below or contact at  query.me


 


Comments

Popular posts from this blog

ls command

wc Command

ifconfig command