码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2015-12-08 08:42:52      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

  转自:http://www.cnblogs.com/peida/archive/2012/10/24/2737730.html

 

 

  Linux中用pwd命令来查看“当前工作目录”的完整路径。简单地说,每当你在终端进行操作时,你都会有一个当前工作目录。

   在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置。

  1.命令格式:

    pwd []

  2.命令功能:

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

  3.常用参数:

    一般情况下不带任何参数。

    如果目录是链接时:

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

  4.常用实例:

    实例1:用pwd命令查看默认工作目录的完整路径

    命令:pwd

    输出:

1 [root@localhost ~]# pwd
2 /root
3 [root@localhost ~]#

    实例2:使用pwd命令查看指定文件夹

    命令:pwd

    输出:

1 [root@localhost ~]# cd /opt/soft/
2 [root@localhost soft]# pwd 
3 /opt/soft
4 [root@localhost soft]#

    实例3:目录连接链接时,pwd -P显示出实际路径,而非使用连接(link)路径;pwd显示的是连接路径

    命令:pwd -P

    输出:

1 [root@localhost soft]# cd /etc/init.d 
2 [root@localhost init.d]# pwd
3 /etc/init.d
4 [root@localhost init.d]# pwd -P
5 /etc/rc.d/init.d
6 [root@localhost init.d]#

    实例4:/bin/pwd

    命令:/bin/pwd [选项]

      选项:-L目录连接链接时,输出连接路径

           -P输出物理路径

    输出:

1 [root@localhost init.d]# /bin/pwd 
2 /etc/rc.d/init.d
3 [root@localhost init.d]# /bin/pwd --help
4 [root@localhost init.d]# /bin/pwd -P
5 /etc/rc.d/init.d
6 [root@localhost init.d]# /bin/pwd -L
7 /etc/init.d
8 [root@localhost init.d]#

    实例5:当前目录被删除了,而pwd命令仍然显示那个目录

    输出:

 1 [root@localhost init.d]# cd /opt/soft
 2 [root@localhost soft]# mkdir removed
 3 [root@localhost soft]# cd removed/
 4 [root@localhost removed]# pwd
 5 /opt/soft/removed
 6 [root@localhost removed]# rm ../removed -rf
 7 [root@localhost removed]# pwd
 8 /opt/soft/removed
 9 [root@localhost removed]# /bin/pwd
10 /bin/pwd: couldnt find directory entry in “..” with matching i-node
11 [root@localhost removed]# cd 
12 [root@localhost ~]# pwd
13 /root
14 [root@localhost ~]#

 

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

标签:

原文地址:http://www.cnblogs.com/shiguangzhe2013/p/5028064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!