How To Find Which Package Provides A Command In Linux
Commands in Linux systems are usually provided by software packages installed in the distribution repository. To determine which package provides specific commands , you can use a package management tool specific to Linux distributions. This is useful for installing missing commands or troubleshooting package dependencies.
Table of contents
- Identify packages that have Linux commands in Alpine Linux
- Find package sources for Linux commands in Arch Linux, EndeavourOS, and Manjaro Linux
- Find packages for Linux commands in Debian, Ubuntu and its derivatives
- Find packages for specific commands in Fedora, CentOS, RHEL and its derivatives
- Identify software packages associated with Linux commands in SUSE, openSUSE
- Find packages behind Linux commands in NixOS
- Revealing command source in Gentoo
- in conclusion
Find packages that provide specific commands in Linux
To find which package provides a command on various Linux distributions, you usually use a package management system specific to your distribution (such as Apk, Apt, DNF, Pacman, Zypper, etc.).
Here's how to do this in some of the most common Linux distributions:
1. Identify packages that own Linux commands in Alpine Linux
In Alpine Linux, you can use the apk package manager to find which package provides a specific command.
<code># apk search -e pstree pstree-2.40-r1</code>

This command searches for packages related to the pstree command in the Alpine Linux package repository.
Here is a breakdown of the commands:
- apk is a package management utility for Alpine Linux, similar to apt for Debian-based distributions or yum for Red Hat-based distributions.
- Search is a command to search for packages in a repository.
- -e or --exact is an option that tells apk to search for the exact package name instead of performing a substring search.
- pstree is the name of the package or command you are searching for.
By running apk search -e pstree, Alpine Linux will search its package repository for any package that provides the pstree command or precisely named "pstree".
If the pstree utility is not installed on your Alpine Linux system, this can help you find and install the package that contains the pstree utility.
2. Find the source of packages for Linux commands in Arch Linux, EndeavourOS, and Manjaro Linux
On Arch Linux and its variants such as EndeavourOS and Manjaro Linux, you can use the pacman command with the -F or -Qo flag to search for files (or commands) in a package.
For example, the following command will display the package containing the grep command:
<code>$ pacman -F grep</code>
The command pacman -F grep is used to find packages that provide specific files or commands.
Here are the meanings of different parts of the command:
- pacman: This is the package manager for Arch Linux.
- -F (or --files): This option tells pacman to search for packages containing specific files.
- grep: This is the file or command you are searching for. In this case, it is the grep command.
When you run pacman -F grep, the package manager searches its package database and lists all installed packages containing files or executables named grep.
The output of this command will usually show the package name and the full path to the file matching grep. For example, the output might look like this:
<code>core/grep 3.11-1 usr/bin/grep [...]</code>
This indicates that the grep command is provided by the grep package in the core repository and the executable is located in /usr/bin/grep.
If multiple packages provide files that match grep, all of them will be listed. Conversely, if no package provides a file named grep, the command will return no output.
You can also use the pacman -Qo command to find which package owns or provides a specific file or command.
<code>$ pacman -Qo grep</code>
Here are the meanings of different parts of the command:
- pacman: This is the package manager for Arch Linux.
- -Q: This option tells pacman to query the local package database.
- -o (or --owns): This option specifies that you want to search for packages that have specific files.
- grep: This is the file or command you are searching for. In this case, it is the grep command.
When you run pacman -Qo grep, pacman will search for all installed packages on the system and find packages that contain or provide files or executables named grep.
The output of this command will usually show the package name that has a file that matches grep. For example, the output might look like this:
<code>/usr/bin/grep is owned by grep 3.11-1</code>
This indicates that the grep command (located in /usr/bin/grep) is provided by the grep package.
If multiple packages provide files that match grep, all of them will be listed. If no package has a file named grep, the command will return no output.
This command is useful when you need to find out which package a specific file or command belongs to on the Arch Linux system. It can help you troubleshoot missing files or dependencies, or help selectively reinstall packages that provide specific components.
The main difference between pacman -F grep and pacman -Qo grep is that -F searches the package database to find packages that contain specific files, while -Qo searches for files that are installed on the system and looks for packages that have them.
3. Find Linux command packages in Debian, Ubuntu and its derivatives
On Debian-based systems like Ubuntu, you can use the dpkg command with the -S option to search for packages that install specific files.
However, if the file is not installed, you need to use the apt-file command. First, make sure that apt-file is installed and its database is updated:
<code>$ sudo apt update $ sudo apt install apt-file $ sudo apt-file update</code>
Then, use the following command to search for a package that provides a specific command (such as the pstree command):
<code>$ apt-file search pstree</code>
Sample output:
<code>criu: /usr/lib/python3/dist-packages/pycriu/images/pstree_pb2.py manpages-ja: /usr/share/man/ja/man1/pstree.1.gz<strong></strong></code><mark> psmisc: /usr/bin/pstree</mark> psmisc: /usr/bin/pstree.x11 psmisc: /usr/share/man/de/man1/pstree.1.gz psmisc: /usr/share/man/fr/man1/pstree.1.gz psmisc: /usr/share/man/man1/pstree.1.gz psmisc: /usr/share/man/man1/pstree.x11.1.gz psmisc: /usr/share/man/pt_BR/man1/pstree.1.gz psmisc: /usr/share/man/ru/man1/pstree.1.gz psmisc: /usr/share/man/uk/man1/pstree.1.gz psmisc: /usr/share/pixmaps/pstree16.xpm psmisc: /usr/share/pixmaps/pstree32.xpm python-psutil-doc: /usr/share/doc/python-psutil-doc/examples/pstree.py recap: /usr/lib/recap/core/pstree systemtap-doc: /usr/share/systemtap/examples/process/pstree.meta systemtap-doc: /usr/share/systemtap/examples/process/pstree.stp tomoyo-tools: /usr/sbin/tomoyo-pstree tomoyo-tools: /usr/share/man/man8/tomoyo-pstree.8.gz

As you noticed in the output above, the psmisc package provides the pstree command. This approach allows you to identify the packages you need to install or make sure pstree is available on your system.
Or, if you already have pstree installed and just want to confirm that pstree comes from this package, you can use:
<code>$ dpkg -S pstree</code>
4. Find packages for specific commands in Fedora, CentOS, RHEL and its derivatives
On Fedora and other RPM-based systems such as AlmaLinux, CentOS, RHEL, and Rocky Linux, you can use the dnf command. On older systems, you may need to use yum.
For example, to search for a package that provides files that match pattern*/pstree, you can run:
<code>$ dnf provides */pstree</code>
The following is a breakdown of the functions of the command:
- dnf: This is the DNF package manager command.
- provide: This subcommand tells DNF to search for packages that provide specific files or functions.
- */pstree: This is a glob pattern that matches any file named pstree. * Partial means "any character" before the file name.
When you run this command, DNF will search its package database and list all available packages that contain files named pstree. This file is usually an executable file for the pstree utility, which displays the process tree.
The output of this command will display the package name and version number of the pstree file. For example, the output might look like this:
<code>psmisc-23.6-4.fc39.x86_64 : Utilities for managing processes on your system Repo : fedora Matched from: Provide : /usr/bin/pstree</code>
This indicates that the pstree file (located in /usr/bin/pstree) is mainly provided by the psmisc package (version 23.6-4) from the Fedora repository.
By using the dnf provides command, you can find out which packages you need to install to get specific files or utilities on your system.
5. Identify software packages associated with Linux commands in SUSE, openSUSE
On SUSE and openSUSE, you can use the zypper se --provides command to search for packages that provide a specified file or executable file.
<code>$ zypper se --provides '/usr/bin/grep'</code>
Here is a breakdown of the commands:
- zypper: This is the command line interface of the ZYpp package manager.
- se: This is the abbreviation of the search subcommand, which searches for packages.
- --provides: This option tells zypper to search for packages that provide specific files or functions.
- '/usr/bin/grep': This is the file or executable path you are searching for. In this case, it is the path to the grep command, usually located in /usr/bin/grep.
When you run this command, zypper will search its package database and list all available packages that contain or provide the file /usr/bin/grep.
The output of this command displays the name, version, and repository information of the package that provides the specified file. For example, the output might look like this:
<code>Loading repository data... Reading installed packages... S | Name | Summary | Type -- ------------------------- ------------------------------------------ ------- | grep-3.11-3 | Pattern matching utilities | package [...]</code>
This output indicates that the file /usr/bin/grep is mainly provided by the grep package (version 3.11-3).
6. Find packages behind Linux commands in NixOS
In NixOS Linux, you can use the nix-env utility to find which package provides a specific command.
For example, to find which package provides the pstree command, you can run:
<code>$ nix-env -qaP pstree</code>
This will search for all installed packages and print out the package name and path when a match is found.
Sample output:
<code>nixpkgs.pstree pstree-2.39</code>
Indicates that the pstree command is provided by the pstree-2.39 package.
You can also use the nix search command to find the name of the package that provides a specific command. Although this command is still in the experimental stage, you can use it to search for packages.
The first run may be slow, but subsequent runs will use cached results.
For example, to find a package containing the pstree command, run:
<code>$ nix --extra-experimental-features "nix-command flakes" search nixpkgs pstree</code>
Sample output:
<code>* legacyPackages.x86_64-linux.psmisc (23.6) A set of small useful utilities that use the proc filesystem (such as fuser, killall and pstree) * legacyPackages.x86_64-linux.pstree (2.39) Show the set of running processes as a tree</code>
7. Reveal the source of the command in Gentoo
We can use the Equery tool in the app-portage/gentoolkit package in Gentoo Linux to find which package provides specific commands.
Make sure you have installed app-portage/gentoolkit:
<code># emerge --ask app-portage/gentoolkit</code>
To search for packages that provide specific commands, use the equation with belongs option:
<code>equery belongs /path/to/command</code>
Replace /path/to/command with the full path to the command you are looking for.
If you don't know the path to the command, you can use the whereis command to find it.
<code># whereis pstree</code>
Sample output:
<code># whereis pstree pstree:<strong></strong></code><mark> /usr/bin/pstree</mark> /usr/share/man/man1/pstree.1.bz2
Now let's use the command to find out which package provides the pstree command:
<code># equery belongs /usr/bin/pstree</code>
This outputs the package name and category that provides the grep command, for example:
<code> * Searching for /usr/bin/pstree ... sys-process/psmisc-23.6 (/usr/bin/pstree)</code>
Indicates that the pstree command is provided by the sys-apps/psmisc package.

If you want to search for the command name only without specifying the full path, you can use the hasuse option:
<code># equery hasuse search-term</code>
This will search for packages with a specific USE flag or provide a specific executable file.
in conclusion
Package managers for most major Linux distributions offer built-in options to identify packages that provide specific commands or files. They allow you to search for the package database and find the source package for any given command or file.
This feature often helps troubleshoot missing dependencies, selectively reinstall packages, and ensure that your system has the necessary components installed.
Related Articles: How to Find Packages that Provide Specific Files in Linux
The above is the detailed content of How To Find Which Package Provides A Command In Linux. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undress AI Tool
Undress images for free
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Clothoff.io
AI clothes remover
Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Understanding RAID Configurations on a Linux Server
Aug 05, 2025 am 11:50 AM
RAIDimprovesstorageperformanceandreliabilityonLinuxserversthroughvariousconfigurations;RAID0offersspeedbutnoredundancy;RAID1providesmirroringforcriticaldatawith50�pacityloss;RAID5supportssingle-drivefailuretoleranceusingparityandrequiresatleastthre
Linux how to enable and disable services at boot
Aug 08, 2025 am 10:23 AM
To manage the startup of Linux services, use the systemctl command. 1. Check the service status: systemctlstatus can check whether the service is running, enabled or disabled. 2. Enable the service startup: sudosystemctlenable, such as sudosystemctlenablenginx. If it is started at the same time, use sudosystemctlenable--nownginx. 3. Disable the service startup: sudosystemctldisable, such as sudosystemctldisablecups. If it is stopped at the same time, use sudosystemctldisabl
How to set up a firewall in Linux
Aug 22, 2025 pm 04:41 PM
UsefirewalldoriptablestosecureLinux;firewalldisuser-friendlywithzonesandservices,idealforCentOS/RHEL/Fedora,whileiptablesoffersgranularcontrolforDebian/Ubuntu.Enablefirewalld:sudosystemctlstartfirewalld,allowserviceslikeSSHwith--add-service=ssh,orope
Linux how to list all running processes
Aug 08, 2025 am 06:42 AM
Usepsauxforacompletesnapshotofallrunningprocesses,showingdetailedinformationlikeUSER,PID,CPU,andmemoryusage.2.Usetoporhtopforreal-timemonitoringofprocesseswithdynamicupdates,wherehtopoffersamoreintuitiveinterface.3.UsepgreporpidoftoquicklyfindthePIDs
How to clean up your Linux system
Aug 22, 2025 am 07:42 AM
Removeunusedpackagesanddependencieswithsudoaptautoremove,cleanpackagecacheusingsudoaptcleanorautoclean,andremoveoldkernelsviasudoaptautoremove--purge.2.Clearsystemlogswithsudojournalctl--vacuum-time=7d,deletearchivedlogsin/var/log,andempty/tmpand/var
Linux how to view the contents of a file
Aug 19, 2025 pm 06:44 PM
ToviewfilecontentsinLinux,usedifferentcommandsbasedonyourneeds:1.Forsmallfiles,usecattodisplaytheentirecontentatonce,withcat-ntoshowlinenumbers.2.Forlargefiles,uselesstoscrollpagebypageorlinebyline,searchwith/search_term,andquitwithq.3.Usemoreforbasi
how to create an alias in linux
Aug 19, 2025 pm 08:13 PM
The steps to set up alias in Linux are as follows: 1. Temporarily set the use of the alias command such as aliasll='ls-la'; 2. Permanently set the shell configuration file, such as ~/.bashrc, and then execute the source to take effect; 3. Be careful to avoid overwriting the original command and the different shell configurations are independent. Alias can simplify complex commands and improve efficiency, but only after the current shell environment takes effect and closes the terminal, it needs to be reasonably defined and regularly checked for configuration.
Understanding the Linux Filesystem Hierarchy Standard (FHS)
Aug 06, 2025 pm 04:23 PM
/bin and /sbin store basic commands and system management commands; 2./usr stores user programs and related resources; 3./etc is the configuration file directory; 4./var stores variable data such as logs and caches; 5./home and /root are the home directories of ordinary users and root users; 6./tmp and /run are used for temporary files and runtime data; 7./dev, /proc, /sys provides device and system information interfaces; 8./lib and /lib64 contain library files required for system startup; 9./opt and /srv are used for third-party software and service data respectively; FHS improves system management efficiency through standardized directory structure, making the layout of Linux files clear and consistent, making it easy to maintain and


