linux 每天一個命令(cd) 只需要1分鐘

1, cd 全名(change directory) 改變目錄 linux 使用最多命令

命令參數
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@guofeng local]# pwd
/usr/local
[root@guofeng local]# cd ../../
[root@guofeng /]# pwd
/
[root@guofeng /]# cd /usr/local/
[root@guofeng local]# pwd
/usr/local
[root@guofeng local]# 

cd -L -P 到鏈接的文件 或者到實際目錄

[root@guofeng /]# cd usr/
[root@guofeng usr]# ll
total 132
dr-xr-xr-x.   2 root root 36864 May 23 19:26 bin
drwxr-xr-x.   2 root root  4096 Sep 23  2011 etc
drwxr-xr-x.   2 root root  4096 Sep 23  2011 games
drwxr-xr-x.  35 root root  4096 May 22 04:49 include
dr-xr-xr-x.  27 root root  4096 Nov  7  2014 lib
dr-xr-xr-x.  86 root root 36864 May 23 19:26 lib64
drwxr-xr-x.  22 root root 12288 Nov  8  2014 libexec
drwxr-xr-x.  22 root root  4096 May 24 23:16 local
dr-xr-xr-x.   2 root root 12288 May 23 19:26 sbin
drwxr-xr-x. 175 root root  4096 Nov  7  2014 share
drwxr-xr-x.   4 root root  4096 Nov  8  2014 src
lrwxrwxrwx.   1 root root    10 Nov  8  2014 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@guofeng var]# pwd
/var
[root@guofeng var]# 

cd - 返回進入此目錄之前所在的目錄

[root@guofeng /]# cd /usr/
[root@guofeng usr]# cd local/
[root@guofeng local]# cd apache-tomcat/
[root@guofeng apache-tomcat]# ll
total 8
drwxr-xr-x. 3 root root 4096 Nov  7  2014 apache-tomcat1
drwxr-xr-x. 3 root root 4096 Nov  7  2014 apache-tomcat2
[root@guofeng apache-tomcat]# cd -
/usr/local
[root@guofeng local]# 
發佈了43 篇原創文章 · 獲贊 8 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章