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!

The main difference between Linux and Windows in process management lies in the implementation and concept of tools and APIs. Linux is known for its flexibility and power, relying on kernel and command line tools; while Windows is known for its user-friendliness and integration, mainly managing processes through graphical interfaces and system services.

Linuxisidealforcustomization,development,andservermanagement,whileWindowsexcelsineaseofuse,softwarecompatibility,andgaming.Linuxoffershighconfigurabilityfordevelopersandserversetups,whereasWindowsprovidesauser-friendlyinterfaceandbroadsoftwaresupport

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools
