Linux中用 pwd
命令来查看”当前工作目录“的完整路径。简单得说,每当我们在终端进行操作时,都会有一个当前工作目录。
在不太确定当前位置时,就会使用pwd
来显示当前目录在文件系统内的确切位置。
pwd [选项]
查看”当前工作目录“的完整路径
一般情况下不带任何参数,但如果目录是链接时:
格式:pwd -P
显示出实际路径,而非使用连接(link)路径。
pwd
执行和输出:
zyiz@ubuntu:~$ pwd /home/zyiz zyiz@ubuntu:~$
pwd
执行和输出:
zyiz@ubuntu:~$ cd /usr/local/src/ zyiz@ubuntu:/usr/local/src$ pwd /usr/local/src zyiz@ubuntu:/usr/local/src$
目录连接链接时,pwd -P
显示出实际路径,而非使用连接(link)路径;pwd显示的是连接路径。
pwd -P
执行和输出:
[root@localhost ~]# 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]#
/bin/pwd [选项]
选项:
-L
目录连接链接时,输出连接路径-P
输出物理路径执行和输出:
zyiz@ubuntu:/etc/init.d$ /bin/pwd /etc/init.d zyiz@ubuntu:/etc/init.d$ /bin/pwd --help Usage: /bin/pwd [OPTION]... Print the full filename of the current working directory. -L, --logical use PWD from environment, even if it contains symlinks -P, --physical avoid all symlinks --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. Report pwd bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> For complete documentation, run: info coreutils 'pwd invocation' zyiz@ubuntu:/etc/init.d$ /bin/pwd -P /etc/init.d zyiz@ubuntu:/etc/init.d$ /bin/pwd -L /etc/init.d zyiz@ubuntu:/etc/init.d$
执行和输出:
zyiz@ubuntu:/etc/init.d$ cd /usr/local/src/ zyiz@ubuntu:/usr/local/src$ mkdir beremoved zyiz@ubuntu:/usr/local/src$ cd beremoved/ zyiz@ubuntu:/usr/local/src/beremoved$ pwd /usr/local/src/beremoved zyiz@ubuntu:/usr/local/src/beremoved$ rm ../beremoved/ -rf zyiz@ubuntu:/usr/local/src/beremoved$ pwd /usr/local/src/beremoved zyiz@ubuntu:/usr/local/src/beremoved$ /bin/pwd /bin/pwd: couldn't find directory entry in �..� with matching i-node zyiz@ubuntu:/usr/local/src/beremoved$ cd zyiz@ubuntu:~$ pwd /home/zyiz zyiz@ubuntu:~$