Yum Utility in Linux Environment - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Community

Yum Utility in Linux Environment

Share This

If you are using Linux, you may be familiar with the yum utility. Yum stands for Yellowdog Updater Modified. Let us discuss how to use this.

In every operating system, installation, deletion, and updation of software packages are very common activities. Most Linux distributions provide at least one package manager utility. These commonly used utilities are apt-get, dpkg, rpm, yum, etc.

Some Linux distributions, like Fedora, RHEL, CentOs, etc, has yum utility as the default package manager.

Package Installation

At the time of package installation, yum identifies the dependencies of the package and if the packages are not installed, it installs the dependencies along with the desired package. To install a package, you can run yum install packagename.

# yum install mysql

By default 'yum install', will prompt you to accept or decline before installing the packages. If you want yum to install automatically without prompting, use the -y option as shown below.

# yum -y install mysql

Uninstall a package

To remove a package (along with all its dependencies), use 'yum remove package' as shown below.

# yum remove mysql

Upgrade an existing package

If you have an older version of a package, use 'yum update package' to upgrade it to the latest current version. This will also identify and install all required dependencies.

# yum update mysql

Search for a package

If you don't know the exact package name to be installed, use 'yum search keyword', which will search all the packages that match the 'keyword' and display it.
To search a package in the yum repository the following command can be used. It shows a list of available packages from all the packages that match the name. For example, to perform a search in the yum repository, you can run the following command.

# yum search firefox

Display additional information about a package

Once you search for a package using yum search, you can use 'yum info package' to view additional information about the package.
The following examples display additional information about the samba-common package.

# yum info mysql

View all available packages

The following command will list all the packages available in the yum database.

# yum list | less

List only the installed packages

To view all the packages that are installed on your system, execute the following yum command.

# yum list installed | less

Which package does a file belong to?

Use 'yum provides' if you like to know which package a particular file belongs to. For example, to find the name of the package that contains /etc/sysconfig/nfs file, you may try the following command.

# yum provides /etc/sysconfig/nfs

List available software groups

In yum, several related packages are grouped together in a specific group. Instead of searching and installing all the individual packages, you can install the group that will install all the packages belonging to the group.
To view, all the available software groups execute 'yum grouplist' as shown below. It shows a list of three groups: i) Installed Groups, ii) Installed Language Groups and iii) Available Groups.

# yum grouplist

Install a specific software group

To install a specific software group, use the groupinstall option as shown below. To install the 'DNS Name Server' group that contains bind and bind-chroot, you may try the following.

# yum groupinstall 'DNS Name Server'

Upgrade an existing software group

If you've already installed a software group using yum groupinstall, and would like to upgrade it to the latest version, use 'yum groupupdate' as shown below.

# yum groupupdate 'Graphical Internet'

Uninstall a software group

To delete an existing software group use 'yum groupremove' as shown below.

# yum groupremove 'DNS Name Server'

Display your current yum repositories

All yum commands go against one or more yum repositories. You can use 'yum repolist' to view all the installed and configured yum repositories in your system. The following will display only the enabled repositories.

# yum repolist

To display all the repositories (both enabled and disabled), use 'yum repolist all'.

# yum repolist all

View only the disabled repositories

Install from disabled repositories using yum -enablerepo
By default yum installs only from the enabled repositories. For some reason, if you like to install a package from disabled repositories, use -enablerepo option in the 'yum install' as shown below.

# yum --enablerepo=fedora-source install vim-X11.x86_64

Execute yum commands interactively using Yum Shell

If you want to install multiple commands, this utility is helpful to run the commands using the interactive shell as shown below.

# yum shell

Yum can also read commands from a text file and execute them one by one. This is very helpful when you have multiple systems and the same commands need to install in all the systems. In this case, you can create a text file containing the commands and use 'yum shell' to execute those commands as shown below.

# cat yum_cmd.txt
# yum shell yum_cmd.txt

Happy Exploring!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.