Managing Repos in Linux

Managing Repos in Linux

Removing / Disabling Package/Repos causing conflicts During Yum Update 

During yum update if there is a conflict, you need to fix by excluding unwanted 3rd party packages / repos that belongs to a specific repository, use any one of the two methods explained in this tutorial.

Also, keep in mind that instead of excluding a whole repository, you can also exclude a specific package.

1. Get Repository List

To view all the available repositories on your system, execute yum repolist as shown below.

# yum repolist
repo id                repo name              status
base                   CentOS-6 - Base        6,575
extras                 CentOS-6 - Extras         62
updates                CentOS-6 - Updates     1,622
dockerrepo             Docker Repository          2
mongodb-org-3.0        MongoDB Repository        75
repolist: 8,336

In the above example, we have the following:

  • The first three repositories listed above are the main CentOS repositories: base, extras and updates
  • dockerrepo is a 3rd party repository that contains Docker container related packages
  • mongodb-org-3.0 is a 3rd party repository that contains MongoDB related packages.

When you do yum update as shown below, it will upgrade all the packages that are already installed on your system to the latest version available from all of the above repositories.

yum update

If you already have mongodb installed on your system, and when you execute the above “yum update”, it will also upgrade mongodb packages to the latest version.

If you don’t want to upgrade mongodb when you do “yum update”, you should exclude that during yum update as explained in the following section.

 

Also, if you want to know which repository a particular package belongs to, so that you can exclude that repository from getting upgraded, use yum info command as shown below.

yum info package-name | grep -i repo

2. Exclude a Repository from Yum Update (Method 1)

You can use the option –disablerepo=repository-name along with yum update. This will not upgrade the packages that belongs to the given repository name.

In the following example, yum update will upgrade all installed packages except any installed packages that belongs to MongoDB repository.

yum --disablerepo=mongodb-org-3.0 update

You can also specify the –disablerepo option at the end after yum update. The following will exclude packages that belongs to Docker repository during yum update.

yum update --disablerepo=dockerrepo

You can get the exact repository name that you want to exclude by looking at the 1st column of the “yum repolist” command output.

3. Exclude a Repository from Yum Update using Enabled Parameter (Method 2)

Instead of excluding a specific repository from yum update command line, you can permanently exclude a package from yum update by setting the enabled parameter to 0 in the repository configuration file.

The repository configuration files are located under /etc/yum.repos.d directory as shown below.

# ls -l /etc/yum.repos.d/
-rw-r--r--. 1 root root 1926 Jan 30  2016 CentOS-Base.repo
-rw-r--r--  1 root root  166 Feb 18  2016 docker.repo
-rw-r--r--  1 root root  142 Feb  5  2016 mongodb-org-3.0.repo
..
..

To exclude mongodb repository, open the mongodb repository file, and set change the value of enabled to 0 as shown below.

# vi /etc/yum.repos.d/mongodb-org-3.0.repo 
[mongodb-org-3.0]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=0

Now, if you do yum repolist, you’ll not see MongoDB repository in the output.

# yum repolist
repo id           repo name              status
base              CentOS-6 - Base        6,575
extras            CentOS-6 - Extras         62
updates           CentOS-6 - Updates     1,622
dockerrepo        Docker Repository          2
repolist: 8,261

This also means that even though you have mongodb related packages installed on your system, when you do the following “yum update”, mongodb packages will not be upgraded anymore.

yum update

4. Exclude Multiple Repositories from Yum update Command Line

You can also exclude multiple repositories during the yum update by specifying the repositories delimited by comma as shown below.

The following example will exclude MongoDB, Docker and EPEL repository during yum update.

yum update --disablerepo=mongodb-org-3.0,dockerrepo,epel

5. Enable a Repository for Yum Update

If you have disabled a repository by setting “enabled=0” in the repository configuration file, you can still include that during your “yum update” by using the –enablerepo option as shown below.

The following example will include the packages from MongoDB repository during “yum update” even though this repository is disabled in the repository file under /etc/yum.repos.d/ directory.

yum update --enablerepo=mongodb-org-3.0

6. Combine EnableRepo and DisableRepo in Yum Update

You can also get creative by combining enablerepo and disablerepo option.

For example, the following yum update command will upgrade only packages from MongoDB repository.

yum update --disablerepo=* --enablerepo=mongodb-org-3.0

In the above:

  • –disablerepo=* This indicates that all the repositories should first be disabled and not be considered for yum update
  • –enablerepo=mongo This indicates that only MongoDB repository should be considered during yum update (when combined with the above disable option)
=============================================================================
 

Installing, removing, and updating packages is a typical activity on Linux.


Most of the Linux distributions provides some kind of package manager utility. For example, apt-get, dpkg, rpm, yum, etc.

On some Linux distributions, yum is the default package manager.

Yum stands for Yellowdog Updater Modified.

This article explains 15 most frequently used yum commands with examples.

1. Install a package using yum install

To install a package, do ‘yum install packagename’. This will also identify the dependencies automatically and install them.

The following example installs postgresql package.

# yum install postgresql.x86_64
Resolving Dependencies
Install       2 Package(s)
Is this ok [y/N]: y

Package(s) data still to download: 3.0 M
(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm          | 2.8 MB     00:11
(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm    | 203 kB     00:00
------------------------------------------------------------------
Total                                        241 kB/s | 3.0 MB     00:12     

Running Transaction
  Installing : postgresql-libs-9.0.4-5.fc15.x86_64             1/2
  Installing : postgresql-9.0.4-5.fc15.x86_64                   2/2 

Complete!

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 -y option as shown below.

 
# yum -y install postgresql.x86_64

2. Uninstall a package using yum remove

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

# yum remove  postgresql.x86_64
Resolving Dependencies
---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erased

Is this ok [y/N]: y

Running Transaction
  Erasing    : postgresql-9.0.4-5.fc15.x86_64       1/1 

Removed:
  postgresql.x86_64 0:9.0.4-5.fc15

Complete!

3. Upgrade an existing package using yum update

If you have a 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 postgresql.x86_64

4. Search for a package to be installed using yum search

If you don’t know the exact package name to be installed, use ‘yum search keyword’, which will search all the packages that matches the ‘keyword’ and display it.

The following examples searches the yum repository for all the packages that matches the keyword ‘firefox’ and lists the available packages.

# yum search firefox
Loaded plugins: langpacks, presto, refresh-packagekit
============== N/S Matched: firefox ======================
firefox.x86_64 : Mozilla Firefox Web browser
gnome-do-plugins-firefox.x86_64 : gnome-do-plugins for firefox
mozilla-firetray-firefox.x86_64 : System tray extension for firefox
mozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefox
mozilla-noscript.noarch : JavaScript white list extension for Mozilla Firefox

Name and summary matches only, use "search all" for everything.

5. Display additional information about a package using yum info

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 displays additional information about the samba-common package.

# yum info samba-common.i686
Loaded plugins: langpacks, presto, refresh-packagekit
Available Packages
Name        : samba-common
Arch        : i686
Epoch       : 1
Version     : 3.5.11
Release     : 71.fc15.1
Size        : 9.9 M
Repo        : updates
Summary     : Files used by both Samba servers and clients
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description : Samba-common provides files necessary for both the server and client
            : packages of Samba.

6. View all available packages using yum list

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

# yum list | less

7. List only the installed packages using yum list installed

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

# yum list installed | less

8. Which package does a file belong to? – Use yum provides

Use ‘yum provides’ if you like to know which package a particular file belongs to. For example, if you like to know the name of the package that has the /etc/sysconfig/nfs file, do the following.

# yum provides /etc/sysconfig/nfs
Loaded plugins: langpacks, presto, refresh-packagekit
1:nfs-utils-1.2.3-10.fc15.x86_64 : NFS utilities and supporting clients and
                                 : daemons for the kernel NFS server
Repo        : fedora
Matched from:
Filename    : /etc/sysconfig/nfs

1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server
Repo        : updates
Matched from:
Filename    : /etc/sysconfig/nfs

1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server
Repo        : installed
Matched from:
Other       : Provides-match: /etc/sysconfig/nfs

9. List available software groups using yum grouplist

In yum, several related packages are grouped together in a specific group. Instead of searching and installing all the individual packages that belongs to a specific function, you can simply install the group, which will install all the packages that belongs to the group.

To view all the available software groups execute ‘yum grouplist’ as shown below. The output is listed in three groups–Installed Groups, Installed Language Groups and Available Groups.

# yum grouplist

Installed Groups:
   Administration Tools
   Base
   Design Suite
   ....

Installed Language Groups:
   Arabic Support [ar]
   Armenian Support [hy]
   Bengali Support [bn]
   ....

Available Groups:
   Authoring and Publishing
   Books and Guides
   Clustering
   DNS Name Server
   Development Libraries
   Development Tools
   Directory Server
   Dogtag Certificate System
   ...

10. Install a specific software group using yum groupinstall

To install specific software group, use groupinstall option as shown below. In the following example, ‘DNS Name Server’ group contains bind and bind-chroot.

# yum groupinstall 'DNS Name Server'

Dependencies Resolved
Install       2 Package(s)
Is this ok [y/N]: y

Package(s) data still to download: 3.6 M
(1/2): bind-9.8.0-9.P4.fc15.x86_64.rpm             | 3.6 MB     00:15
(2/2): bind-chroot-9.8.0-9.P4.fc15.x86_64.rpm   |  69 kB     00:00
-----------------------------------------------------------------
Total               235 kB/s | 3.6 MB     00:15

Installed:
  bind-chroot.x86_64 32:9.8.0-9.P4.fc15

Dependency Installed:
  bind.x86_64 32:9.8.0-9.P4.fc15

Complete!

Note: You can also install MySQL database using yum groupinstall as we discussed earlier.

11. Upgrade an existing software group using groupupdate

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'

Dependencies Resolved
Upgrade       5 Package(s)
Is this ok [y/N]: y   

Running Transaction
  Updating   : evolution-data-server-3.0.2-1.fc15.x86_64     1/10
  Updating   : evolution-3.0.2-3.fc15.x86_64                 2/10
  Updating   : evolution-NetworkManager-3.0.2-3.fc15.x86_64  3/10
  Updating   : evolution-help-3.0.2-3.fc15.noarch            4/10
  Updating   : empathy-3.0.2-3.fc15.x86_64                   5/10
  Cleanup    : evolution-NetworkManager-3.0.1-1.fc15.x86_64  6/10
  Cleanup    : evolution-help-3.0.1-1.fc15.noarch            7/10
  Cleanup    : evolution-3.0.1-1.fc15.x86_64                 8/10
  Cleanup    : empathy-3.0.1-3.fc15.x86_64                   9/10
  Cleanup    : evolution-data-server-3.0.1-1.fc15.x86_64     10/10 

Complete!

12. Uninstall a software group using yum groupremove

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

# yum groupremove 'DNS Name Server'
Dependencies Resolved
Remove        2 Package(s)
Is this ok [y/N]: y

Running Transaction
  Erasing    : 32:bind-chroot-9.8.0-9.P4.fc15.x86_64  1/2
  Erasing    : 32:bind-9.8.0-9.P4.fc15.x86_64            2/2 

Complete!

13. Display your current yum repositories

All yum commands goes against one or more yum repositories. To view all the yum repositories that are configured in your system, do ‘yum repolist’ as shown below.

The following will display only the enabled repositories.

# yum repolist
repo id     repo name                        status
fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612

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

# yum repolist all
repo id                   repo name                                status
fedora                    Fedora 15 - x86_64                       enabled: 24,085
fedora-debuginfo          Fedora 15 - x86_64 - Debug               disabled
fedora-source             Fedora 15 - Source                       disabled
rawhide-debuginfo         Fedora - Rawhide - Debug                 disabled
rawhide-source            Fedora - Rawhide - Source                disabled
updates                   Fedora 15 - x86_64 - Updates             enabled:  5,612
updates-debuginfo         Fedora 15 - x86_64 - Updates - Debug     disabled
updates-source            Fedora 15 - Updates Source               disabled
updates-testing           Fedora 15 - x86_64 - Test Updates        disabled
updates-testing-debuginfo Fedora 15 - x86_64 - Test Updates Debug  disabled
updates-testing-source    Fedora 15 - Test Updates Source          disabled

To view only the disabled repositories, use ‘yum repositories disabled’.

14. Install from a 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 a disabled repositories, use –enablerepo option in the ‘yum install’ as shown below.

# yum --enablerepo=fedora-source install vim-X11.x86_64
Dependencies Resolved
Install       1 Package(s)
Is this ok [y/N]: y

Running Transaction
  Installing : 2:vim-X11-7.3.138-1.fc15.x86_64   1/1 

Complete!

15. Execute yum commands interactively using Yum Shell

Yum provides the interactive shell to run multiple commands as shown below.

# yum shell
Setting up Yum Shell
> info samba.x86_64
Available Packages
Name        : samba
Arch        : x86_64
Epoch       : 1
Version     : 3.5.11
Release     : 71.fc15.1
Size        : 4.6 M
Repo        : updates
Summary     : Server and Client software to interoperate with Windows machines
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description :
            : Samba is the suite of programs by which a lot of PC-related
            : machines share files, printers, and other information (such as
            : lists of available files and printers). The Windows NT, OS/2, and
            : Linux operating systems support this natively, and add-on packages
            : can enable the same thing for DOS, Windows, VMS, UNIX of all
            : kinds, MVS, and more. This package provides an SMB/CIFS server
            : that can be used to provide network services to SMB/CIFS clients.
            : Samba uses NetBIOS over TCP/IP (NetBT) protocols and does NOT
            : need the NetBEUI (Microsoft Raw NetBIOS frame) protocol.

> 

Yum can also read commands from a text file and execute it one by one. This is very helpful when you have multiple systems. Instead of executing the same command on all the systems, create a text file with those commands, and use ‘yum shell’ to execute those commands as shown below.

# cat yum_cmd.txt
repolist
info nfs-utils-lib.x86_64

# yum shell yum_cmd.txt 
repo id     repo name                        status
fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612

Available Packages
Name        : nfs-utils-lib
Arch        : x86_64
Version     : 1.1.5
Release     : 5.fc15
Size        : 61 k
Repo        : fedora
Summary     : Network File System Support Library
URL         : http://www.citi.umich.edu/projects/nfsv4/linux/
License     : BSD
Description : Support libraries that are needed by the commands and
            : daemons the nfs-utils rpm.

Leaving Shell

 
    • Related Articles

    • New Access Management User setup on Linux

      1) Login to your accounts.cartika.com account 2) Select your access management service (customers with managed infrastructure in both the US and CAD will have two) 3) Navigate to Login to SolidCP -> Click Login 4) Click on Users under your Hosted ...
    • Linux

      Linux     System Information: Print Kernel and OS Release Versions: uname -r (or uname -a for all info) 2.6.32-531.29.2.lve1.3.11.1.el6.x86_64 cat /etc/*release* CloudLinux Server release 6.6 (Leonid Kizim) Linux Watch Limit: ...
    • Linux BMR (ReaR)

      Cartika has developed a new Linux BMR tool into our backups/dr and BaaS offerings.  This is more tightly integrated with our GUI and is based on the ReaR *nix server imaging technology. This new Linux BMR replaces the legacy/original Linux BMR. AS ...
    • Managing Hotmail Safe Senders

      Adding a domain to a Hotmail.com safe senders list will ensure emails sent to that hotmail address are processed.  Hotmail and Windows Live have a very strong filter that blocks a lot of mail which is not spam. Although the Hotmail/Windows Live pages ...
    • Managing RDS Users

      Customers on our "Access Management" platform can manage their own RDS users, create groups for both security and control, along with assigning specific users to specific servers and/or groups of servers. 1) Navigate to your accounts.cartika.com and ...