This post will guide you how to find out which package that provides a given file in Ubuntu operating system. How do I find what package a file belongs to in Ubuntu Linux.
Ubuntu Find out Which Package That Provides a File
Assuming that you want to find out which package provides a file named /bin/bash in Ubuntu Linux. How to achieve it. And if you are working on the CentOS/RHEL Linux, you can use the rpm –qf command to check which package provide this file.
In Ubuntu Linux system, you can use the dpkg –S or apt-file command to achieve the result. Just type the following command:
#dpkg –S wget
Outputs:
root@ubuntu-dev:/# dpkg -S wget language-pack-en-base: /usr/share/locale-langpack/en@quot/LC_MESSAGES/wget.mo wget: /usr/share/doc/wget/NEWS.gz wireless-tools: /usr/share/man/man8/iwgetid.8.gz wget: /usr/bin/wget wireless-tools: /usr/share/man/fr.ISO8859-1/man8/iwgetid.8.gz wireless-tools: /usr/share/man/fr.UTF-8/man8/iwgetid.8.gz language-pack-en-base: /usr/share/locale-langpack/en_GB/LC_MESSAGES/wget.mo wget: /usr/share/doc/wget/MAILING-LIST wireless-tools: /usr/share/man/cs/man8/iwgetid.8.gz wireless-tools: /sbin/iwgetid wget: /usr/share/doc/wget/changelog.Debian.gz wget: /usr/share/man/man1/wget.1.gz wget: /usr/share/info/wget.info.gz wget: /usr/share/doc/wget/AUTHORS wget: /usr/share/doc/wget/README language-pack-en-base: /usr/share/locale-langpack/en_AU/LC_MESSAGES/wget.mo wget: /etc/wgetrc wget: /usr/share/doc/wget/copyright language-pack-en-base: /usr/share/locale-langpack/en@boldquot/LC_MESSAGES/wget.mo bash-completion: /usr/share/bash-completion/completions/wget wget: /usr/share/doc/wget vim-runtime: /usr/share/vim/vim74/syntax/wget.vim
Using apt-file to Search package
You need to install apt-file tool with apt command under command line interface.
Type the following command:
#apt-get install apt-file #apt-get update
Outputs:
root@ubuntu-dev:/# apt-get install apt-file Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: curl libconfig-file-perl libcurl3-gnutls libregexp-assemble-perl The following NEW packages will be installed: apt-file curl libconfig-file-perl libregexp-assemble-perl The following packages will be upgraded: libcurl3-gnutls 1 upgraded, 4 newly installed, 0 to remove and 469 not upgraded. Need to get 432 kB of archives. After this operation, 689 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3-gnutls amd64 7.47.0-1ubuntu2.8 [185 kB] Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.8 [139 kB] Get:3 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libconfig-file-perl all 1.50-3 [9,722 B] Get:4 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libregexp-assemble-perl all 0.36-1 [77.5 kB] Get:5 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 apt-file all 2.5.5ubuntu1 [21.6 kB] Fetched 432 kB in 3s (120 kB/s) (Reading database ... 179488 files and directories currently installed.) Preparing to unpack .../libcurl3-gnutls_7.47.0-1ubuntu2.8_amd64.deb ... Unpacking libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.8) over (7.47.0-1ubuntu2.2) ... Selecting previously unselected package curl. Preparing to unpack .../curl_7.47.0-1ubuntu2.8_amd64.deb ... Unpacking curl (7.47.0-1ubuntu2.8) ... Selecting previously unselected package libconfig-file-perl. Preparing to unpack .../libconfig-file-perl_1.50-3_all.deb ... Unpacking libconfig-file-perl (1.50-3) ... Selecting previously unselected package libregexp-assemble-perl. Preparing to unpack .../libregexp-assemble-perl_0.36-1_all.deb ... Unpacking libregexp-assemble-perl (0.36-1) ... Selecting previously unselected package apt-file. Preparing to unpack .../apt-file_2.5.5ubuntu1_all.deb ... Unpacking apt-file (2.5.5ubuntu1) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for man-db (2.7.5-1) ... Setting up libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.8) ... Setting up curl (7.47.0-1ubuntu2.8) ... Setting up libconfig-file-perl (1.50-3) ... Setting up libregexp-assemble-perl (0.36-1) ... Setting up apt-file (2.5.5ubuntu1) ... The system-wide cache is empty. You may want to run 'apt-file update' as root to update the cache. You can also run 'apt-file update' as normal user to use a cache in the user's home directory. Processing triggers for libc-bin (2.23-0ubuntu9) ...
To search in which package that provides a file called wget, type the following command:
#apt-file search wget