Usage of YUM Package Manager Explained With Examples



yum is an interactive, rpm based,package manager. It can automatically perform system updates, including dependency analysis and obsolete processing based on "repository" metadata. It can also perform installation of new packages, removal of old packages and perform queries on the installed and/or available packages among many other commands/services. yum is similar to other high level package managers like apt-get and smart.

yum stands for yellowdog update modifier. You can say,its a better version of rpm because it is intelligent enough to take up the required dependencies for any package being installed.

Here are some of the examples that will help you gain more about the usage of yum.

1. To install package/packages:

install is used to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied.

Usage:

Syntax: yum install <package1> <package2>

[root@localhost ~]# yum install httpd

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be an update
--> Processing Dependency: httpd-tools = 2.2.15-29.el6.centos for package: httpd-2.2.15-29.el6.centos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be an update
--> Finished Dependency Resolution


2. To update package/packages:

If run without any packages,update will update every currently installed package.If one or more packages or package globs are specified, Yum will only update the listed packages.While updating packages,yum will ensure that all dependencies are satisfied.

Usage:

Syntax : yum update <package1> <package2>
[root@localhost ~]# yum update httpd

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Update Process


3. To upgrade package/packages:

upgrade is same as the update command with the --obsoletes flag set which means it forces the removal of obsolete packages.The removal of obsolete packages can be risky, as it may remove packages that you use.

Usage:

Syntax: yum upgrade <package1> <package2>
[root@localhost ~]# yum upgrade httpd

Loaded plugins: fastestmirror,refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Upgrade Process


4. To remove package/packages:

remove is used to remove the specified packages from the system as well as remove any packages which depend on the package being removed.remove operates on groups,files,provides and filelists just like the "install" command.

Usage:

Syntax: yum remove <package1> <package2>
[root@localhost ~]# yum remove httpd

Loaded plugins: fastestmirror,refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased
--> Processing Dependency: httpd-mmn = 20051115 for package: mod_perl-2.0.4-10.el6.x86_64
--> Processing Dependency: httpd >= 2.2.0 for package: gnome-user-share-2.28.2-3.el6.x86_64
--> Running transaction check
---> Package gnome-user-share.x86_64 0:2.28.2-3.el6 will be erased
---> Package mod_perl.x86_64 0:2.0.4-10.el6 will be erased
--> Finished Dependency Resolution


Note: "yum" is included in the protected_packages configuration,by default.So you can't accidentally remove yum itself.

5. To list the information about package/packages:

list is used to list various information about packages. There are numerous options that can be used with list like available,updates,installed,extras,obsoletes,recent,all.

Usage:

Syntax: yum list <package1> <package2>
              yum list <option>
[root@localhost ~]# yum list httpd

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Installed Packages
httpd.x86_64 2.2.15-29.el6.centos @base


You need not necessarily mention the name of the package/packages. It will do it for all packages if not specified.

6. To view the info about package/packages:

info is used to list a description and summary information about available packages. It takes the same arguments as that of list.

Usage:

Syntax: yum info <package1> <package2>
              yum info <option>
[root@localhost ~]# yum info httpd

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.2.15
Release : 29.el6.centos
Size : 2.9 M
Repo : installed
From repo : base
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible web server.


7. To search for a package/packages:

This is used to find packages when you know something about the package but aren't sure of it's name. By default search will try searching just package names and summaries, but if that "fails" it will then try descriptions and url.
Yum search orders the results so that those packages matching more terms will appear first.

You can force searching everything by specifying "all" as the first argument.

Syntax: yum search <package1> <package2>
       yum search all

Try both the above commands with same keyword and see the difference.

8. To clean the yum cache:

clean is used to clean up various things which accumulate in the yum cache directory over time. There are various options that can be used with clean like packages,headers,expire-cache,metadata,dbcache,plugins,rpmdb, all. Amont all these, clean all cleans everything. To know more about other options, please refer the man page for yum.

Usage:

Syntax: yum clean <option>
For option all,

[root@localhost ~]# yum clean all

Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: Security-Updates base epel extras spacewalk-client updates
Cleaning up Everything
Cleaning up list of fastest mirrors
You have new mail in /var/spool/mail/root


Note: clean requires an option: headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all

9. To list all the configured repositories:

The default is to list all enabled repositories.

Usage:

[root@localhost ~]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
Security-Updates security-updates 1,154
base base 7,965
epel epel 14,597
extras extras 14
spacewalk-client spacewalk-client 21
updates updates 1,871
repolist: 25,622


If you pass -v,for verbose mode, some additional information is listed.

If the first argument is 'enabled', 'disabled' or 'all' then the command will list those types of repos.

10. Options for the groups:

A group is a combination of several related packages. This saves the time of installing several packages one by one, if the packages belong to the same function.

There are several options that can be applied to packages in the group. I have explained some of them below.

yum grouplist : It is used to list the available groups from all yum repos.

yum groupinstall 'groupname': It is used to install all of the individual packages in a group, of the specified types. This works as if you'd taken each of those package names and put them on the command line for a "yum install" command.

yum groupremove 'groupname': It is used to remove all of the packages in a group, unlike "groupinstall" this will remove everything regardless of group_package_types.

yum groupinfo 'groupname' : It is used to give the description and package list of a group.

yum groupupdate 'groupname': It is used to upgrade the existing group of packages.

11. To list all the dependencies related to a package:

Produces a list of all dependencies and what packages provide those dependencies for the given packages.

Usage:

Syntax: yum deplist

[root@localhost ~]# yum deplist httpd


That's not it. These are just few examples of the usage of yum. There are a lot more things you can do with yum. Please refer to the man page of yum for more options.

Related

technology 6560977430947571161

Post a Comment

emo-but-icon

 

Recent Posts

comments

Join Us

 

Recommended

item