yum is a package management tool, used to install, uninstall or update the Linux (CentOS, RHEL, Fedora etc.) packages. You can use yum with root privilege only.
To install a package:
yum install packagename
To update a package, if already install or to install a package:
yum update packagename
To reinstall a installed package:
yum reinstall packagename
To remove a installed package:
yum remove packagename
To see the list of package groups:
yum grouplist
To install all the packages of a group:
yum groupinstall packagegroupname
To update all the packages of a group:
yum groupupdate packagegroupname
To remove all the packages of a group:
yum groupremove packagegroupname
If you want to exclude some packages from group to install or update or remove, use “–exclude” option:
yum groupinstall packagegroupname –exclude=excludepackagename
To clean the cache of packages database:
yum clean all
Now some little tricky commands.
To disable all the repository & enable the given repositories only & then again same yum commands:
yum –disablerepo=\* –enablerepo=myreponame1,myreponame2 install packagename
You can get the reponame from the repo files inside the /etc/yum.repo.d directory. For example, the CentOS.repo file’s content is showing the reponame inside the square brackets “[ ]” as base & update. To select all the repo,”\*” is used.
[base]
name=CentOS-$releasever – Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5#released updates
[updates]
name=CentOS-$releasever – Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
“yum clean all” command does not clean the cache of disabled repositories, clean the cache by enabling all the repositories, remove all the cache:
yum –enablerepo=\* clean all
you can also remove the directory /var/cache/yum/* to clean all the cache of repositories.
There are so many other commands & combination in yum. If you like to share, please write as a comment.
If you like this post, don’t forget to share it with others…………..
Pingback: How to Install LibreOffice4.0.0 on CentOS 6/RHEL 6.3 | Linux Explore