,

How to fix yum after CentOS 6 went EOL

 If for whatever reason, you are stuck with the now EOL version of the CentOS operating system, you can no longer run yum upgrade successfully. Running yum upgrade in CentOS 6 will yield the following results:

Setting up Upgrade Process
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

Rightfully so, as the YUM repository was removed from the main CentOS update servers, no security or feature upgrades are provided.

However, not all the repositories have halted their support for CentOS 6. The GetPageSpeed repository still provides up-to-date NGINX builds and its module packages.

This may be one reason why you want yum upgrade to still work. Or simply, you are not ready to move on with a newer operating system, and willing to take the security risks associated with using the older version.

How to fix yum upgrade then?

Use the CentOS Vault repository

The CentOS Vault repositories have been around for a long time and allow you to stick to a specific CentOS x.y release even while newer ones are available. Now that there will be no newer 6.x, you can simply point your yum repository configuration to the latest 6.x that will ever be, which is 6.10.

To use the Vault repository, set up its repo configuration instead of the now defunct repositories configuration:

curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo

That’s it, everything should be functional.

Alternatively, you can manually replace the contents of the file /etc/yum.repos.d/CentOS-Base.repo with the necessary configuration.

Copy-paste the entire snippet below and hit Enter:

cat <<-'EOF' > /etc/yum.repos.d/CentOS-Base.repo
[C6.10-base]
name=CentOS-6.10 - Base
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never

[C6.10-updates]
name=CentOS-6.10 - Updates
baseurl=http://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never

[C6.10-extras]
name=CentOS-6.10 - Extras
baseurl=http://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never

[C6.10-contrib]
name=CentOS-6.10 - Contrib
baseurl=http://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
metadata_expire=never

[C6.10-centosplus]
name=CentOS-6.10 - CentOSPlus
baseurl=http://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
metadata_expire=never
EOF

Now you can run yum upgrade without problems. This also allows you to get to the latest release 6.10 even if you were left behind at, e.g. 6.7.

Not only yum upgrade works, but you can also install arbitrary packages as usual.

Fixing EPEL repository

curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo

Fixing SCLO repositories

The repositories containing newer compilation software like gcc is available via Software Collections.
However, its repositories are likewise gone. Use Vault repositories instead:

yum -y install centos-release-scl
curl https://www.getpagespeed.com/files/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo
curl https://www.getpagespeed.com/files/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

Continue reading How to fix yum after CentOS 6 went EOL
,

How to use yum command on CentOS/RHEL

 How do I use the yum command to update and patch my Red hat Enterprise Linux / CentOS Linux version 5.x/6.x/7.x server via RHN or the Internet? Can I use up2date command under a RHEL v5.x?


up2date command was part of RHEL v4.x or older version. You need to use yum command to update and patch the system using RHN or Internet. Use yum command to install critical and non-critical security updates as well as binary packages. 


Login as the root user to install and update the system. This page show examples of common sysadmin tasks that you can perform using yum command on a CentOS or RHEL.

How to register my RHEL based system with RHN

To register your RHEL 5.x system with RHN type the following command and just follow on screen instructions (CentOS user skip to the next step):
# rhn_register
To register your RHEL 7.x system with RHN type the folllwong
# subscription-manager register --username tom --password jerry --auto-attach

WARNING! These examples only works with RHEL / CentOS Linux version 5.x or above. For RHEL 4.x and older version use up2date command.

How to display a list of updated software and security fix

Type the following command at shell prompt:
# yum list updates
Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * epel: repo.ugm.ac.id
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
Updated Packages
apr.x86_64                                        1.3.9-5.el6_9.1                               updates
device-mapper.x86_64                              1.02.117-12.el6_9.1                           updates
device-mapper-libs.x86_64                         1.02.117-12.el6_9.1                           updates
kernel-devel.x86_64                               2.6.32-696.16.1.el6                           updates
kernel-headers.x86_64                             2.6.32-696.16.1.el6                           updates
libblkid.x86_64                                   2.17.2-12.28.el6_9.1                          updates
libuuid.x86_64                                    2.17.2-12.28.el6_9.1                          updates
util-linux-ng.x86_64                              2.17.2-12.28.el6_9.1                          updates

How to find out whether updates exist for packages that are already installed on my system

# yum check-update

Patch up system by applying all updates

To download and install all updates type the following command:
# yum update
Sample outputs:

Updates all CentOS 6.x packages including packages on which they depend

Updates all CentOS 6.x packages including packages on which they depend

You can only apply security-related package updates using the following syntax:
$ sudo yum update --security

To update specified packages

Updates the specified package. The syntax is
$ yum update {package-name-1}
To check for and update httpd package, enter:
$ sudo yum update httpd
You can update one packages to a particular version say nginx using the following syntax:
$ ## first find a list of all dups ##
$ yum --showduplicates list nginx
$ ## now update to particular version ##
$ sudo yum update-to nginx-version
$ sudo yum update-to nginx-1.12.2-1.el7

List all installed packages

To list all installed packages, enter:
$ rpm -qa ## not recommend just use yum ##
$ yum list installed

Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * epel: mirror1.ku.ac.th
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
Installed Packages
GeoIP.x86_64                                       1.5.0-11.el7                                @base   
OpenEXR-libs.x86_64                                1.7.1-7.el7                                 @base   
SDL.x86_64                                         1.2.15-14.el7                               @base   
ShellCheck.x86_64                                  0.3.5-1.el7                                 @epel   
acl.x86_64                                         2.2.51-12.el7                               @base   
alsa-lib.x86_64                                    1.1.3-3.el7                                 @base   
apr.x86_64                                         1.4.8-3.el7_4.1                             @updates
apr-util.x86_64                                    1.5.2-6.el7                                 @base   
atk.x86_64                                         2.22.0-3.el7                                @base   
atk-devel.x86_64                                   2.22.0-3.el7                                @base   
atlas.x86_64                                       3.10.1-12.el7                               @base   
audit-libs.x86_64                                  2.7.6-3.el7                                 @base   
autoconf.noarch                                    2.69-11.el7                                 @base   
autogen-libopts.x86_64                             5.18-5.el7                                  @base   
....
..
...
yum-plugin-fastestmirror.noarch                    1.1.31-42.el7                               @base   
zip.x86_64                                         3.0-11.el7                                  @base   
zlib.x86_64                                        1.2.7-17.el7                                @base   
zlib-devel.x86_64                                  1.2.7-17.el7                                @base

Find out if httpd package installed or not on the system

$ rpm -qa | grep httpd*
$ yum list installed httpd

Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: repo.ugm.ac.id
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Installed Packages
httpd.x86_64                               2.4.6-67.el7.centos.6                               @updates

Lists all packages that are available to install all packages that are installed on system

$ yum list
$ yum list
$ yum list | more ## [ Use more command to show info one screen at a time ] ##
$ yum list | grep bash ## [ Use grep command to filter out results ] ##

Lists all packages that are available for installation

$ yum list available
$ yum list available | more
$ yum list available | grep nginx

How to search for packages by name

You can search the package descriptions for the specified string using search command. The list command can be used too. To search httpd and all matching perl packages, enter:
$ yum list {package-name}
$ yum list {regex}
$ yum list httpd
$ yum list perl*
$ yum search {package-name}
$ yum search nginx
$ yum search nginx*

Sample output from yum list perl*:

Loading "installonlyn" plugin
Loading "security" plugin
Setting up repositories
Reading repository metadata in from local files
Installed Packages
perl.i386                                4:5.8.8-10.el5_0.2     installed       
perl-Archive-Tar.noarch                  1.30-1.fc6             installed       
perl-BSD-Resource.i386                   1.28-1.fc6.1           installed       
perl-Compress-Zlib.i386                  1.42-1.fc6             installed       
perl-DBD-MySQL.i386                      3.0007-1.fc6           installed       
perl-DBI.i386                            1.52-1.fc6             installed       
perl-Digest-HMAC.noarch                  1.01-15                installed       
perl-Digest-SHA1.i386                    2.11-1.2.1             installed       
perl-HTML-Parser.i386                    3.55-1.fc6             installed   
.....
.......
..
perl-libxml-perl.noarch                  0.08-1.2.1             base            
perl-suidperl.i386                       4:5.8.8-10.el5_0.2     updates

How to see detailed information about a package

The syntax is:
$ yum info {pkg-1} {pkg-2}
$ yum info htop
$ yum info nginx htop

Sample outputs:

Displays detailed information about a package on a RHEL/CentOS Linux server

Displays detailed information about a package on a RHEL/CentOS Linux server

How to show dependencies list for a package

The syntax is:
$ yum deplist {pkg}
## show for htop pkg
$ yum deplist htop

Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: repo.ugm.ac.id
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
package: htop.x86_64 2.0.2-1.el7
  dependency: libc.so.6(GLIBC_2.15)(64bit)
   provider: glibc.x86_64 2.17-196.el7_4.2
  dependency: libgcc_s.so.1()(64bit)
   provider: libgcc.x86_64 4.8.5-16.el7_4.1
  dependency: libgcc_s.so.1(GCC_3.0)(64bit)
   provider: libgcc.x86_64 4.8.5-16.el7_4.1
  dependency: libgcc_s.so.1(GCC_3.3.1)(64bit)
   provider: libgcc.x86_64 4.8.5-16.el7_4.1
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.17-196.el7_4.2
  dependency: libm.so.6(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-196.el7_4.2
  dependency: libncursesw.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: libtinfo.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-196.el7_4.2
   provider: glibc.i686 2.17-196.el7_4.2

How to install the specified packages [ RPM(s) ]

To install package called httpd:
# yum install {package-name-1} {package-name-2}
# yum install httpd
# yum install nginx mariadb-server php-fpm
# yum install htop

Sample outputs:

Installs the specified package named htop on a CentOS/RHEL

Installs the specified package named htop on a CentOS/RHEL

To install a package from a local file called foo.rpm or http, or ftp mirror:
$ sudo yum localinstall foo.rpm
$ sudo yum https://server1.cyberciti.biz/foo.rpm

It is possible to install particular version too. To find or show duplicates, in repos, in list/search commands
$ yum --showduplicates list php
$ ## now install to particular version ##
$ sudo yum update-to php-version
$ sudo yum update-to php-7.0.2-1.nix

How to downgrade a package to an earlier version

The syntax is:
# yum downgrade {pkg}
# yum downgrade nginx

How to reinstall a package again

The syntax is:
# yum reinstall {pkg}
# yum reinstall httpd

How to remove / uninstall the specified packages [ RPM(s) ]

Remove package called httpd, enter:
# yum remove {package-name-1} {package-name-2}
# yum erase {package-name-1} {package-name-2}
# yum remove httpd
# yum erase htop

How to remove unneeded/unwanted packages/deps

The syntax is:
# yum autoremove
Sample outputs:

Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package tcp_wrappers-libs.x86_64 0:7.6-77.el7 will be erased
--> Finished Dependency Resolution
--> Finding unneeded leftover dependencies
Found and removing 0 unneeded dependencies
 
Dependencies Resolved
 
=======================================================================================================
 Package                        Arch                Version                   Repository          Size
=======================================================================================================
Removing:
 tcp_wrappers-libs              x86_64              7.6-77.el7                @base              131 k
 
Transaction Summary
=======================================================================================================
Remove  1 Package
 
Installed size: 131 k
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : tcp_wrappers-libs-7.6-77.el7.x86_64                                                 1/1 
  Verifying  : tcp_wrappers-libs-7.6-77.el7.x86_64                                                 1/1 
 
Removed:
  tcp_wrappers-libs.x86_64 0:7.6-77.el7                                                                
 
Complete!

Display the list of available packages

$ yum list all

Display list of group software

Type the following command:
$ yum grouplist
OR
$ yum groups list
Output:

Installed Groups:
   Engineering and Scientific
   MySQL Database
   Editors
   System Tools
   Text-based Internet
   Legacy Network Server
   DNS Name Server
   Dialup Networking Support
   FTP Server
   Network Servers
   Legacy Software Development
   Legacy Software Support
   Development Libraries
   Graphics
   Web Server
   Ruby
   Printing Support
   Mail Server
   Server Configuration Tools
   PostgreSQL Database
Available Groups:
   Office/Productivity
   Administration Tools
   Beagle
   Development Tools
   GNOME Software Development
   X Software Development
   Virtualization
   GNOME Desktop Environment
   Authoring and Publishing
   Mono
   Games and Entertainment
   XFCE-4.4
   Tomboy
   Java
   Java Development
   Emacs
   X Window System
   Windows File Server
   KDE Software Development
   KDE (K Desktop Environment)
   Horde
   Sound and Video
   FreeNX and NX
   News Server
   Yum Utilities
   Graphical Internet
Done

Install all the default packages by group

Install all ‘Development Tools’ group packages, enter:
# yum groupinstall "Development Tools"
OR
# yum groups install "Development Tools"

Update all the default packages by group

Update all ‘Development Tools’ group packages, enter:
# yum groupupdate "Development Tools"
OR
# yum groups update "Development Tools"

Remove all packages in a group

Remove all ‘Development Tools’ group packages, enter:
# yum groupremove "Development Tools"
OR
# yum groups remove "Development Tools"

Display description and contents of a package group

$ yum groupinfo 'Development Tools'
OR
$ yum groups info 'Development Tools'
$ yum groups info 'File and Print Server'

Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: del-mirrors.extreme-ix.org
 * epel: ftp.riken.jp
 * extras: del-mirrors.extreme-ix.org
 * updates: del-mirrors.extreme-ix.org
 
Environment Group: File and Print Server
 Environment-Id: file-print-server-environment
 Description: File, print, and storage server for enterprises.
 Mandatory Groups:
   +base
   +core
   +file-server
   +print-server
 Optional Groups:
   +backup-client
   +backup-server
   +debugging
   +directory-client
   +guest-agents
   +ha
   +hardware-monitoring
   +java-platform
   +large-systems
   +network-file-system-client
   +performance
   +remote-system-management
   +resilient-storage

Install particular architecture package

If you are using 64 bit RHEL version it is possible to install 32 packages (please note that 32 bit support is dropped in the latest version of CentOS/RHEL 7.x):
# yum install {package-name}.{architecture}
# yum install mysql.i386

Display packages not installed via official RHN subscribed repos

Show all packages not available via subscribed channels or repositories i.e show packages installed via other repos:
$ yum list extras
Sample output:

Loading "installonlyn" plugin
Loading "security" plugin
Setting up repositories
Reading repository metadata in from local files
Extra Packages
DenyHosts.noarch                         2.6-python2.4          installed       
VMwareTools.i386                         6532-44356             installed       
john.i386                                1.7.0.2-3.el5.rf       installed       
kernel.i686                              2.6.18-8.1.15.el5      installed       
kernel-devel.i686                        2.6.18-8.1.15.el5      installed       
lighttpd.i386                            1.4.18-1.el5.rf        installed       
lighttpd-fastcgi.i386                    1.4.18-1.el5.rf        installed       
psad.i386                                2.1-1                  installed       
rssh.i386                                2.3.2-1.2.el5.rf       installed  

Display what package provides the file

You can easily find out what RPM package provides the file. For example find out what provides the /etc/passwd file:
$ yum whatprovides /etc/passwd
OR
$ yum provides /etc/passwd
Sample output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: repo.ugm.ac.id
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
setup-2.8.71-7.el7.noarch : A set of system configuration and setup files
Repo        : base
Matched from:
Filename    : /etc/passwd



setup-2.8.71-7.el7.noarch : A set of system configuration and setup files
Repo        : @base
Matched from:
Filename    : /etc/passwd

You can use same command to list packages that satisfy dependencies:
$ yum whatprovides {dependency-1} {dependency-2}
$ yum provides string
$ yum provides '*bin/nginx*'

How to clean yum cache

You can delete all cached and downloaded package, headers and other info:
# yum clean all
Sample outputs:

Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

Above command can help to clear problems that can result from out-of-date headers, network errors and more. To check the local RPM database for problems:
# yum check

How to list software repositories

$ yum repolist
Sample outputs:

repo id                          repo name                                                      status
base/7/x86_64                    CentOS-7 - Base                                                 9591
epel/x86_64                      Extra Packages for Enterprise Linux 7 - x86_64                 12155
extras/7/x86_64                  CentOS-7 - Extras                                                327
nginx/x86_64                     nginx repo                                                       313
updates/7/x86_64                 CentOS-7 - Updates                                              1573
repolist: 23959

See information about enabled yum repositories

To get info about nginx repo, run:
$ yum repoinfo nginx
Sample outputs:

Repo-id      : nginx/x86_64
Repo-name    : nginx repo
Repo-status  : enabled
Repo-revision: 1511279401
Repo-updated : Tue Nov 21 15:50:07 2017
Repo-pkgs    : 313
Repo-size    : 143 M
Repo-baseurl : http://nginx.org/packages/mainline/centos/7/x86_64/
Repo-expire  : 21600 second(s) (last: Sat Dec 23 16:49:24 2017)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/nginx.repo
 
repolist: 313

How to work with given repository

The syntax is:
# yum repo-pkgs repo_name_id <list|install|remove|upgrade|reinstall> [pkg]
List all packages from nginx repository:
# yum repo-pkgs nginx list
Get info about nginx package from nginx repository:
# yum repo-pkgs nginx info | more
# yum repo-pkgs nginx info nginx

Install a package named ‘nginx’ from nginx repository:
# yum repo-pkgs nginx install nginx
Install ALL PACKAGES from nginx repository:
# yum repo-pkgs nginx install
Erase/remove/delete a package named ‘nginx’ from nginx repository:
# yum repo-pkgs nginx remove nginx
Erase/remove/delete ALL PACKAGES from nginx repository:
# yum repo-pkgs nginx remove
Upgrade nginx package from nginx repository:
# yum repo-pkgs nginx upgrade nginx
Reinstall nginx package from nginx repository:
# yum repo-pkgs nginx reinstall nginx

How to view and use yum history

The syntax is:
# yum history
# yum history list
# yum info ID
# yum undo ID
# yum redo ID


How to see help about yum command

Refer yum command man page for more information:
$ man yum
$ yum help
$ yum help install
$ yum help erase

Sample outputs:

Loaded plugins: fastestmirror
erase PACKAGE...

Remove a package or packages from your system

alias: remove

Summary of yum command

Command nameDescription/usage
yum check-updateDisplay list of available package updates
yum update
yum update pkg1
Update all packages or update the pkg1 package
yum install pkgInstall a package
yum localinstall pkg.rpmInstall a package from a file named pkg.rpm
yum erase pkgRemove a package
yum remove pkgSame as above
yum autoremoveFree disk space by removing unwanted packages
yum reinstall pkgReinstall a package
yum downgrade pkgDowngrade a package to an older version
yum checkCheck rpm database for errors/problems
yum clean packagesDelete cached packages database
yum clean allDelete out all packages and meta data from disk cache
yum list
yum list installed
yum list php
yum list available
List package names
yum deplist pkg1Show dependencies for a pkg1
yum info pkgShow info about a package
yum search pkg
yum search regex
Search package names
yum provides string
yum whatprovides string
List package that provides the given file or other info
yum history listShow a list of all yum command history action such as install/update/erase
yum history info IDGet info of yum action ID
yum history undo IDUndo the yum command action from ID
yum history redor IDRedot the yum command action from ID
yum grouplistList package groups
yum groupinstall ‘Group Name’Install all packages in the given group name
yum groupinfo ‘Group Name’See packages in the given group name
yum groupremove ‘Group Name’Remove/Delete all packages in the selected group
yum repolistShow a list of all enabled repositories
yum repoinfo repoIDShow info about repoID
yum repo-pkgs repoID listShow packages from repoID repo
yum repo-pkgs repoID installInstall all packages from repoID repo
yum repo-pkgs repoID removeErase all packages from repoID repo
yum repo-pkgs repoID reinstallReinstall all packages from repoID repo
yum help
yum help commandman yum
Show help about yum command or read yum command man page
Continue reading How to use yum command on CentOS/RHEL