cd

From Initq

Revision as of 14:50, 26 June 2008 by Qais (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Change the current working directory to directory specified. If directory not specified then change to user's home directory.
cd - takes you back to the last directory you were at.

 [alibaba@ohnonono ~]$ cd /var/www/html
 [alibaba@ohnonono html]$ cd
 [alibaba@ohnonono ~]$ pwd
 /home/alibaba
 [alibaba@ohnonono ~]$ cd -
 /var/www/html
 [alibaba@ohnonono html]$

single dot directory is your current directory and the double dot directory is one folder below.

 [alibaba@ohnonono html]$ ls -la
 total 16
 drwxr-xr-x 2 root root 4096 Aug  6  2007 .
 drwxr-xr-x 8 root root 4096 Dec  2 03:31 ..

you can go back or forward in one command. you can also go back to your home directory two ways.

 [alibaba@ohnonono html]$ cd ../../../
 [alibaba@ohnonono /]$ pwd
 /
 [alibaba@ohnonono /]$ cd ~
 [alibaba@ohnonono ~]$ pwd
 /home/alibaba
 [alibaba@ohnonono ~]$ cd
 [alibaba@ohnonono ~]$ pwd
 /home/alibaba