30 YUM Command Examples for Linux

Linux

Yellowdog Updater, Modified (yum) is an open source package-management utility in Redhat based operating system. Yum takes care of automatic installation of dependent packages during package installation, removal, and updates.

Yum uses Redhat Package Manager (RPM) and can install software packages from yum repositories (collections of RPM packages), which can be accessed locally or over a network connection.

READHow to create Local/Network YUM repository on CentOS 7 / RHEL 7

Here, we will take a look at YUM commands examples for managing packages on Linux (CentOS RHEL / Fedora)

1. Install a Package with YUM

To install a RPM package, you can use the following command. You can mention multiple package names separated by a space.

Adding a -y flag to the yum command will install/remove/reinstall packages without any futher confirmation.

2. Remove a Package with YUM

To remove any package, run the following command. You can mention multiple package names separated by a space.

3. Update a Package with YUM

To update any package to the latest version, run the following command. You can mention multiple package names separated by a space.

4. Downgrade a Package with YUM

To downgrade a package using yum command, run the following command. This command will revert the package to the previous version.

It will work only if the repository has a previous version of the mentioned package.

Ex: Let us downgrade the sudo package which was just updated in our previous example.

5. Reinstall a Package with YUM

You can reinstall an RPM using the following command to resolve installation issues.

6. List a package with YUM

Do you know the package name? Then use the below command to know whether the package is already installed or available for your system.

The output will have the repository name from which the package was installed. In case it is not already installed, the output will have the name of the repository from which we can install the package.

Installed Package:

Available Package:

7. List all installed packages with YUM

Sometimes you may want to get a list of packages installed on your system. Use the below command.

8. List all available packages with YUM

You can use the below yum command to get a list of all available packages for your system.

9. Find / Search a Package with YUM

Did you forget the package name? You can use below command to search for a package. The command will simply list packages that contain given phrase.

10. Find which package provides a file with YUM

This command will help you find a package that provides a file. For example: let us find which package provides the date command.

11. Get an information about a Package with YUM

To know more about a particular package, use the following command.

12. Download packages with YUM

In some cases, like repository creation, you will need to download rpm packages without installing using YUM command. Below command will download FTP server package to /tmp directory.

Verify whether the package has been downloaded or not.

13. Check updates with YUM

Want to know what are all packages need an update for keeping your system safe then use the below command.

14. Update system with YUM

To update all installed packages in a single go or upgrade the system to the new release of the operating system, you can use the below command.

15. Exclude a Package from update with YUM

Sometimes, you want to prevent a package(s) from being updated. For that, you can use below command. You can mention multiple packages separated by a comma.

16. Get history details with YUM

Until this step, you might have executed the yum command for many times. Below command will let you view historical data of successful yum command executions which have actions like install, erase, and update.

ID is unique for each yum transaction and which will be useful in next few examples.

17. Check information yum history

To know what happened during the particular yum command execution, you can use yum history info command.

For example: let us see changes happened during yum execution (ID 9).

18. Revert packages with yum history

This command enables you to revert the changes happened for a particular yum command execution.

For example: In the previous step, you can see that the package called epel-release was installed during ID 9. Let us revert (remove package) that whole installation with yum.

19. Undo revert with yum history

This command will undo the revert (install the removed package – step 19) happened for a particular yum command execution.

20. List YUM repositories with YUM

Want to get a list of repositories configured on your machine. Use the below command. The command will list only the enabled repositories.

21. List all YUM repositories with YUM

Using yum with all option can give you the list of all repositories configured on your system including the disabled repositories.

22. List disabled repositories with YUM

You can use yum with a disabled option to list only the disabled yum repositories on your system.

23. Enable repository with YUM

You can also enable a particular repository for the time being to install rpm package.

For example: To install any package from the epel-testing repository which is in disabled state (see 13th step output), the command might look like below.

24. Enable repositories with YUM

Sometimes, multiple repositories have the same package. To avoid duplicates, you can use below command to enable particular repository by disabling all other repositories.

Use yum list or yum search command to know on which repository the package is available.

25. List package groups with YUM

Below command will list you the available groups and environments for your system.

26. Install group of packages with YUM

Installing packages in a group will configure a system to a particular state. For example: if you install “Server with GUI” group then your system will have a grahical interface (desktop).

27. Generate Meta cache with YUM

Download and make usable all the metadata, like packages, for the currently enabled yum repositories. This command will help you faster the transcation of package installation.

28. Clear caches with YUM

YUM creates caches in /var/cache/yum/ directory, and this needs to be cleared if you get any errors or make some disk space.

29. YUM shell

YUM has its own interactive shell prompt where you can do all tasks shown in previous steps. Below example shows you how to install a package with YUM shell.

30. Get help with YUM

You can get more information about YUM using the below commands.

Source

Share: