Yum Command on Linux (Installing and Upgrading Packages)
Linux distributions based on Red Hat use the package manager called Red Hat Package Manager — RPM to install your software. The most famous distributions include Red Hat’s own Linux Enterprise, Fedora, and CentOS.
RPM is a powerful package manager that allows the administrator to install, remove, and obtain package information. It is a software distribution method widely used in several Linux distributions, in addition to Red Hat.
It also makes it possible to build packages from source files, verify the digital signature, simulate an installation, among others. It’s as powerful as dpkg and apt-get.
Due to the difficulty of dealing with package management using the rpm command, Red Hat-based Linux distributions use the yum utility.
Yum is an acronym for Yellow Dog Updater, Modified. It is a tool used to manage the installation and removal of packages in Linux distributions that use the RPM system.
Yum is a file package manager similar to APT-GET that automatically handles dependencies by computing them and resolving what must be done to treat them.
It has a configuration file that specifies which repositories YUM should use to search for and download RPM packages.
RPM-based Linux won’t always have the YUM package manager installed. If you need to install YUM, it can be obtained at http://yum.baseurl.org.
The installation command is:
# rpm -ivh yum.rpm
Some yum commands:
- yum list: List all available packages;
- yum check-update or yum list updates: Check if there are packages available for an update;
- yum update: Update your system;
- yum install ;: Installs a specific package and its dependencies;
- yum remove: Removes a specific package
- yum info: Presents basic information for a given package.
- yum whatprovides file: List all packages that have the file indicated in the search
See the examples:
To install a package:
# yum install postgresql
Resolving DependenciesInstall 2 Package (s)Is this ok [Y/n]: y
Package (s) data still to download: 3.0 M(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm | 2.8 MB 00:11(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00----------------------------------------------------------Total 241 Kb/s | 3.0 MB 00:12
Running TransactionInstalling: postgresql-libs-9.0.4-5.fc15.x86_64 1/2Installing: postgresql-9.0.4-5.fc15.x86_64 2/2
One option in Yum is the “-y” that installs or updates packages without asking. It’s not very suitable for production.
To update installed packages:
# yum updatePlugins loaded: priorities, update-motd, upgrade-helperamzn-main/latest
Resolving dependencies---> Performing transaction verification---> The aws-cli.noarch package 0:1 .7.5-1.2.amzn1 will be updated---> The aws-cli.noarch package 0:1 .7.12-1.3.amzn1 will be an update---> Dependency resolution finished
Dependencies resolved=======================================================================Package Arq. Repo Tam version.=======================================================================Installing:kernel x86_64 3.14.34-27.48.amzn1 amzn-updates 16 M
Updating:aws-cli noarch 1.7.12-1.3.amzn1 amzn-updates 604 mTransaction summary======================================================================= Install 1 Package (+4 Dependent packages)Upgrade 1 Package
Total download size: 16 MBIs this ok [Y/D/n]:
To remove a package:
# yum remove Postgresql
To search for all packages with the word “firefox”:
# yum search Firefox <br></br>Loaded plugins: langpacks, soon, refresh-packagekit============== N/S Matched: firefox ==========================firefox.x86_64: Mozilla Firefox Web browsergnome-do-plugins-firefox.x86_64: gnome-do-plugins for Firefoxmozilla-firetray-firefox.x86_64: System tray extension for firefoxmozilla-adblockplus.noarch: Adblocking extension for Mozilla Firefoxmozilla-noscript.noarch: JavaScript list extension for Mozilla Firefox
Name and summary matches only, use “search all” for everything.
To obtain information about a particular package:
# yum info MySQLPlugins loaded: priorities, update-motd, upgrade-helperNewRelic & nbsp; ; 59/59Installed packages
Name: mysqlArchitecture: noarchVersion: 5.5Release: 1.6.amzn1Size: 0.0Repo: installedFrom the repository: amzn-mainSummary: MySQL meta packageWebbadress: http://www.mysql.comLicense: GPLv2 with exceptionsDescription: MySQL is a multi-user, multi-threaded SQL database server. MySQL is a: client/server implementation consisting of a server daemon (mysqld): and many different client programs and libraries. The Base Package: contains the standard MySQL client programs and generic MySQL files.
To view all the packages available in the yum repository:
# yum listInstalled packagesGeoIP.x86_64 1.4.8-1.5.amzn1 @amzn -mainGeoIP-Devel.x86_64 1.4.8-1.5.amzn1 @amzn -mainPyyaml.x86_64 3.10-3.6.amzn1 installedacl.x86_64 2.2.49-6.9.amzn1 installedacpid.x86_64 1.0.10-2.1.6.amzn1 installedalsa-lib.x86_64 1.0.22-3.9.amzn1 installedapr.x86_64 1.5.0-2.11.amzn1 @amzn -updates(...)
To find out which package a particular file belongs to:
# yum provides /etc/sysconfig/nfsPlugins loaded: priorities, update-motd, upgrade-helper1:nfs-utils-1.2.3-39.15.amzn1.x86_64: NFS utilities and supporting clients and daemons for the kernel NFS server
Repo: aman-mainResult starting from:File name: /etc/sysconfig/nfs
To find out which repositories are active in YUM:
# Yum Repolistrepo id repo status nameamzn-main/latest AMZN-Main-Base 5.019amzn-updates/latest AMZN-updates-Base 1.085newrelic/x86_64 New Relic packages 59
Like apt, YUM also caches packages downloaded in the /var/cache/yum directory.
Generally, after the successful installation of the packages, yum automatically cleans the cache directory. This depends on the /etc/yum.conf configuration file, especially the keepcache option.
In any case, you can empty the cache with the command:
# yum clean all
Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.