YUM (Yellowdog Updater Modified) is a popular command in Linux that allows you to install, update, and remove packages in RHEL/Fedora/CentOS Linux distributions. In this article, we will look at the most commonly used Yum command examples for package management. You can keep this list handy for quick reference.
Top Yum Command Examples in Linux
Yum command is a package manager for RPM-based Linux distributions such as RHEL/Fedora/CentOS Linux. It allows you to easily install, update, search, and remove packages in Linux. It automatically connects to third-party libraries to download packages & their dependencies, making it very convenient to use. Here are some commonly used yum commands for you. In each of the following commands below, you don’t have to mention the exact package name. Even if you mention the approximate name, yum will automatically search for the nearest matching package in its repositories, download and install them. In many cases, it will ask you for a confirmation before installing, updating or remove package. In this confirmation, yum will display the exact package names to be installed, updated or removed. This allows users to inspect the exact packages that will be impacted on their system.
1. Install package
If you want to install package using yum just mention it after the yum install command as shown below. Here is an example to install firefox using yum package manager.
# yum install firefox
In most cases, it will prompt you to confirm package installation, or installing its dependencies. To continue installation without prompt, use -y option after yum command but before install keyword.
# yum -y install firefox
2. Removing Package
If you want to remove a package and its dependencies just run yum remove command as shown below.
# yum remove firefox
Again, yum command will ask for confirmation before removing the mentioned package. In this case also, use -y option after yum command but before remove keyword as shown below to remove package without asking for confirmation.
# yum -y remove firefox
3. Update package
If you want to update an installed package on your system, along with its dependencies, use yum update command followed by package name.
# yum update mysql
4. List package
If you want to list package details such as installed package and available version, use list command.
# yum list openssh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: mirror.nus.edu.sg Installed Packages openssh.i386 4.3p2-72.el5_6.3 installed Available Packages 4.3p2-82.el5
In this case, it shows that there is a more recent version of openssh package available. You can use this information to decide whether to update it or not.
5. Search for Package
You can use search command to get a list of all matching packages. Here’s an example.
# yum search vsftpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in ============================== Matched: vsftpd ======================== ccze.i386 : A robust log colorizer pure-ftpd-selinux.i386 : SELinux support for Pure-FTPD vsftpd.i386 : vsftpd - Very Secure Ftp Daemon
While yum list and yum search are both used to search for packages, yum search is more comprehensive than yum list and therefore slower. Yum list only looks for package name for search word while yum search even searches package summaries and descriptions.
6. Get Package Information
If you want to get package information before installing it, use yum info command.
# yum info firefox Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in Available Packages Name : firefox Arch : i386 Version : 10.0.6 Release : 1.el5.centos Size : 20 M Repo : updates Summary : Mozilla Firefox Web browser URL : http://www.mozilla.org/projects/firefox/ License : MPLv1.1 or GPLv2+ or LGPLv2+ Description: Mozilla Firefox is an open-source web browser, designed for standards : compliance, performance and portability.
7. List All Available Packages
Here is the command to list all available packages for your system.
# yum list | less
8. List Installed Packages
Here is the command to list all packages installed on your system via yum command.
# yum list installed | less
9. Check for update
You can also check for system update using yum command.
# yum check-update
10. Update system
Here is the command to update your Linux system using yum command.
# yum update
That’s it. In this article, we have looked at the most common yum command examples that you can use for your requirement.
Also read:
How to Password Protect Folders in Linux
How to Restrict SSH Users to Specific Folders
How to Monitor Log Files in Real Time
Tail Command to Check Logs in Linux
How to Remove Unused Packages in Linux