Search This Blog

Sunday, May 20, 2012

CLI: 3. Navigating cmd line - cd

The command cd allows switching to, into, or out of a specified work directory.


Consider that cd-ing into something is to enter in a pathname.  There are either absolute pathnames (manually-inputted directories) or relative pathnames (facilitated by the use of a period or periods.)  

For instance, the directory that holds the applications in Linux is /usr/bin.

- To get there, I cd to it. 

*I wrote the absolute pathname.  


- Now you are in the directory /usr/bin.  But say you wanted to leave the directory back to the home directory.  It's simple as writing...

 1. cd ../.. 
*Here I wrote the relative pathname, using double periods (..) to go back a directory and back again.
The / represents the home directory.
or

 2. cd  
*returns you to default. 



- Say you want to go back to the /usr/bin again.  
The easiest way to do this is use a relative pathname.

*Notice you could write bin because by writing that cmd, you implied to reach that directory.  

- To return to a previous directory (like a backward button on web browsers), we write cd -


No comments:

Post a Comment