As in the title. Neither dpkg -S /usr/bin/less nor apt-file search /usr/bin/less produces anything useful.

Does it mean that there's a bug or that less really doesn't come from any package?

(In case you're wondering why I need to know the answer, I find that the less is an old version 487 instead of 530 that has a feature I want.)

$ which less
$ dpkg -S /usr/bin/less
dpkg-query: no path found matching pattern /usr/bin/less
$ apt-file search /usr/bin/less
colorized-logs: /usr/bin/lesstty
libcss-lessp-perl: /usr/bin/lessp
node-less: /usr/bin/lessc

That's because /usr/bin/less is a symbolic link:

$ ls -l /usr/bin/less
lrwxrwxrwx 1 root root 9 Jul 21  2017 /usr/bin/less -> /bin/less

The latter is provided by package less

$ dpkg -S $(realpath $(which less))
less: /bin/less

The symbolic link is one of several created by the postinst script during package configuration:

case "$1" in
        for file in lessfile lesspipe lesskey lessecho less; do
          if [ ! -e /usr/bin/$file ]; then
            ln -s /bin/$file /usr/bin/$file

(The same script installs less as the default pager under update-alternatives.)

  • Thanks. Does any package own the symlink? If so, why do the tools not care about the symlinks? If not how does Ubuntu know to remove the symlink? Is it just that the tools are limited in this sense? Perhaps Ubuntu knows to add/remove the symlinks as a post -installation/-uninstallation actions? – Syncopated Jul 3 at 2:33
  • @Syncopated I have updated the answer with some information about the symlink – steeldriver Jul 3 at 11:52
  • The dpkg database only shows you files that are managed directly by dpkg, it doesn't show you files that are managed by the maintainer scripts :( – Peter Green Jul 3 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.