首頁 > 運維 > linux運維 > 主體

linux pwd指令如何使用

WBOY
發布: 2023-05-18 08:40:11
轉載
3947 人瀏覽過

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 pwd指令如何使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!