linux命令之三pwd命令

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

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

1.命令格式:

pwd [选项]

2.命令功能:

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

3.常用参数:

一般情况下不带任何参数

如果目录是链接时:

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

4.常用实例:

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

命令:

[html]  view plain  copy
  1. pwd   

输出:

[html]  view plain  copy
  1. [root@localhost ~]# pwd  
  2. /root  
  3. [root@localhost ~]#  

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

命令:

[html]  view plain  copy
  1. pwd  

输出:

[html]  view plain  copy
  1. [root@localhost ~]# cd /opt/soft/  
  2. [root@localhost soft]# pwd   
  3. /opt/soft  
  4. [root@localhost soft]#  

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

命令:

[html]  view plain  copy
  1. pwd -P  

输出:

[html]  view plain  copy
  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 输出物理路径

输出:

[html]  view plain  copy
  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]#  

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

 输出:

[html]  view plain  copy
  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: couldn't find directory entry in “..” with matching i-node  
  11. [root@localhost removed]# cd   
  12. [root@localhost ~]# pwd  
  13. /root  
  14. [root@localhost ~]#  


#################################

转自:http://blog.csdn.net/taiyang1987912/article/details/42523265

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值