How to find the package to which a file belongs (Ubuntu)?
If you are working in Ubuntu/Debian, you may want to know the package to which a particular file belongs to. Take for example, you want to find out the package to which the command ‘ls’ is found. For this purpose, you must know the complete path of the command which can be found out easily using the command ‘which‘
$ which ls /bin/ls
Now you can use this path to find out the package to which it belongs
$ dpkg -S /bin/ls coreutils: /bin/ls
Thus you can see that ls and the likes (mkdir, rmdir) are all part of the package ‘coreutils‘
You can easily find out the above, using the following commad
$ dpkg -S `which ls` coreutils: /bin/ls
Try some other commands like firefox.
$ dpkg -S `which firefox` firefox-3.5: /usr/bin/firefox
You can even find out the package to which a man page belongs to.
Let’s finf out where is the man page of ls is found. We will make use of whereis command. It helps to find out “locate the binary, source, and manual page files for a command”
$ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1posix.gz /usr/share/man/man1/ls.1.gz
So we have found out that the man page is found here: /usr/share/man/man1/ls.1.gz
Let’s now make use of the dpkg command
$ dpkg -S /usr/share/man/man1/ls.1.gz coreutils: /usr/share/man/man1/ls.1.gz
As you can see it is part of the package ‘coreutils‘
Similarly, you can even find out the contents of a package.
Comments:
me like! Thanks