国际访客建议访问 Primers 编程伙伴 国际版站点 > Bash 教程 > pwd 以获得更好的体验。

# Bash 的 pwd 命令

pwd [OPTION]...

!subtitle:功能

查看当前工作目录。

!subtitle:类型

Bash 内置命令。

pwd 也是 coreutils 的一个可执行文件;为了保持 POSIX 标准的兼容性,确保在其他 shell(比如一些极简的或古老的 shell)或者某些特定环境下,命令依然可用。

!subtitle:参数

  • OPTION 选项:

    • -L, --logical - 查看逻辑路径(符号链接显示自身路径)

    • -P, --physical - 查看物理路径(符号链接显示源文件路径)

    • --help - 显示帮助

    • --version - 显示版本

# 示例

$ cd /lib
$ pwd
/lib
$ pwd -L
/lib
$ pwd -P
/usr/lib

# 推荐阅读

# 手册

PWD(1)                           User Commands                          PWD(1)

NAME
       pwd - print name of current/working directory

SYNOPSIS
       pwd [OPTION]...

DESCRIPTION
       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

       If no option is specified, -P is assumed.

       NOTE:  your shell may have its own version of pwd, which usually super‐
       sedes the version described here.  Please refer to your  shell's  docu‐
       mentation for details about the options it supports.

AUTHOR
       Written by Jim Meyering.

REPORTING BUGS
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
       Report any translation bugs to <https://translationproject.org/team/>

COPYRIGHT
       Copyright  ©  2023  Free Software Foundation, Inc.  License GPLv3+: GNU
       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This is free software: you are free  to  change  and  redistribute  it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       getcwd(3)

       Full documentation <https://www.gnu.org/software/coreutils/pwd>
       or available locally via: info '(coreutils) pwd invocation'

GNU coreutils 9.4                 April 2024                            PWD(1)
本文 更新于: 2025-11-27 09:38:15 创建于: 2025-11-27 09:38:15