每天一個 Linux 命令(3):pwd 命令
Linux中用 pwd 命令來檢視”當前工作目錄“的完整路徑。 簡單得說,每當你在終端進行操作時,你都會有一個當前工作目錄。
在不太確定當前位置時,就會使用pwd來判定當前目錄在檔案系統內的確切位置。
1.命令格式:
pwd [選項]
2.命令功能:
檢視”當前工作目錄“的完整路徑
3.常用引數:
一般情況下不帶任何引數
如果目錄是連結時:
格式:pwd -P 顯示出實際路徑,而非使用連線(link)路徑。
4.常用例項:
例項1:用 pwd 命令檢視預設工作目錄的完整路徑
命令:
pwd
輸出:
[root@localhost ~]# pwd /root [root@localhost ~]#
例項2:使用 pwd 命令檢視指定資料夾
命令:
pwd
輸出:
[root@localhost ~]# cd /opt/soft/ [root@localhost soft]# pwd /opt/soft [root@localhost soft]#
例項三:目錄連線連結時,pwd -P 顯示出實際路徑,而非使用連線(link)路徑;pwd顯示的是連線路徑
命令:
pwd -P
輸出:
[root@localhost soft]# cd /etc/init.d [root@localhost init.d]# pwd /etc/init.d [root@localhost init.d]# pwd -P /etc/rc.d/init.d [root@localhost init.d]#
例項4:/bin/pwd
命令:
/bin/pwd [選項]
選項:
-L 目錄連線連結時,輸出連線路徑
-P 輸出物理路徑
輸出:
[root@localhost init.d]# /bin/pwd /etc/rc.d/init.d [root@localhost init.d]# /bin/pwd --help [root@localhost init.d]# /bin/pwd -P /etc/rc.d/init.d [root@localhost init.d]# /bin/pwd -L /etc/init.d [root@localhost init.d]#
例項五:當前目錄被刪除了,而pwd命令仍然顯示那個目錄
輸出:
[root@localhost init.d]# cd /opt/soft [root@localhost soft]# mkdir removed [root@localhost soft]# cd removed/ [root@localhost removed]# pwd /opt/soft/removed [root@localhost removed]# rm ../removed -rf [root@localhost removed]# pwd /opt/soft/removed [root@localhost removed]# /bin/pwd /bin/pwd: couldn't find directory entry in “..” with matching i-node [root@localhost removed]# cd [root@localhost ~]# pwd /root [root@localhost ~]#
相關文章
- 每天一個Linux命令(6):rmdir命令Linux
- 每天一個Linux命令(5):rm命令Linux
- 每天一個Linux命令(2):shutdown命令Linux
- 每天一個 Linux 命令(12):more 命令Linux
- 每天一個 Linux 命令(16):which 命令Linux
- 每天一個linux命令(1):find命令之execLinux
- 每天一個Linux命令(1):xargsLinux
- 每天學一個 Linux 命令(15):manLinux
- 每天學一個 Linux 命令(13):touchLinux
- 每天學習一個Linux命令-目錄Linux
- Linux常用基本命令( tree, pwd, cd )Linux
- 每天一個linux命令--持續更新中~~Linux
- Linux常用命令之ls、cd、pwd、mkdir命令講解Linux
- 每天一個Linux命令-使用du檢視檔案大小Linux
- 學習一個 Linux 命令:shutdown 命令Linux
- 每天一個設計模式之命令模式設計模式
- Linux運維pwd命令有什麼用途?linux運維主要做什麼Linux運維
- 每天一個Linux命令之ps-檢視系統程式資訊Linux
- 學習一個 Linux 命令:pstreeLinux
- 每天一條Linux命令(24) ssh (遠端安全登入)Linux
- linux開坑記–常用的3個命令Linux
- Linux系統命令3Linux
- 【3】Linux常見命令Linux
- linux最常用的20個命令(一)Linux
- linux命令學習(date,cal,df,free,exit,pwd,ls,cd,file,less,萬用字元)Linux字元
- 【Linux命令】grep命令Linux
- Linux命令—–CP命令Linux
- Unix檔案系統和pwd命令實現詳解
- Linux簡單命令(一)Linux
- linux刪除資料夾命令是什麼 linux刪除一個目錄的命令Linux
- 6個有趣的Linux命令Linux
- Linux命令技巧之30個必會的命令技巧Linux
- 重新點亮linux 命令樹————幫助命令[一]Linux
- Linux的幾個新手必備的命令(一)Linux
- 如何用Linux的at命令安排一個任務Linux
- Linux命令(1)——xargs命令Linux
- Linux命令之lldptool命令Linux
- Linux命令篇 - sed 命令Linux
- Linux命令篇 - grep 命令Linux