Find what apt package contains a Linux command with apt-file (Debian 12)
Sometimes you run apt install <package_name>
on a program and you find out that the package does not exist.
This guide explains how to find out which package a Linux command belongs to, using the apt-file
command.
The OS I chose to demonstrate this is Debian 12, but it might work in any Debian derived OS (Ubuntu, Raspbian OS, Linux Mint and so on). I haven't tested it yet.
Installing apt-file
The apt-file
command allows you to search for files in packages that are either installed or available in the repositories.
To use it, first install the apt-file
package:
sudo apt update
sudo apt install apt-file -y
Note: The version of apt-file
I'm using is 3.3
, that can be checked with:
dpkg -l apt-file
Using apt-file
Next, update the apt-file
database:
sudo apt-file update
This is required as the apt-file
command does not use the local package database, but rather a separate database that contains information about all files in all packages.
Searching for a command
To find out which package a command belongs to, use the following command:
apt-file search <command_name>
For example, to find out which package provides the mkfs.exfat
command, you would run:
apt-file search mkfs.exfat
This will return a list of packages that contain the specified command.
exfatprogs: /usr/sbin/mkfs.exfat
exfatprogs: /usr/share/man/man8/mkfs.exfat.8.gz
In this case, the command mkfs.exfat
is provided by the exfatprogs
package.
Listing all files in a package
To list all files contained in a specific package, you can use the following command:
apt-file list <package_name>
For example, to list all files in the exfatprogs
package, you would run:
apt-file list exfatprogs
This will output a list of all files included in the exfatprogs
package, including their paths.
exfatprogs: /usr/sbin/dump.exfat
exfatprogs: /usr/sbin/exfat2img
exfatprogs: /usr/sbin/exfatlabel
exfatprogs: /usr/sbin/fsck.exfat
exfatprogs: /usr/sbin/mkfs.exfat
exfatprogs: /usr/sbin/tune.exfat
exfatprogs: /usr/share/doc/exfatprogs/changelog.Debian.gz
exfatprogs: /usr/share/doc/exfatprogs/changelog.gz
exfatprogs: /usr/share/doc/exfatprogs/copyright
exfatprogs: /usr/share/man/man8/dump.exfat.8.gz
exfatprogs: /usr/share/man/man8/exfat2img.8.gz
exfatprogs: /usr/share/man/man8/exfatlabel.8.gz
exfatprogs: /usr/share/man/man8/fsck.exfat.8.gz
exfatprogs: /usr/share/man/man8/mkfs.exfat.8.gz
exfatprogs: /usr/share/man/man8/tune.exfat.8.gz
Resources
- Debian Wiki: apt-file
- apt-file(1) manual page (Debian Manpages)