命令參數
cd:
usage: cd [-L|-P] [dir]
-L 鏈接目錄
-P 實際目錄
dir 要去的目錄
cd 到home目錄
[root@guofeng ~]# cd /usr/local/nginx-1.6.2
[root@guofeng nginx-1.6.2]# pwd
/usr/local/nginx-1.6.2
[root@guofeng nginx-1.6.2]# cd
[root@guofeng ~]#
cd / 到根目錄
[root@guofeng ~]# cd /
[root@guofeng /]# cd
[root@guofeng ~]# cd ..
[root@guofeng /]# pwd
/
[root@guofeng /]# cd /usr/local/nginx-1.6.2
[root@guofeng nginx-1.6.2]# cd /
[root@guofeng /]#
cd .. 返回上一級目錄
[root@guofeng nginx-1.6.2]# pwd
/usr/local/nginx-1.6.2
[root@guofeng nginx-1.6.2]# cd ..
[root@guofenglocal]# pwd
/usr/local
[root@guofenglocal]# cd ../../
[root@guofeng /]# pwd
/
[root@guofeng /]# cd /usr/local/
[root@guofenglocal]# pwd
/usr/local
[root@guofenglocal]#
cd -L -P 到鏈接的文件 或者到實際目錄
[root@guofeng/]# cd usr/
[root@guofeng usr]# ll
total 132
dr-xr-xr-x. 2 root root 36864 May 2319:26 bin
drwxr-xr-x. 2 root root 4096 Sep 232011 etc
drwxr-xr-x. 2 root root 4096 Sep 232011 games
drwxr-xr-x. 35 root root 4096 May 2204:49 include
dr-xr-xr-x. 27 root root 4096 Nov 72014 lib
dr-xr-xr-x. 86 root root 36864 May 2319:26 lib64
drwxr-xr-x. 22 root root 12288 Nov 82014 libexec
drwxr-xr-x. 22 root root 4096 May 2423:16 local
dr-xr-xr-x. 2 root root 12288 May 2319:26 sbin
drwxr-xr-x. 175 root root 4096 Nov 72014 share
drwxr-xr-x. 4 root root 4096 Nov 82014 src
lrwxrwxrwx. 1 root root 10 Nov 82014 tmp -> ../var/tmp
[root@guofeng usr]# cd -L tmp/
[root@guofeng tmp]# ll
total 0
[root@guofeng tmp]# cd ..
[root@guofeng usr]# cd -P tmp/
[root@guofeng tmp]# cd ..
[root@guofengvar]# pwd
/var
[root@guofengvar]#
cd - 返回進入此目錄之前所在的目錄
[root@guofeng /]# cd /usr/
[root@guofeng usr]# cd local/
[root@guofenglocal]# cd apache-tomcat/
[root@guofeng apache-tomcat]# ll
total 8
drwxr-xr-x. 3 root root 4096 Nov 72014 apache-tomcat1
drwxr-xr-x. 3 root root 4096 Nov 72014 apache-tomcat2
[root@guofeng apache-tomcat]# cd -
/usr/local
[root@guofenglocal]#