The ls /bin
command shows many files. I need to get a detailed list. But the ls -l /bin
command shows only 1 file.
Tell me, please, what is wrong?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityNothing is wrong.
/bin
is a symlink that points to /usr/bin
.
When you use the ls /bin
command, the symlink is followed, and you're shown the contents of /usr/bin
(where the symlink points).
However, with the ls -l /bin
command, the symlink is not followed, and only the symlink itself is shown.
The reason may be found under the --dereference-command-line-symlink-to-dir
option in the ls texinfo documentation (info ls
or info coreutils 'ls invocation'
):
‘--dereference-command-line-symlink-to-dir’
Do not dereference symbolic links, with one exception: if a command
line argument specifies a symbolic link that refers to a directory,
show information for that directory rather than for the link
itself. This is the default behavior when no other
dereferencing-related option has been specified (‘--classify’
(‘-F’), ‘--directory’ (‘-d’), (‘-l’), ‘--dereference’ (‘-L’), or
‘--dereference-command-line’ (‘-H’)).
In this context, -l
is an "other dereferencing-related option" and turns the behavior off.
If you use ls -lH /bin
, you tell the command to specifically follow symlinks, and now you (properly) see the contents of /usr/bin
.
/bin
being a symlink to /usr/bin
follows the UsrMerge package, which was introduced in Debian 10 in 2019, and thus adopted by the following versions of Ubuntu.
$ ls -l $(echo $PATH | tr ':' '\n')
will show you "all" your executables, and also where they or the /bin dirs are linked to, if that is the case.