Saturday, May 9, 2015

Yum Package Installer in CentOS / RHEL

To install a package like samba simply enter:
# yum install samba
To update a package:
# yum update samba
And to update all installed packages:
# yum update samba
To remove a package: 
# yum remove samba
To print the list of current and active repositories, use:
# yum repolist
To print the list of all enabled and disabled repositories:
# yum repolist all
If you need more information about the repositories, enter: 
# yum repoinfo
To query about a particular package like samba:
# yum info samba
Note: rpm -q --info samba works just for the packages which already installed. 

To get more information like the rpm checksum, the command given on the command line that was invoked to install the rpm package (if any), and the reason that the package was installed on the system (where user indicates it was installed by the user, and dep means it was brought in as a dependency):
# yumdb info samba
If you do not know the package name, you still can install it by using one of its files: 
# yum install /usr/sbin/named
If you know you want to install the package that contains a particular binary file but you do not know in which bin or sbin directory is the file installed, use:
# yum provides "*bin/named"
If you have a package to install and the package will demand for dependencies and those dependencies are present in yum repository then the localinstall will become very helpful:
# yum localinstall <path>
To display twenty most recent yum transactions:
# yum history
To synchronize the rpmdb or yumdb database contents for any installed package with the currently used rpmdb or yumdb database, type:
# yum history sync
If you want to take a look at yum storage directory, go to /var/cache/yum/$basearch/$releasever/ which is my case is /var/cache/yum/x86_64/7/ then you can see a directory for each repository.