zoukankan      html  css  js  c++  java
  • 每天一个linux命令(4):pwd命令

    版权声明更新: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命令》。

  • 相关阅读:
    WebService-CXF 学习笔记
    Java中对于ClassLoader类加载器 嵌套了深度技术的价值
    WebService学习笔记
    MongoDB学习笔记
    java.io.IOException: java.io.FileNotFoundException: /tmp/tomcat.2457258178644046891.8080/work/Tomcat/localhost/innovate-admin/C:/up/154884318438733213952/sys-error.log (没有那个文件或目录)
    Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime
    Mysql优化
    SI架构设计与实践
    高并发高可用处理大数据量
    虚拟机安装CentOS详细操作
  • 原文地址:https://www.cnblogs.com/luckyalan/p/6824329.html
Copyright © 2011-2022 走看看