每天一个linux命令(3):pwd命令

1.命令格式:

pwd [选项]

2.命令功能:

查看”当前工作目录“的完整路径

3.常用参数:

一般情况下不带任何参数

如果目录是链接时:

格式:pwd -P  显示出实际路径,而非使用连接(link)路径。

 

用 pwd 命令查看默认工作目录的完整路径
[root@localhost ~]# pwd
使用 pwd 命令查看指定文件夹
[root@localhost soft]# pwd 
/opt/soft
目录连接链接时,pwd -P  显示出实际路径,而非使用连接(link)路径;pwd显示的是连接路径
[root@localhost init.d]# pwd
/etc/init.d
[root@localhost init.d]# pwd -P
/etc/rc.d/init.d
/bin/pwd [选项]
选项:
-L 目录连接链接时,输出连接路径
-P 输出物理路径
[root@localhost init.d]# /bin/pwd 
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd -P
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd -L
/etc/init.d
当前目录被删除了,而pwd命令仍然显示那个目录
[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

 

 

 

posted @ 2026-01-09 10:06  蘑菇味的花魂  阅读(1)  评论(0)    收藏  举报