前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >Linux 命令(151)—— pwd 命令

Linux 命令(151)—— pwd 命令

作者头像
恋喵大鲤鱼
发布2022-10-25 19:34:22
发布2022-10-25 19:34:22
1.1K00
代码可运行
举报
文章被收录于专栏:C/C++基础C/C++基础
运行总次数:0
代码可运行

文章目录

1.命令简介

pwd(print working directory)打印当前工作目录的绝对路径。

2.命令格式

代码语言:javascript
代码运行次数:0
复制
pwd [<OPTION>]...

3.选项说明

代码语言:javascript
代码运行次数:0
复制
-L, --logical
	使用环境变量 PWD,即使它包含符号链接。为默认选项。
-P, --physical
	显示当前工作目录的实际物理地址。
--help
	显示帮助信息然后退出。
--version
	显示版本信息,然后退出。

4.常用示例

(1)查看当前工作目录的完整路径。

代码语言:javascript
代码运行次数:0
复制
# pwd
/root/go

(2)如果目录是个符号链接,显示实际路径。

代码语言:javascript
代码运行次数:0
复制
# ls -l /etc/init.d
lrwxrwxrwx 1 root root 11 Jan 19  2021 /etc/init.d -> rc.d/init.d

# cd /etc/init.d && pwd -P
/etc/rc.d/init.d

(3)查看 pwd 命令的帮助信息。

代码语言:javascript
代码运行次数:0
复制
# /usr/bin/pwd --help
Usage: /usr/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.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'pwd invocation'

或者:

代码语言:javascript
代码运行次数:0
复制
# help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.
    
    Options:
      -L	print the value of $PWD if it names the current working
    	directory
      -P	print the physical directory, without any symbolic links
    
    By default, `pwd' behaves as if `-L' were specified.
    
    Exit Status:
    Returns 0 unless an invalid option is given or the current directory
    cannot be read.

参考文献

pwd(1) - Linux manual page - man7.org

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-10-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 1.命令简介
  • 2.命令格式
  • 3.选项说明
  • 4.常用示例
  • 参考文献
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档