每天学习Linux(3)---pwd命令
Linux中用?pwd?命令來(lái)查看”當(dāng)前工作目錄“的完整路徑。?簡(jiǎn)單得說(shuō),每當(dāng)你在終端進(jìn)行操作時(shí),你都會(huì)有一個(gè)當(dāng)前工作目錄。?
在不太確定當(dāng)前位置時(shí),就會(huì)使用pwd來(lái)判定當(dāng)前目錄在文件系統(tǒng)內(nèi)的確切位置。
1.命令格式:
pwd?[選項(xiàng)]
2.命令功能:
查看”當(dāng)前工作目錄“的完整路徑
3.常用參數(shù):
一般情況下不帶任何參數(shù)
如果目錄是鏈接時(shí):
格式:pwd?-P??顯示出實(shí)際路徑,而非使用連接(link)路徑。?
4.常用實(shí)例:
? ? ? ?實(shí)例1:用?pwd?命令查看默認(rèn)工作目錄的完整路徑
命令:
pwd?
輸出:
[root@localhost?~]#?pwd
/root
[root@localhost?~]#
?
實(shí)例2:使用?pwd?命令查看指定文件夾
命令:
pwd
輸出:
[root@localhost?~]#?cd?/opt/soft/
[root@localhost?soft]#?pwd?
/opt/soft
[root@localhost?soft]#
?
?
實(shí)例三:目錄連接鏈接時(shí),pwd?-P??顯示出實(shí)際路徑,而非使用連接(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]#
?
?
實(shí)例4:/bin/pwd
命令:
/bin/pwd?[選項(xiàng)]
選項(xiàng):
-L?目錄連接鏈接時(shí),輸出連接路徑
-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]#
實(shí)例五:當(dāng)前目錄被刪除了,而pwd命令仍然顯示那個(gè)目錄
?輸出:
[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?~]#
轉(zhuǎn)載于:https://www.cnblogs.com/epipremnum-aureum/p/4663080.html
總結(jié)
以上是生活随笔為你收集整理的每天学习Linux(3)---pwd命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 普拉多2700价格多少,性能怎么样?值得
- 下一篇: 第三波精品Android源码袭来!免费下