基礎命令學習目錄首頁html
原文連接:https://blog.csdn.net/gnail_oug/article/details/70664458post
pwd
是Print Working Directory
的縮寫,其功能是顯示當前所在工做目錄的全路徑。主要用在當不肯定當前所在位置時,經過pwd
來查看當前目錄的絕對路徑。學習
pwd [選項]
參數:
-L
:--logical
,顯示當前的路徑,有鏈接文件時,直接顯示鏈接文件的路徑,(不加參數時默認此方式),參考示例1。
-p
:--physical
,顯示當前的路徑,有鏈接文件時,不使用鏈接路徑,直接顯示鏈接文件所指向的文件,參考示例2。 當包含多層鏈接文件時,顯示鏈接文件最終指向的文件,參考示例3。
--help
:顯示幫助信息。
--version
:顯示版本信息。 url
[root@localhost var]# pwd /var
[root@localhost ~]# cd /var/ #進入/var目錄,該目錄下有個mail鏈接文件,方便對比查看 [root@localhost var]# ll total 164 ... drwxr-xr-x 12 root root 4096 Apr 22 19:56 log lrwxrwxrwx 1 root root 10 Oct 17 2015 mail -> spool/mail drwxr-xr-x 2 root root 4096 May 11 2011 nis ... [root@localhost var]# cd mail/ #進入mail目錄,mail爲鏈接文件。 [root@localhost mail]# pwd #默認,使用鏈接文件,直接顯示鏈接文件全路徑。 /var/mail [root@localhost mail]# pwd -P #不使用邏輯路徑,鏈接文件最終指向的文件 /var/spool/mail
[root@localhost ~]# ll # /root目錄下面有個dir1目錄,test鏈接文件指向dir1目錄 total 12 drwxr-xr-x 2 root root 4096 Apr 24 05:51 dir1 lrwxrwxrwx 1 root root 5 Apr 24 05:54 test -> dir1/ [root@localhost ~]# ll /home/ #/home目錄下面有一個test鏈接文件,指向/root/test鏈接文件 total 20 drwx------ 16 sgl sgl 4096 Oct 17 2015 sgl lrwxrwxrwx 1 root root 10 Apr 24 05:55 test -> /root/test [root@localhost ~]# cd /home/test/ #經過cd命令進入/home/test [root@localhost test]# pwd #默認,只顯示鏈接文件的全路徑 /home/test [root@localhost test]# pwd -P # 顯示鏈接文件最終指向的文件的全路徑。注意這裏不是/root/test。 /root/dir1