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

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

时间:2017-05-08 14:40:47      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:strong   soft   bsp   com   arch   tor   nbsp   cal   pre   

版权声明更新:2017-05-08
博主:LuckyAlan
联系:liuwenvip163@163.com
声明:吃水不忘挖井人,转载请注明出处!

1 文章介绍

本文介绍了Linux下命令cd。

2 开发平台

Linux

3 阅前须知

4 文章正文

pwd(print working directory)用于输出当前工作目录的绝对路径。我们在终端进行操作时,会有一个当前工作目录。 在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置。

4.1 命令

命令格式: pwd [选项] 
命令功能:查看当前工作目录的绝对路径。

4.2 参数

一般情况下不带任何参数,如果目录是链接时可以使用:

1 pwd -P

显示出实际路径,而非使用连接(link)路径。

4.3、常用实例

4.3.1 用 pwd 查看默认工作目录的完成路径

命令: pwd 

输出:

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

4.3.2 使用 pwd 命令查看指定文件夹

命令: pwd 

输出:

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

4.3.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.3.4  /bin/pwd 

命令: /bin/pwd [选项] 

选项:

1 -L 目录连接链接时,输出连接路径
2 -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]#

4.3.5 当前目录被删除了,而pwd命令仍然爱心那好似那个目录

输出:

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]#

4.4 说明

在4.3中,不太清楚什么什么是“目录连接链接”,由于除了4.3.1、4.3.2外,都没遇到过,因此暂时不深究,遇到以后再做学习。

5 参考资料

1、本文概念部分参考了维基百科
2、本文很大程度上是来自《每天一个linux命令(3):pwd命令》。

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

标签:strong   soft   bsp   com   arch   tor   nbsp   cal   pre   

原文地址:http://www.cnblogs.com/luckyalan/p/6824329.html

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