How to find which package provides a command in yum

- by

CentOS-LogoSometimes you know you need a package, but when you try to install it with yum you’ll get a message like “No matches found”. Yet you’re sure the package exists because you’ve used it before.

This can happen if the package in question is part of a set which installs multiple packages. The net-tools package springs to mind.

yum has a great option called whatprovides with which you can query what package you need to install to use a command. Let’s try it out!

Say I wanted to install mkfs.vfat which is not installed by default in CentOS. Simply trying to install it won’t work:

yum install mkfs.vfat

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * extras: centos.mirrors.tds.net
 * updates: centos.mirrors.tds.net
No package mkfs.vfat available.
Error: Nothing to do

Of course it won’t. But I can ask yum what provides this package:

yum whatprovides mkfs.vfat

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * extras: ftp.usf.edu
 * updates: centos.mirrors.tds.net
dosfstools-3.0.20-9.el7.x86_64 : Utilities for making and checking MS-DOS FAT
                               : filesystems on Linux
Repo        : base
Matched from:
Filename    : /usr/sbin/mkfs.vfat



dosfstools-3.0.20-9.el7.x86_64 : Utilities for making and checking MS-DOS FAT
                               : filesystems on Linux
Repo        : @base
Matched from:
Filename    : /usr/sbin/mkfs.vfat

Well fantastic! The package I’m looking for is called dosfstools. Knowing that, I can simply use yum install dosfstools, and a few moments later mkfs.vfat will work as expected.

Thanks, yum!

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.