Linux applications installed (generally) as packages. Packages contain 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 a 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 at 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 installs it.
Install A Package
Installing a 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 A 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 exist. If we are confident what we do we simply provide -y parameter to accept all confirmation questions like below.
$ sudo yum install tmux -y
Install Group Packages
If we want to install group which includes a group of packages for similar targets like gnome desktop, KDE desktop, etc. we can use @ sign before package name
$ sudo 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 an update. You can specify version if not it is updated to the latest. If not installed it is installed. To see any updates available use check-update which outputs updated packages count. The upgrade is the same but looks for the obsolete flag.
$ sudo yum update
List Group Packages
Repositories provide 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 the only list installed group packages.
$ yum grouplist installed
To remove packages use to remove or erase which removes all files and dependencies.
$ sudo yum remove wireshark
Remove Group Packages
Group packages can be removed like a regular package. To remove group packages just provide
groupremove like below.
$ sudo 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 a very handy option for looking at 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 packages for x64 and x86 which is shown i686. This will provide information like name, architecture, version, release, size, repository, description, license
$ yum info wireshark
To clear 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.
$ sudo yum clean all
Yum Interactive Shell
Yum, the shell is used for batch or interactive command line if you specify file the yum commands in the file are executed if not you will get a shell to run yum commands.
$ sudo yum shell
Installed packages can be installed again. This will reconfigure the package and clean the binaries and configuration of the package.
$ sudo 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.
$ sudo 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 package like libraries, binaries, frameworks. The dependency of a package can be got 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 are also popular repositories provided by third parties. All these repositories can be listed with
$ yum repolist
List All Repositories
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 the previous example, we have listed repositories. Details about these repositories can be listed with
$ 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 a practical way to see the 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.
$ sudo 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 an error or disrupt and you need to resume the transaction.
$ sudo 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 the 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.
$ sudo yum install --nogpgcheck tmux
Skip Broken Packages For Update
Sometimes updates come with broken dependencies or packages so you can skip all of them and install other packages without problem use –skip-broken
$ sudo 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
$ sudo yum --downloadonly install tmux