美食网站建设的功能,网站建设优化哪家好,上海公司牌照申请流程,娄底本地做寄生虫网站文章目录 1.命令概述2.命令格式3.常用选项4.相关描述5.参考示例 1.命令概述
pwd#xff08;Print Working Directory#xff09;命令用于显示用户当前工作目录的完整路径。这是一个常用的命令#xff0c;帮助用户确定他们目前所在的目录位置。
2.命令格式
基本的 pwd 命令… 文章目录 1.命令概述2.命令格式3.常用选项4.相关描述5.参考示例 1.命令概述
pwdPrint Working Directory命令用于显示用户当前工作目录的完整路径。这是一个常用的命令帮助用户确定他们目前所在的目录位置。
2.命令格式
基本的 pwd 命令格式非常简单pwd [选项]
3.常用选项
-L逻辑打印出逻辑工作目录的名称即包含符号链接的路径。-P物理显示不包含符号链接的物理路径即实际路径。-help : 显示帮助并退出–version : 输出版本信息并退出
注意在大多数情况下如果不使用任何选项pwd 默认表现类似于 -L 选项。
4.相关描述 pwd 是一个内置命令意味着它内置于大多数现代 shell 中如 bash 和 zsh。这使得 pwd 在几乎所有 Linux 系统和环境中都可用并且执行速度很快。 pwd 的退出状态 0表示成功非零值表示退出失败
5.参考示例
基本用法在终端输入 pwd按回车。显示当前的工作目录。
xjcubuntu:~$ pwd
/home/xjc
xjcubuntu:~$ ^C查看指定文件夹的路径
xjcubuntu:/usr/local$ cd /usr/local
xjcubuntu:/usr/local$ pwd
/usr/local
xjcubuntu:/usr/local$打印 pwd 的版本 注意 ‘pwd’ 通常不带选项运行且没有任何参数
重要 注意刚才运行的是 “/bin/pwd” 而不是 “pwd”。
这有什么区别呢直接使用“pwd”意味着使用 shell 内置的 pwd。shell 可能有不同版本的 pwd。当使用的是/bin/pwd 时调用的是二进制版本的命令。虽然二进制的版本有更多的选项但是它们两者都能打印当前的目录。
查看 pwd 命令的帮助信息
xjcubuntu:/usr/local$ /bin/pwd --help
Usage: /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 exitIf no option is specified, -P is assumed.NOTE: your shell may have its own version of pwd, which usually supersedes
the version described here. Please refer to your shells documentation
for details about the options it supports.GNU coreutils online help: http://www.gnu.org/software/coreutils/
Full documentation at: http://www.gnu.org/software/coreutils/pwd
or available locally via: info (coreutils) pwd invocation打印所有含有可执行 pwd 的路径
xjcubuntu:/usr/local$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
xjcubuntu:/usr/local$存储“pwd”命令的值到变量中比如说a 并从中打印变量的值, 常用于观察 shell 脚本
xjcubuntu:/usr/local$ a$(pwd)
xjcubuntu:/usr/local$ echo $a
/usr/local
xjcubuntu:/usr/local$使用 -P 选项如果你的当前工作目录是一个符号链接使用 pwd -P 将显示该链接指向的实际目录。
首先创建一个新目录比如叫 real_dir然后在另一个地方创建一个指向 real_dir 的符号链接 link_dir。
xjcubuntu:~$ mkdir /tmp/real_dir
xjcubuntu:~$ ln -s /tmp/real_dir /tmp/link_dir
xjcubuntu:~$接下来切换当前工作目录到这个符号链接 link_dir。
xjcubuntu:~$ cd /tmp/link_dir使用 pwd 命令查看当前路径
xjcubuntu:/tmp/link_dir$ pwd
/tmp/link_dir
xjcubuntu:/tmp/link_dir$现在使用 pwd -P 命令来获取实际路径而不是符号链接的路径。
xjcubuntu:/tmp/link_dir$ pwd -P
/tmp/real_dir
xjcubuntu:/tmp/link_dir$这里输出 的是 /tmp/real_dir即使当前在符号链接目录 link_dir 中。
使用 -L 选项如果你的当前工作目录是通过符号链接进入的使用 pwd -L 将显示符号链接的路径。 这里输出 的是 /tmp/link_dir说明**pwd -L**** **显示的是符号链接的路径。