1.功能說明
pwd命令是“print working directory ”首字母縮寫,顯示當前目錄的絕對路徑。
2.語法格式
pwd [option]
pwd 選項
3.命令參數
參數 |
參數說明 |
-L |
當目錄是鏈接(目錄快捷方式)時,顯示連接文件路徑 |
-P |
輸出物理路徑 |
說明:當一個目錄有鏈接文件時,pwd輸出當前路徑 |
4.使用范例
范例1 :不帶任何選項執行pwd命令
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /etc/sysconfig/
[root@localhost sysconfig]# pwd
/etc/sysconfig
范例2:在鏈接目錄下,輸出鏈接文件的路徑,輸出物理路徑
[cxf@localhost ~]$ ls -ld /etc/init.d
lrwxrwxrwx. 1 root root 11 Jul 31 2017 /etc/init.d -> rc.d/init.d l:表示鏈接文件標識符;/etc/init.d指向的真實路徑是/etc/rc.d/init.d
[cxf@localhost ~]$ cd /etc/init.d
[cxf@localhost init.d]$ pwd
/etc/init.d #默認情況下pwd顯示鏈接文件的真實路徑
[cxf@localhost ~]$ cd /etc/init.d
[cxf@localhost init.d]$ pwd -L
/etc/init.d
[cxf@localhost init.d]$ pwd -P
/etc/rc.d/init.d
范例3:/etc/init.d是/etc/rc.d/init.d的鏈接文件,在/etc/init.d目錄,pwd默認顯示鏈接文件路徑,如若需要輸出物理路徑,需要-P
[cxf@localhost init.d]$ cd /etc/init.d
[cxf@localhost init.d]$ pwd
/etc/init.d
[cxf@localhost init.d]$ pwd -L
/etc/init.d
[cxf@localhost init.d]$ pwd –P #顯示物理路徑
/etc/rc.d/init.d
...........................
[cxf@localhost init.d]$ cd /etc/rc.d/init.d/
[cxf@localhost init.d]$ pwd
/etc/rc.d/init.d
[cxf@localhost init.d]$ pwd -P
/etc/rc.d/init.d
[cxf@localhost init.d]$ pwd -L
/etc/rc.d/init.d
注:在物理路徑下,pwd –L 是不能輸出鏈接文件路徑;在鏈接文件目錄下,pwd –P能輸出物理路徑。