Yum Command Tutorial With Examples For Linux Package Management Like Install, Update Remove
Linux applications installed (generally) as packages. Packages contains required files like binary, configuration, database, data, graphic etc. All files packaged to one file named rpm. There is a lot of packages in fedora or other rpm based distribution to manage.
Keep in mind that there is also different version of packages like a1,a2,a3. Packages are named like wireshark-1.10.7-3.fc20.x86_64. Here wireshark is package real name as we know, 1.10.7-3 is the version number used in wireshark, fc20 shows that this packages used in fedora core 20 but it is not must you can use this packet if you supply dependencies of package, latest x86_64 means that this package includes 64 bit binaries and this is important because it will not work with 32 bit libraries or OS if you see noarch it means that there is no architecture specific binary. Do we look all of these things when installing applications? NO because a lot of work is done by yum rpm manager. Yum use rpm to make things more smooth and easy. So we just write package name and it install it. So much talk is enough let’s action.
Installing package is very easy you can add more packages with space delimiter. Here we will install wireshark core package and gcc which is a c compiler. If we want to install them without answering yes/no question we must provide -y between yum and install like yum -y install. Here yum resolves dependencies and show installation required packages. There is 9 required package.
$ yum install wireshark gcc
Install Package From Specified Repository
As we will see below yum can use multiple repositories and the same package can be provided from multiple repositories. While installing this package we can specify specific repository like below.
$ yum --enablerepo="centosplus/7/x86_64"_64 install tmux
Automatic Confirmation / Yes
While operating with yum commands for caution reasons confirmations exists. If we are confident what we do we simply provide -y parameter to accept all confirmation questions like below.
$ yum install tmux -y
Install Group Packages
If we want to install group which includes group of packages for similar targets like gnome desktop, kde desktop etc. we can use @ sign before package name
$ yum install @"KDE Plasma Workspaces"
To search packages with specific word use search. If you want to search all areas of package description use all parameter.
$ yum search wiresh
Search More Details
Name and summary matches only, use “search all” for everything.
$ yum search all wiresh
If you want to list all available packages use list option. But there may be a lot of output you can filter it with grep
$ yum list
To update packages use update. You can specify version if not it is updated to the latest. If not installed it is installed. To see any updatest available use check-update which outputs updated packages count. Upgrade is the same but looks for obsolete flag.
$ yum update
List Group Packages
Repositories provides packages. There can be more than one repository configured in a Linux system. Packages provided configured repositories can be listed like below.
$ yum grouplist
List Installed Group Packages
There is an option to only list installed group packages
$ yum grouplist installed
To remove packages use remove or erase which removes all files and dependencies.
$ yum remove wireshark
Remove Group Packages
Group packages can be removed like a regular package. To remove group packages just provide groupremove like below.
$ yum groupremove "GNOME Desktop"
Find Package Name With File Path
If you want to search a filename in packages use provides or whatprovides. This is very handy option for looking what file belongs to what package. Here we query etc/grub2.cfg and get results from different versions of grub.
$ yum whatprovides /etc/grub2.cfg
To get info about a package use info . Wireshark has two package for x64 and x86 which is shown i686. This will provide information like name, architecture,version,realease, size, repository, description, license
$ yum info wireshark
To clean cache files and get more free space. We can use this command for every 1-2 months. This option has parameters but using all is most practical usage.
$ yum clean all
Yum Interactive Shell
Yum shell is used for batch or interactive command line if you specify file the yum commands in file are executed if not you will get a shell to run yum commands.
$ yum shell
Installed packages can be installed again. This will reconfigure the package and clean the binaries and configuration of the package.
$ yum reinstall wireshark
This is a rare situation. Packages can be downgraded which means installing older versions. If there is an application relies on old releases this feature can be used. To downgrade a package exact version must be exist configured repository.
$ yum downgrade qemu-img-1.6.2-5.fc20.x86_64
List Package Dependencies
Dependency is the requirement to install a package. A package dependency is another packages like libraries, binaries, frameworks. The dependency of a package can be get by providing the package name like below.
$ yum deplist wireshark
List Enabled Repositories
Generally Linux systems are configured to use more than one repository. There is also popular repositories provided by third parties. All these repositories can be listed with repolist command.
$ yum repolist
List All Repositories
By default yum repolist command provides enabled repositories. There may be some repositories not enabled and not used. Providing all will list all enabled and not enabled repositories.
$ yum repolist all
Print Detailed Repository Information
In previous example we have listed repositories. Details about these repositories can be listed with repoinfo command.
$ yum repoinfo base/7/x86_64
repoinfo provides repository information like repository id, name, status,revision, package count, size, mirrors, base url, expire and file name.
Yum Command History
Yum provides practical way to see history of yum with history parameter. To see yum history we can also look to the /var/log/yum.log for more detailed info. history command provides command id, command, issued date and time, action and changed package count.
$ yum history
Think about this while installing packages with yum the ssh connection is lost. What will happen can we resume from where we left? Yes.Some times there is a error or disrupt and you need to resume transaction
$ yum load-transaction /tmp/yum_save_tx.2017-01-12.13-02.LIA7DG.yumtx
Yum Database Integrity Check
check command will check the status of the yum database. If it founds some corruption it will try to recover this.
$ yum check
Yum Configuration File
Generally yum configuration resides /etc/yum.conf and /etc/yum.conf.d and these paths are used as default. If you want to specify different yum configuration file use -c option
$ yum -c yum.conf search wiresha
While using operation commands with yum we may want to get more informed about running command. We can use -v option to see more details about yum operations.
$ yum -v search wiresha
Install Without GPG/Digest Check
Rpm files are signed for security reasons but some times it may be a trivial problem and we want to disable signature checking use –nogpgcheck . But generally do not prefer using this option which will provide some security thread for the installed packages.
$ yum install --nogpgcheck tmux
Skip Broken Packages For Update
Sometimes updates comes with broken dependencies or packages so you can skip all of them and install other packages without problem use –skip-broken
$ yum --skip-broken update
Only Download Package
To just download packages not install them you can install them later. This will download package to the current working directory like a name tmux-1.8-4.el7.x86_64.rpm
$ yum --downloadonly install tmux