Linux命令 - pwd命令
pwd是print working directory的缩写,Linux中用 pwd 命令来查看”当前工作目录“的完整路径。 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录。
1.语法:
pwd [选项]
2.功能:
查看”当前工作目录“的完整路径。可以得知目前所在的工作目录的绝对路径名称。
3.参数:
-L 打印 $PWD 变量的值,如果它包含了当前的工作目录。默认情况下,`pwd' 的行为和带 `-L' 选项一致。
-P 打印当前的物理路径,不带有任何的符号链接
--help 在线帮助。查看该命令功能和可带参数等。
4.常用范例:
例一:查看默认工作目录的完整路径
命令:pwd
[root@localhost ~]# pwd
/root
例二:查看指定文件夹
命令:pwd
[root@localhost ~]# cd /usr/lib
[root@localhost lib]# pwd
/usr/lib
例三:目录连接链接时,显示连接路径
命令: pwd -P
pwd -P 显示出实际路径,而非使用连接(link)路径
[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
例四:当前目录被删除了,而pwd命令仍然显示那个目录
[root@localhost test]# cd /usr/games/
[root@localhost games]# ll
总用量 0
[root@localhost games]# mkdir test
[root@localhost games]# ll
总用量 0
drwxr-xr-x. 2 root root 6 5月 12 17:07 test
[root@localhost games]# cd test/
[root@localhost test]# pwd
/usr/games/test
[root@localhost test]# rm -rf /usr/games/test/
[root@localhost test]# pwd
/usr/games/test
[root@localhost test]# cd /usr/games/
[root@localhost games]# ll
总用量 0