YUM Command To Manage Packages on RHEL/CentOS
As per my experience in Linux administration i can assure, we can’t
manage RHEL /CentOS /Fedora /Scientific Linux systems without YUM
Command. It is mandatory to perform so many actions. Yum (Yellowdog
Updater Modified) is one of the package manager utility in Linux
operating system. Yum command is used to install, update, search &
remove packages on some Linux distributions based on RedHat. Some other
package manger utilities which are being used widely in Linux are
apt-get, dpkg, rpm, Zypper, pacman, etc.,
Now, I’m going to play on my CentOS 6.6 server to explain and cover mostly used yum commands with examples. Reference link
The above output shows matching string for ftpd
Now, I’m going to play on my CentOS 6.6 server to explain and cover mostly used yum commands with examples. Reference link
1) Common syntax/file location for yum
See below for common syntax/ file location of yum.# Common syntax for yum # root@2daygeek [~]# yum [options] [commands] [package name] # most popular yum commands # root@2daygeek [~]# [install remove update search info check-update clean repolist list history # yum Repository file location # root@2daygeek [~]# /etc/yum.repos.d # yum cached file location # root@2daygeek [~]# /var/cache/yum
2) Install a Package or packages
Use the below command to install any package or packages on your system. In this case i’m going to install apache, MariaDB-server, MariaDB-client. Every time yum ask your confirmation to install the corresponding package. if you want to avoid the confirmation you can do by this adding -y option with yum.# Install a single package # root@2daygeek [~]# yum install httpd or root@2daygeek [~]# yum -y install httpd # Install more than one packages # root@2daygeek [~]# yum install MariaDB-server MariaDB-client or root@2daygeek [~]# yum -y install MariaDB-server MariaDB-client
3) Remove a Package or packages
Use the below command to remove/erase any package or packages on your system. In this case I’m going to remove apache, MariaDB-server, MariaDB-client.# Remove a single package # root@2daygeek [~]# yum remove httpd or root@2daygeek [~]# yum erase httpd # Remove more than one packages # root@2daygeek [~]# yum remove MariaDB-server MariaDB-client or root@2daygeek [~]# yum erase MariaDB-server MariaDB-client
4) update a Package or packages
Use the below command to update any package or packages on your system. In this case I’m going to update apache, MariaDB-server, MariaDB-client to latest version.# update single package # root@2daygeek [~]# yum update httpd # update more than one packages # root@2daygeek [~]# yum update MariaDB-server MariaDB-client
5) list all repository packages
Use the below command to list all packages which are available in all repository. I have enabled EPEL & REMI so in this case it shows all the repository packages. Both gives same results.root@2daygeek [~]# yum list or root@2daygeek [~]# yum list all
6) Check updates
Use the below command to check available package updates on your system. In this case kernel update is available. Both gives same results.root@2daygeek [~]# yum list updates or root@2daygeek [~]# yum check-update Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net kernel.x86_64 2.6.32-504.3.3.el6 updates
7) list installed packages
Use the below command to print installed packages on your Linux system.root@2daygeek [~]# yum list installed
8) Search a package
If you don’t know the exact package name which you want to install, Use the search option it will return the matching string. In this case I’m going to search ftpdroot@2daygeek [~]# yum search ftpd Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net ============================================================== N/S Matched: ftpd =============================================================== nordugrid-arc-gridftpd.x86_64 : ARC gridftp server pure-ftpd.x86_64 : Lightweight, fast and secure FTP server vsftpd.x86_64 : Very Secure Ftp Daemon Name and summary matches only, use "search all" for everything.
The above output shows matching string for ftpd
9) Check package information
If you want to know the package detailed information before proceeding with the installation. Use the below command, it will give full information about the package like package version, size, repo name, etc..root@2daygeek [~]# yum info vsftpd Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: mirrors.coreix.net * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net Available Packages Name : vsftpd Arch : x86_64 Version : 2.2.2 Release : 13.el6_6.1 Size : 151 k Repo : updates Summary : Very Secure Ftp Daemon URL : http://vsftpd.beasts.org/ License : GPLv2 with exceptions Description : vsftpd is a Very Secure FTP daemon. It was written completely from : scratch.
10) How to Check package is installed or not
Use the below command to check whether the package is installed or not on your system. In this case I’m going to check openssh package.root@2daygeek [~]# yum list installed openssh Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net Installed Packages openssh.x86_645.3p1-104.el6_6.1 @updates
11) yum provides / whatprovides function
This command searches which packages provide the requested dependency of file.root@2daygeek [~]# yum provides /etc/passwd or Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files Repo : base Matched from: Filename : /etc/passwd setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files Repo : installed Matched from: Other : Provides-match: /etc/passwd
12) Purpose of makecache
Makecache is used to download and make usable all the metadata for the currently enabled repository on your system.root@2daygeek [~]# yum makecache
13) Print yum repositories
Use the below command to print the list of repositories available on your system.# To print enabled repository # root@2daygeek [~]# yum repolist Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net repo id repo name status base CentOS-6 - Base 6,456+62 epel Extra Packages for Enterprise Linux 6 - x86_64 10,483+671 extras CentOS-6 - Extras 36 isv_ownCloud_community Latest stable community release of ownCloud (CentOS_CentOS-6) 2+1 rpmforge RHEL 6 - RPMforge.net - dag 4,677+41 updates CentOS-6 - Updates 496+34 repolist: 22,150 # To print Disabled repository # root@2daygeek [~]# yum repositories disabled # To print all repository # root@2daygeek [~]# yum repolist all
14) Do full system update
Use the below command to keep your system up to date. It will install all the available updates.root@2daygeek [~]# yum update
15) list available group packages
Use the below command to list available group of packages on your system. In these groups no of packages are bundled together with a single name. So you can install the group of packages with single shot instead of installing each and every software separately.root@2daygeek [~]# yum grouplist
16) Install the group packages
To install group of packages use groupinstall instead of install with yum command. In this case i’m going to install “Development tools”. Its bundled with libtool, gcc, c++, automake, pkgconfig, autoconf, etc.,root@2daygeek [~]# yum groupinstall 'Development tools'
16) update the group packages
Use the below command to update the group of packages to latest version.root@2daygeek [~]# yum groupupdate 'Development tools'
17) Remove the group packages
Use the below command to update the group of packages to latest version.root@2daygeek [~]# yum groupremove 'Development tools' or root@2daygeek [~]# yum grouperase 'Development tools'
18) Install a package from particular Repository
Use the below command to Install a package from particular Repository. In this case I’m going to install Htop package from rpmforge repository.root@2daygeek [~]# yum --enablerepo=rpmforge install htop
19) Cleaning yum cache
Whenever you are installing packages yum creates a cache of metadata and packages. This cache can take up a lot space. The yum clean command allows you to clean up these files. All the files yum clean will act on are normally stored in /var/cache/yum.# cleans up any cached packages # root@2daygeek [~]# yum clean packages # cleans up any cached xml metadata # root@2daygeek [~]# yum clean metadata # cleans up any cached db packages # root@2daygeek [~]# yum clean dbcache # Clean all cached files # root@2daygeek [~]# yum clean all
20) checking Recently Added Packages into Repository
Use the below command to check Recently Added Packages into Repository.root@2daygeek [~]# yum list recent
21) Print yum history
Use the below command to Print yum history.root@2daygeek [~]# yum history
22) yum man page
Use the below command for More info about yum command.root@2daygeek [~]# yum -help or root@2daygeek [~]# man yum or root@2daygeek [~]# yum --h
Comments
Post a Comment