Wise people learn when they can; fools learn when they must - Arthur Wellesley

Wednesday, 3 May 2017

RHEL6 – 32 -YUM


RHEL6 – 32 -YUM


As we had seen earlier in last post that how to install RPM packages. YUM is also a way to do same. If both have same purpose then what is need of yum?

YUM is preferable way to install RPM packages, because its capability to resolve dependency.

YUM is the primary tool for getting, installing, deleting, querying, and managing Red Hat Enterprise Linux RPM software packages from official Red Hat software repositories, as well as other third-party repositories. YUM is used in Red Hat Enterprise Linux versions 5 and later.


YUM stands for Yellow dog Updater, Modified because it is based on YUP, the Yellow dog Updater. Yellow Dog is a version of Linux for the Power Architecture hardware. YUP, and later YUM, were written by the Linux community as a way to maintain an RPM-based system.

Before using YUM, we need to create YUM Repository.
Procedure to create YUM REPO is in following link,


How to list all installed & available packages via yum?

[root@rhel6-test1 ~]# yum list all

How to list only installed packages with yum?

[root@rhel6-test1 ~]# yum list installed |wc -l
902

How to list particular installed/not installed package via yum?
How to check particular package is installed or not?

[root@rhel6-test1 ~]# yum list vsftpd
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Installed Packages ççç
vsftpd.x86_64                       2.2.2-11.el6                               installed ççç


[root@rhel6-test1 ~]# yum list finger
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Available Packages ççç
finger.x86_64                       0.17-39.el6                        localrepo ççç

How to get the package install path via yum?

For this we need a yum utility called “yum-utils”
Let’s check it is installed or not.

[root@rhel6-test1 ~]# yum list yum-utils
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Installed Packages
yum-utils.noarch           1.1.30-14.el6    @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4

Package is installed, if not then we can do

[root@rhel6-test1 ~]# yum install yum-utils

Now we can query our packages via,

[root@rhel6-test1 ~]# repoquery -l vsftpd

How to install packages via yum?

[root@rhel6-test1 ~]# yum install samba
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localrepo                                                                                                      | 2.9 kB     00:00 ...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:3.6.9-151.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                     Arch                         Version                               Repository                       Size
======================================================================================================================================
Installing:
 samba                       x86_64                       3.6.9-151.el6                         localrepo                       5.0 M

Transaction Summary
======================================================================================================================================
Install       1 Package(s)

Total download size: 5.0 M
Installed size: 18 M
Is this ok [y/N]: y ççç

If we are sure to install then can use (-y),

[root@rhel6-test1 ~]# yum install -y samba
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:3.6.9-151.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                     Arch                         Version                               Repository                       Size
===============================================================================================================
Installing:
 samba                       x86_64                       3.6.9-151.el6                         localrepo                       5.0 M

Transaction Summary
===============================================================================================================
Install       1 Package(s)

Total download size: 5.0 M
Installed size: 18 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : samba-3.6.9-151.el6.x86_64                                                                                         1/1
  Verifying  : samba-3.6.9-151.el6.x86_64                                                                                         1/1

Installed:
  samba.x86_64 0:3.6.9-151.el6

Complete!

How to uninstall a package via yum?

[root@rhel6-test1 ~]# yum remove samba
[root@rhel6-test1 ~]# yum erase samba

How to update a package via yum?

[root@rhel6-test1 ~]# yum update samba
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Update Process
No Packages marked for Update

**To update a package obviously we need updated version than installed.

How to check whether any update is available or not for installed packages from all configured yum repositories via yum?

[root@rhel6-test1 ~]# yum check-update
[root@rhel6-test1 ~]# yum list updates

YUM CHANGELOG:

Well, if the packages are updated. Then how do we know that what changes are done by “yum update” or to see the latest changes to an rpm package

yum-changelog is a Yum plugin for viewing package changelogs before/after updating.

[root@rhel6-test1 ~]# yum list installed |grep -i changelog
Nothing in o/p, means it is not installed. Verify again

[root@rhel6-test1 ~]# yum list all |grep -i changelog
eclipse-changelog.x86_64                1:2.7.0-1.el6                 localrepo
yum-plugin-changelog.noarch             1.1.30-14.el6                 localrepo

Install it,

[root@rhel6-test1 ~]# yum install yum-changelog -y
[root@rhel6-test1 ~]# yum list installed |grep -i changelog
Loaded plugins: changelog, product-id, refresh-packagekit, security,
yum-plugin-changelog.noarch          1.1.30-14.el6                     @localrepo

How to view all changes done to a particular package via yum?

[root@rhel6-test1 ~]# yum changelog all vsftpd
Loaded plugins: changelog, product-id, refresh-packagekit, security,
              : subscription-manager
This system is not registered to Red Hat Subscription Management. You can use su                                                      bscription-manager to register.

Listing all changelogs

==================== Installed Packages ====================
vsftpd-2.2.2-11.el6.x86_64               installed
* Fri Mar  2 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-11
- Resolves: #785084 - improved: vsftpd can not handle square brackets in ls

* Mon Feb 13 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-10
- Resolves: #745133 - corrected doc for 'max_per_ip' and 'max_clients' default s                                                      etting

* Thu Feb  2 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-9
- Resolves: #785084 - vsftpd can not handle square brackets in ls
- Resolves: #785061 - vsftpd child terminates when listing files with UID/GID la                                                      rger than signed in
- Resolves: #717411 - Connection failures during upload using PORT not handled c                                                      leanly
- Resolves: #752954 - Disabling Reverse DNS lookups in VSFTPd
- Resolves: #745133 - vsftpd: documentation for 'max_per_ip' default setting is                                                       wrong
=======================O/P REMOVED=================================

How to see the latest 5 changes to particular package via yum?

[root@rhel6-test1 ~]# yum changelog 5 vsftpd
Loaded plugins: changelog, product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Listing 5 changelogs

==================== Installed Packages ====================
vsftpd-2.2.2-11.el6.x86_64               installed
* Fri Mar  2 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-11
- Resolves: #785084 - improved: vsftpd can not handle square brackets in ls

* Mon Feb 13 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-10
- Resolves: #745133 - corrected doc for 'max_per_ip' and 'max_clients' default setting

* Thu Feb  2 17:30:00 2012 Jiri Skala <jskala@rehat.com> - 2.2.2-9
- Resolves: #785084 - vsftpd can not handle square brackets in ls
- Resolves: #785061 - vsftpd child terminates when listing files with UID/GID larger than signed in
- Resolves: #717411 - Connection failures during upload using PORT not handled cleanly
- Resolves: #752954 - Disabling Reverse DNS lookups in VSFTPd
- Resolves: #745133 - vsftpd: documentation for 'max_per_ip' default setting is wrong
- Resolves: #765757 - SITE HELP offers CHMOD even when it is disabled/unavailable
- Resolves: #701300 - vsftpd.conf lists incorrect default value for xferlog_file
- Resolvse: #785642 - Invalid error recovery in vsf_privop_pasv_listen()

* Mon Dec 12 17:30:00 2011 Jiri Skala <jskala@rehat.com> - 2.2.2-8
- Resolves: #708657 - Update to rhel 6.1 broke vsftpd authentication when using ldap

* Thu Mar  3 17:30:00 2011 Jiri Skala <jskala@rehat.com> - 2.2.2-7
- Resolves: #681892 - CVE-2011-0762 vsftpd: remote DoS via crafted glob patter

changelog stats. 1 pkg, 1 source pkg, 5 changelogs

How to download a package from yum repo to local system via yum?

[root@rhel6-test1 ~]# yumdownloader vsftpd
Loaded plugins: product-id, refresh-packagekit
vsftpd-2.2.2-11.el6.x86_64.rpm                           | 151 kB     00:00

[root@rhel6-test1 ~]# ls -ltr vsftpd-2.2.2-11.el6.x86_64.rpm
-r--r--r--. 1 root root 154392 Apr 12 11:52 vsftpd-2.2.2-11.el6.x86_64.rpm

[root@rhel6-test1 ~]# yumdownloader finger
Loaded plugins: product-id, refresh-packagekit
finger-0.17-39.el6.x86_64.rpm                                 |  22 kB     00:00

How to install a package locally/without yum-repo via yum?

[root@rhel6-test1 ~]# yum localinstall finger-0.17-39.el6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Local Package Process
Examining finger-0.17-39.el6.x86_64.rpm: finger-0.17-39.el6.x86_64
Marking finger-0.17-39.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package finger.x86_64 0:0.17-39.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                  Arch                     Version                         Repository                                    Size
===============================================================================================================
Installing:
 finger                   x86_64                   0.17-39.el6                     /finger-0.17-39.el6.x86_64                    27 k

Transaction Summary
===============================================================================================================
Install       1 Package(s)

Total size: 27 k
Installed size: 27 k
Is this ok [y/N]:

How to get the installed package information via yum?

[root@rhel6-test1 ~]# yum info samba
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Installed Packages
Name        : samba
Arch        : x86_64
Version     : 3.6.9
Release     : 151.el6
Size        : 18 M
Repo        : installed ççç
From repo   : localrepo
Summary     : Server and Client software to interoperate with Windows machines
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description :
            : Samba is the suite of programs by which a lot of PC-related
            : machines share files, printers, and other information (such as
            : lists of available files and printers). The Windows NT, OS/2, and
            : Linux operating systems support this natively, and add-on packages
            : can enable the same thing for DOS, Windows, VMS, UNIX of all
            : kinds, MVS, and more. This package provides an SMB/CIFS server
            : that can be used to provide network services to SMB/CIFS clients.
            : Samba uses NetBIOS over TCP/IP (NetBT) protocols and does NOT
            : need the NetBEUI (Microsoft Raw NetBIOS frame) protocol.

How to get the package information before installation via yum?

[root@rhel6-test1 ~]# yum info finger
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Available Packages
Name        : finger
Arch        : x86_64
Version     : 0.17
Release     : 39.el6
Size        : 22 k
Repo        : localrepo ççç
Summary     : The finger client
License     : BSD
Description : Finger is a utility which allows users to see information about
            : system users (login name, home directory, name, how long they've
            : been logged in to the system, etc.).  The finger package includes
            : a standard finger client.
            :
            : You should install finger if you'd like to retrieve finger
            : information from other systems.

How to search package via yum?

Well, good to have search option. But why?

I know that “ssh” is installed in system, not because of yum because I connected via ssh. Let’s search this package.

[root@rhel6-test1 ~]# yum list ssh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: No matching Packages to list
[root@rhel6-test1 ~]# yum list sshd
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: No matching Packages to list

No result, why?
Because I forget the name of package.

Here “search” option will help.

[root@rhel6-test1 ~]# yum list ssh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: No matching Packages to list ççç

[root@rhel6-test1 ~]# yum list sshd
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: No matching Packages to list ççç

[root@rhel6-test1 ~]# yum search ssh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
=============================== N/S Matched: ssh ===============================
ksshaskpass.x86_64 : A KDE version of ssh-askpass with KWallet support
libssh2.i686 : A library implementing the SSH2 protocol
libssh2.x86_64 : A library implementing the SSH2 protocol
openssh.x86_64 : An open source implementation of SSH protocol versions 1 and 2
openssh-askpass.x86_64 : A passphrase dialog for OpenSSH and X
openssh-clients.x86_64 : An open source SSH client applications
openssh-server.x86_64 : An open source SSH server daemon
trilead-ssh2.noarch : SSH-2 protocol implementation in pure Java
jsch.noarch : Pure Java implementation of SSH2
python-paramiko.noarch : A SSH2 protocol library for python
python-twisted-conch.x86_64 : SSH and SFTP protocol implementation together with
                            : clients and servers

  Name and summary matches only, use "search all" for everything.

Now I can get the correct package name. It’s “openssh” not “ssh”.

How to know the package name from file name via yum?

Why it is required? Let’s say I have two files (/etc/ssh/sshd_config & /etc/vsftpd/vsftpd.conf) and I want to know the name of package which generated those files, then I can use following.

[root@rhel6-test1 ~]# yum provides /etc/ssh/sshd_config
OR
[root@rhel6-test1 ~]# yum whatprovides /etc/ssh/sshd_config

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
openssh-server-5.3p1-84.1.el6.x86_64 : An open source SSH server daemon ççç
Repo        : localrepo
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-5.3p1-84.1.el6.x86_64 : An open source SSH server daemon
Repo        : installed
Matched from:
Other       : Provides-match: /etc/ssh/sshd_config

[root@rhel6-test1 ~]# yum provides /etc/vsftpd/vsftpd.conf
OR
[root@rhel6-test1 ~]# yum whatprovides /etc/vsftpd/vsftpd.conf

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
vsftpd-2.2.2-11.el6.x86_64 : Very Secure Ftp Daemon ççç
Repo        : localrepo
Matched from:
Filename    : /etc/vsftpd/vsftpd.conf

vsftpd-2.2.2-11.el6.x86_64 : Very Secure Ftp Daemon
Repo        : installed
Matched from:
Other       : Provides-match: /etc/vsftpd/vsftpd.conf

We can use above command in vice versa manner also,

[root@rhel6-test1 ~]# yum provides "ssh"
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Warning: 3.0.x versions of yum would erroneously match against filenames.
 You can use "*/ssh" and/or "*bin/ssh" to get that behaviour
No Matches found

[root@rhel6-test1 ~]# yum provides "*/ssh"
OR
[root@rhel6-test1 ~]# yum whatprovides "*/ssh"

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
pam_ldap-185-11.el6.i686 : PAM module for LDAP
Repo        : localrepo
Matched from:
Filename    : /usr/share/doc/pam_ldap-185/pam.d/ssh

python-twisted-conch-8.2.0-3.2.el6.x86_64 : SSH and SFTP protocol implementation together with clients and servers
Repo        : localrepo
Matched from:
Filename    : /usr/lib64/python2.6/site-packages/twisted/conch/ssh

pam_ldap-185-11.el6.x86_64 : PAM module for LDAP
Repo        : localrepo
Matched from:
Filename    : /usr/share/doc/pam_ldap-185/pam.d/ssh

openssh-5.3p1-84.1.el6.x86_64 : An open source implementation of SSH protocol versions 1 and 2
Repo        : localrepo
Matched from:
Filename    : /etc/ssh

openssh-clients-5.3p1-84.1.el6.x86_64 : An open source SSH client applications
Repo        : localrepo
Matched from:
Filename    : /usr/bin/ssh

openssh-clients-5.3p1-84.1.el6.x86_64 : An open source SSH client applications
Repo        : installed
Matched from:
Filename    : /usr/bin/ssh

How to list the available yum repositories?

[root@rhel6-test1 ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                           repo name                     status
localrepo                                         localrepo                     3,720
repolist: 3,720

How to list all enabled/disabled yum repositories?

[root@rhel6-test1 ~]# yum repolist all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                 repo name                                                    status
InstallMedia                            Red Hat Enterprise Linux 6.4                                 disabled
localrepo                               localrepo                                                    enabled: 3,720
rhel-source                             Red Hat Enterprise Linux 6Server - x86_64 - Source           disabled
rhel-source-beta                        Red Hat Enterprise Linux 6Server Beta - x86_64 - Source      disabled
repolist: 3,720

How to reinstall a package via yum?

[root@rhel6-test1 ~]# yum reinstall samba

How to view yum history?

[root@rhel6-test1 ~]# yum history
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     4 | root <root>              | 2017-05-02 18:00 | Install        |    1
     3 | root <root>              | 2017-05-02 18:00 | Erase          |    1
     2 | root <root>              | 2017-05-01 18:48 | Install        |    1  <
     1 | System <unset>           | 2016-08-30 03:40 | Install        |  886 >
history list

[root@rhel6-test1 ~]# yum history info 4
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Transaction ID : 4
Begin time     : Tue May  2 18:00:45 2017
Begin rpmdb    : 891:e7af27ebc1dbb9d30649f389100ac30fedaaea23
End time       :            18:00:48 2017 (3 seconds)
End rpmdb      : 892:179a357b6f7493c6e180caa759cda42f4adddbaf
User           : root <root>
Return-Code    : Success
Command Line   : install finger -y
Transaction performed with:
    Installed     rpm-4.8.0-32.el6.x86_64                  @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
    Installed     subscription-manager-1.1.23-1.el6.x86_64 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
    Installed     yum-3.2.29-40.el6.noarch                 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
Packages Altered:
    Install finger-0.17-39.el6.x86_64 @localrepo
history info

[root@rhel6-test1 ~]# yum history info 3
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Transaction ID : 3
Begin time     : Tue May  2 18:00:31 2017
Begin rpmdb    : 892:eb1d215fd514850e3455326e586455e5b4e2f409
End time       :            18:00:36 2017 (5 seconds)
End rpmdb      : 891:e7af27ebc1dbb9d30649f389100ac30fedaaea23
User           : root <root>
Return-Code    : Success
Command Line   : erase samba
Transaction performed with:
    Installed     rpm-4.8.0-32.el6.x86_64                  @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
    Installed     subscription-manager-1.1.23-1.el6.x86_64 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
    Installed     yum-3.2.29-40.el6.noarch                 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
Packages Altered:
    Erase samba-3.6.9-151.el6.x86_64 @localrepo
history info

How to undo a change via yum?

[root@rhel6-test1 ~]# yum history undo 3
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Undoing transaction 3, from Tue May  2 18:00:31 2017
    Erase samba-3.6.9-151.el6.x86_64 @localrepo
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:3.6.9-151.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                     Arch                         Version                               Repository                       Size
======================================================================================================================================
Installing:
 samba                       x86_64                       3.6.9-151.el6                         localrepo                       5.0 M

Transaction Summary
======================================================================================================================================
Install       1 Package(s)

Total download size: 5.0 M
Installed size: 18 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : samba-3.6.9-151.el6.x86_64                                                                                         1/1
  Verifying  : samba-3.6.9-151.el6.x86_64                                                                                         1/1

Installed:
  samba.x86_64 0:3.6.9-151.el6

Complete!

How to redo a change via yum?

[root@rhel6-test1 ~]# yum history redo 3
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repeating transaction 3, from Tue May  2 18:00:31 2017
    Erase samba-3.6.9-151.el6.x86_64 @localrepo
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:3.6.9-151.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                     Arch                         Version                              Repository                        Size
===============================================================================================================================
Removing:
 samba                       x86_64                       3.6.9-151.el6                        @localrepo                        18 M

Transaction Summary
===============================================================================================================================
Remove        1 Package(s)

Installed size: 18 M
Is this ok [y/N]:

How to get the help for yum?

[root@rhel6-test1 ~]# yum help

How to know the dependency list for a package via yum?

[root@rhel6-test1 ~]# yum deplist openssh
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localrepo                                                       | 2.9 kB     00:00 ...
localrepo/primary_db                                            | 3.1 MB     00:00 ...
Finding dependencies:
package: openssh.x86_64 5.3p1-84.1.el6
  dependency: initscripts >= 5.20
   provider: initscripts.x86_64 9.03.38-1.el6
  dependency: libc.so.6(GLIBC_2.8)(64bit)
   provider: glibc.x86_64 2.12-1.107.el6
  dependency: libnss3.so(NSS_3.2)(64bit)
   provider: nss.x86_64 3.14.0.0-12.el6
=========================O/P REMOVED=================================

What is yum cache?

By default, yum deletes downloaded data files when they are no longer needed after a successful operation. This minimizes the amount of storage space that yum uses.
We can enable yum caching, so the yum will keep the packages even after installation that can be used elsewhere also.

Where the temporary files created by yum are stored?

/var/cache/yum

More precisely,

/var/cache/yum/$basearch/$releasever/

$basearch is Yum variable referring to base architecture of the system
$releasever is Yum variable referring to the release version of RHEL

FROM RHEL-6
[root@rhel6-test1 ~]# ls -l /var/cache/yum/x86_64/6Server/
total 12
drwxr-xr-x. 3 root root 4096 Apr 10 17:50 client
drwxr-xr-x. 4 root root 4096 Apr 10 17:50 InstallMedia
drwxr-xr-x. 3 root root 4096 May  2 18:36 localrepo

FROM RHEL-7
[root@rhel7-client ~]# ls -l /var/cache/yum/x86_64/7Server/
total 8
drwxr-xr-x. 4 root root   31 Nov 22 19:07 InstallMedia
drwxr-xr-x. 4 root root 4096 May  2 18:53 localrepo
-rw-r--r--. 1 root root   43 Jan 21 04:10 timedhosts

Well, there are no packages stored.

Let the cache enable.

[root@rhel6-test1 ~]# vi /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1 çç changed to 1 from 0

[root@rhel6-test1 ~]# yum makecache
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localrepo                                                                                                      | 2.9 kB     00:00 ...
localrepo/other_db                                                                                             | 1.6 MB     00:00 ...
Metadata Cache Created

“makecache” Is used to download and make usable all the metadata for the currently enabled yum repositories.

How to clean yum cache?

Whenever a package is installed, yum extracts the rpm package on the system and then installs the package and creates a cache of metadata and packages. But after installing package the extracted files are stores there only which may unnecessarily uses our disk space. This cache can take up a lot space. The yum clean command allows us to clean these files. All the files yum clean will act on are normally stored in /var/cache/yum.

[root@rhel6-test1 ~]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: localrepo
Cleaning up Everything

** By default, yum deletes downloaded data files when they are no longer needed after a successful operation.

How to reset the file permissions?

Why it is required,

[root@rhel6-test1 samba]# repoquery -l samba
Chosen 3 files & 1 dir from output,

/etc/pam.d/samba
/etc/samba/smbusers
/usr/bin/smbstatus
/usr/lib64/samba/auth

[root@rhel6-test1 ~]# ls -ltr /etc/pam.d/samba /etc/samba/smbusers /usr/bin/smbstatus
-rw-r--r--. 1 root root      97 Dec 17  2012 /etc/samba/smbusers
-rw-r--r--. 1 root root     177 Dec 17  2012 /etc/pam.d/samba
-rwxr-xr-x. 1 root root 1675672 Dec 17  2012 /usr/bin/smbstatus

[root@rhel6-test1 ~]# ls -ld /usr/lib64/samba/auth
drwxr-xr-x. 2 root root 4096 May  2 19:18 /usr/lib64/samba/auth

Now change the permission to 777 for all.

[root@rhel6-test1 ~]# chmod 777 /etc/pam.d/samba /etc/samba/smbusers /usr/bin/smbstatus
[root@rhel6-test1 ~]# ls -ltr /etc/pam.d/samba /etc/samba/smbusers /usr/bin/smbstatus
-rwxrwxrwx. 1 root root      97 Dec 17  2012 /etc/samba/smbusers
-rwxrwxrwx. 1 root root     177 Dec 17  2012 /etc/pam.d/samba
-rwxrwxrwx. 1 root root 1675672 Dec 17  2012 /usr/bin/smbstatus

[root@rhel6-test1 ~]# chmod 777 /usr/lib64/samba/auth

[root@rhel6-test1 ~]# ls -ld /usr/lib64/samba/auth
drwxrwxrwx. 2 root root 4096 May  2 19:18 /usr/lib64/samba/auth

Well, suppose above was done by someone and not limited to 4 files, several file perms are messed up of package “samba”. What to do?

[root@rhel6-test1 ~]# rpm --setperms samba

See the magic………………………

[root@rhel6-test1 ~]# ls -ltr /etc/pam.d/samba /etc/samba/smbusers /usr/bin/smbstatus
-rw-r--r--. 1 root root      97 Dec 17  2012 /etc/samba/smbusers
-rw-r--r--. 1 root root     177 Dec 17  2012 /etc/pam.d/samba
-rwxr-xr-x. 1 root root 1675672 Dec 17  2012 /usr/bin/smbstatus
[root@rhel6-test1 ~]# ls -ld /usr/lib64/samba/auth
drwxr-xr-x. 2 root root 4096 May  2 19:18 /usr/lib64/samba/auth

How to reset the file ownership?

[root@rhel6-test1 ~]# rpm --setugids samba

How to see the yum logs?

[root@rhel6-test1 ~]# cat /var/log/yum.log
May 02 18:00:33 Erased: samba
May 02 18:00:46 Installed: finger-0.17-39.el6.x86_64
May 02 18:05:51 Installed: samba-3.6.9-151.el6.x86_64
May 02 18:12:43 Erased: finger
May 02 18:19:07 Installed: finger-0.17-39.el6.x86_64
May 02 19:06:19 Erased: samba
May 02 19:06:19 Erased: finger
May 02 19:08:35 Installed: samba-3.6.9-151.el6.x86_64
May 02 19:08:35 Installed: finger-0.17-39.el6.x86_64


REFERENCES & GOOD READ:



No comments:

Post a Comment