【Linux】一步一步学Linux——pwd命令(19)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——pwd命令(19)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 附錄
01. 命令概述
pwd命令是print working directory中每個單詞的首字母縮寫,其功能正如所示單詞一樣,為打印工作目錄,即顯示當前工作目錄的絕對路徑。
02. 命令格式
pwd [選項]
03. 常用選項
顯示出 完整的 當前 活動目錄 名稱.-L 打印 $PWD 變量的值,如果它命名了當前的工作目錄-P 打印當前的物理路徑,不帶有任何的符號鏈接默認情況下,pwd 的行為和帶 -L 選項一致--help 顯示 幫助 信息, 然后 退出--version 顯示 版本 信息, 然后 退出04. 參考示例
4.1 查看默認工作目錄的完整路徑
[deng@localhost ~]$ pwd /home/deng4.2 查看指定文件夾的路徑
[deng@localhost ~]$ cd /usr/src/ [deng@localhost src]$ pwd /usr/src4.3 如果目錄是個符號鏈接,pwd 顯示鏈接(link)路徑;pwd -P 顯示實際路徑。
[deng@localhost ~]$ ls -l /etc/init.d lrwxrwxrwx. 1 root root 11 11月 8 2018 /etc/init.d -> rc.d/init.d [deng@localhost ~]$ cd /etc/init.d [deng@localhost init.d]$ pwd /etc/init.d [deng@localhost init.d]$ pwd -P /etc/rc.d/init.d [deng@localhost init.d]$ pwd -L /etc/init.d [deng@localhost init.d]$4.4 查看上一次的工作目錄與當前的工作目錄
[deng@localhost ~]$ pwd /home/deng [deng@localhost ~]$ echo $OLDPWD /etc/init.d [deng@localhost ~]$ echo $PWD /home/deng [deng@localhost ~]$ cd /etc/init.d/ [deng@localhost init.d]$ pwd /etc/init.d [deng@localhost init.d]$ echo $OLDPWD /home/deng [deng@localhost init.d]$ echo $PWD /etc/init.d [deng@localhost init.d]$4.5 當前目錄被刪除后,pwd 命令仍可顯示該目錄
[deng@localhost ~]$ mkdir dir [deng@localhost ~]$ cd dir [deng@localhost dir]$ pwd /home/deng/dir [deng@localhost dir]$ rm -rf ../dir/ [deng@localhost dir]$ pwd /home/deng/dir [deng@localhost dir]$ /usr/bin/pwd /usr/bin/pwd: 在匹配的inode ".." 上找不到目錄入口 [deng@localhost dir]$4.6 查看pwd命令的類型
[deng@localhost dir]$ type -a pwd pwd 是 shell 內嵌 pwd 是 /usr/bin/pwd [deng@localhost dir]$4.7 查看pwd命令的版本
[deng@localhost dir]$ /usr/bin/pwd --version pwd (GNU coreutils) 8.22 Copyright (C) 2013 Free Software Foundation, Inc. 許可證:GPLv3+:GNU 通用公共許可證第3 版或更新版本<http://gnu.org/licenses/gpl.html>。 本軟件是自由軟件:您可以自由修改和重新發布它。 在法律范圍內沒有其他保證。由Jim Meyering 編寫。 [deng@localhost dir]$4.8 查看pwd命令的幫助信息
[deng@localhost dir]$ /usr/bin/pwd --help 用法:/usr/bin/pwd [選項]... 輸出當前工作目錄的完整名稱。-L, --logical 使用環境變量中的PWD,即使其中包含符號鏈接-P, --physical 避免所有符號鏈接--help 顯示此幫助信息并退出--version 顯示版本信息并退出注意:您的shell 內含自己的pwd 程序版本,它會覆蓋這里所提及的相應 版本。請查閱您的shell 文檔獲知它所支持的選項。GNU coreutils online help: <http://www.gnu.org/software/coreutils/> 請向<http://translationproject.org/team/zh_CN.html> 報告pwd 的翻譯錯誤 要獲取完整文檔,請運行:info coreutils 'pwd invocation' [deng@localhost dir]$或者
[deng@localhost dir]$ help pwd pwd: pwd [-LP]打印當前工作目錄的名字。選項:-L 打印 $PWD 變量的值,如果它命名了當前的工作目錄-P 打印當前的物理路徑,不帶有任何的符號鏈接默認情況下,`pwd' 的行為和帶 `-L' 選項一致退出狀態:除非使用了無效選項或者當前目錄不可讀,否則返回狀態為0。 [deng@localhost dir]$05. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——pwd命令(19)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【计算机类】大学生计算机专业电子书汇总
- 下一篇: 【Linux】一步一步学Linux——c