为什么“ls -l /bin”命令只显示 1 个文件?

Tet*_*ana 10 files ls 20.04

ls /bin命令显示许多文件。我需要得到一份详细的清单。但该ls -l /bin命令仅显示 1 个文件。

请告诉我,出了什么问题?

Art*_*ild 22

没有什么是错的。

\n

/bin是一个指向 的符号链接/usr/bin

\n

当您使用该ls /bin命令时,将跟随符号链接,并向您显示/usr/bin(符号链接指向的位置)的内容。

\n

但是,使用该ls -l /bin命令时,不会遵循符号链接,而仅显示符号链接本身。

\n

原因可以在--dereference-command-line-symlink-to-dirls texinfo 文档(info lsinfo coreutils \'ls invocation\')的选项下找到:

\n
\xe2\x80\x98--dereference-command-line-symlink-to-dir\xe2\x80\x99\n     Do not dereference symbolic links, with one exception: if a command\n     line argument specifies a symbolic link that refers to a directory,\n     show information for that directory rather than for the link\n     itself.  This is the default behavior when no other\n     dereferencing-related option has been specified (\xe2\x80\x98--classify\xe2\x80\x99\n     (\xe2\x80\x98-F\xe2\x80\x99), \xe2\x80\x98--directory\xe2\x80\x99 (\xe2\x80\x98-d\xe2\x80\x99), (\xe2\x80\x98-l\xe2\x80\x99), \xe2\x80\x98--dereference\xe2\x80\x99 (\xe2\x80\x98-L\xe2\x80\x99), or\n     \xe2\x80\x98--dereference-command-line\xe2\x80\x99 (\xe2\x80\x98-H\xe2\x80\x99)).
Run Code Online (Sandbox Code Playgroud)\n

在这种情况下,-l“其他与取消引用相关的选项”并关闭该行为。

\n

如果您使用ls -lH /bin,则告诉命令专门遵循符号链接,现在您(正确地)看到 的内容/usr/bin

\n

/bin作为UsrMerge/usr/bin软件包的符号链接,该软件包于 2019 年在 Debian 10 中引入,并被以下版本的 Ubuntu 采用。

\n

  • 强制取消引用的另一种方法是使用“ls -l /bin/” (3认同)