yum | LinuxHostSupport Linux Tutorials and Guides Thu, 19 Mar 2020 22:40:36 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 How to Set Up and Use Yum Repositories on CentOS 7 https://linuxhostsupport.com/blog/how-to-set-up-and-use-yum-repositories-on-centos-7/ https://linuxhostsupport.com/blog/how-to-set-up-and-use-yum-repositories-on-centos-7/#comments Thu, 19 Mar 2020 22:40:36 +0000 https://linuxhostsupport.com/blog/?p=1085 This tutorial explains how to set up and use Yum repositories on a CentOS 7 VPS. The official CentOS 7 repository has a huge list of packages and it covers almost all bases in terms of software for servers, but sometimes we need some additional packages which are not available in the official repositories. In […]

The post How to Set Up and Use Yum Repositories on CentOS 7 appeared first on LinuxHostSupport.

]]>
This tutorial explains how to set up and use Yum repositories on a CentOS 7 VPS.

The official CentOS 7 repository has a huge list of packages and it covers almost all bases in terms of software for servers, but sometimes we need some additional packages which are not available in the official repositories. In that case, we can simply add new repositories to further expand the catalogue of packages available to us. Let’s begin with the tutorial.

Step 1. Login via SSH

Log in to your CentOS 7 VPS via SSH as the root user, or as an account with sudo privileges:

ssh root@IP_Address -p Port_number

Make sure to replace “IP_Address” and “Port_number” with your server’s IP address and SSH port.

Step 2. Update the OS Packages and Install the yum-utils Package:

Once you are logged in to the server, run the following commands to make sure that all installed packages are up to date:

yum clean all
yum update

Install the yum-utils package using the following command:

yum install yum-utils

We can enable the EPEL (Extra Packages for Enterprise Linux) repository on CentOS 7 / RHEL 7, maintained by a special Fedora Special Interest Group that creates, maintains, and manages high quality additional packages for enterprise Linux versions. This includes Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux (SL), and Oracle Enterprise Linux (OEL).

Step 3. Install the EPEL repository

To install the EPEL rpm, do so with the following command:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

The output will appear as shown below:

Retrieving https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-11                ################################# [100%]

Check the newly installed repository. You should be able to find the EPEL repository in the list.

yum repolist

You should receive the following output, or something similar to it:

base                                                                                                            | 3.6 kB  00:00:00
epel/x86_64/metalink                                                                                            |  11 kB  00:00:00
epel                                                                                                            | 3.2 kB  00:00:00
extras                                                                                                          | 3.4 kB  00:00:00
updates                                                                                                         | 3.4 kB  00:00:00
(1/7): base/7/x86_64/group_gz                                                                                   | 166 kB  00:00:00
(2/7): base/7/x86_64/primary_db                                                                                 | 5.9 MB  00:00:00
(3/7): epel/x86_64/group_gz                                                                                     |  88 kB  00:00:00
(4/7): epel/x86_64/updateinfo                                                                                   | 934 kB  00:00:00
(5/7): updates/7/x86_64/primary_db                                                                              | 6.0 MB  00:00:00
(6/7): extras/7/x86_64/primary_db                                                                               | 204 kB  00:00:00
(7/7): epel/x86_64/primary                                                                                      | 3.6 MB  00:00:00
epel                                                                                                                       12739/12739
repo id                                         repo name                                                                      status
base/7/x86_64                                   CentOS-7 - Base                                                                9,901+10
epel/x86_64                                     Extra Packages for Enterprise Linux 7 - x86_64                                   12,739
extras/7/x86_64                                 CentOS-7 - Extras                                                                   432
updates/7/x86_64                                CentOS-7 - Updates                                                             1,543+71
repolist: 24,615

In order to see all of the packages available in the EPEL repository, run the following command:

yum --enablerepo=epel list | less

The output of this command will show you the list of packages.

Note: Other CentOS repositories that can be useful are located in /etc/yum.repos.d directory. When enabling some repository manually by editing the .repo file, make sure that the main version for CentOS is used in the repo file, in this case, it is CentOS 7.

For example, edit the CentOS-Base.repo file and add/modify these lines:

[base]
name=CentOS $releasever – Base
baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=0
enabled=1

[updates]
name=CentOS $releasever – Updates
baseurl=http://mirror.centos.org/centos/7/updates/$basearch/
gpgcheck=0
enabled=1

[extras]
name=CentOS $releasever – Extras
baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
gpgcheck=0
enabled=1

Listing all repositories

To list all repositories, including all enabled and disabled repositories, run:

yum repolist all

Enabling a Yum Repository

To enable a Yum repository, run the following command as root:

yum-config-manager --enable repository <repository name>

Disabling a Yum Repository

To disable a Yum repository, run the following command as root:

yum-config-manager --disable repository <repository name>

Do not forget to replace <repository name> with the actual repo name.

If for some reason we cannot find the software package we need in the official and EPEL repositories, we can extend the capabilities of the server with even more software by adding additional repositories, like the Remi RPM repository, which is not an official repository of CentOS distribution but is well maintained and always up to date.

Remi Collet maintains a large collection of RPM packages, including the latest versions of PHP, etc. Please note that this repo does not always play nicely with other third party CentOS repos, so check the list of repositories using yum repolist and disable additional repositories if there are any package conflicts.

We can install the Remi repository using this next command:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

If for example we want to enable PHP 7.2 , we can edit the /etc/yum.repos.d/remi-php72.repo file and change enabled=0 to enabled=1 :

# This repository only provides PHP 7.2 and its extensions
# NOTICE: common dependencies are in "remi-safe"

[remi-php72]
name=Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php72/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php72/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php72/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Another good unofficial CentOS repository is the Webtatic Repo. This repository provides updated packages with later versions of PHP, MySQL, and other packages. With this information, you can now install any repository of your choosing and expand the functionality of your server in any way that you need to.


Of course, you don’t have to setup and configure additional repositories on CentOS 7, if you use our Fully Managed VPS Support solutions, in which case you can simply ask our expert Linux admins to configure additional repositories on CentOS 7 for you, along with anything else that you might need. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to set up and use Yum repositories on a CentOS VPS, please share it with your friends on the social networks using the sharing shortcut, or simply leave a reply below. Thanks.

The post How to Set Up and Use Yum Repositories on CentOS 7 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-set-up-and-use-yum-repositories-on-centos-7/feed/ 3
How to Reveal All “Install” Commands Using Yum https://linuxhostsupport.com/blog/how-to-reveal-all-install-commands-using-yum/ https://linuxhostsupport.com/blog/how-to-reveal-all-install-commands-using-yum/#respond Thu, 21 Feb 2019 17:05:25 +0000 https://linuxhostsupport.com/blog/?p=786 Sometimes, working with YUM – the default CentOS package manager – can feel unintuitive and cumbersome. Sure, it’s better than using the even more barebones RPM package manager, but it still leaves a lot to be desired. Take YUM’s “history” command, for instance. The idea of that command is to give you a general idea […]

The post How to Reveal All “Install” Commands Using Yum appeared first on LinuxHostSupport.

]]>
Sometimes, working with YUM – the default CentOS package manager – can feel unintuitive and cumbersome. Sure, it’s better than using the even more barebones RPM package manager, but it still leaves a lot to be desired. Take YUM’s “history” command, for instance. The idea of that command is to give you a general idea of what package operations you’ve carried out recently. So if you’ve been installing stuff, upgrading older packages, or updating CentOS itself, YUM will keep a record of it all.

Getting a List of Manually Installed Packages

We can often install stuff that only ends up getting used a handful of times, which then ends up getting forgotten about being installed in the first place. This results in packages accumulating over a period of time, using up space, and cluttering our system files. It’s a good practice to clean them out every now and then. But how do we know which packages we installed manually?

If we use the history feature built into YUM by typing the following:

yum history

We get an output similar to this:

No Commands are Shown

This tells us the following:

  1. The transaction ID
  2. The Username
  3. The Date
  4. The Actions that were carried out
  5. The Number of files and/or packages altered

Unfortunately, this doesn’t tell us which specific packages were installed, nor does it give us the commands used or options used in conjunction with the commands. Without these two crucial pieces of information, we can’t know what was installed.

Luckily, YUM allows us to specify the “setopt” parameter, which will give us the command name. We use it like this:

sudo yum --setopt=history_list_view=commands history

We can now get the history together with the commands as well:

List of Commands
List of Commands

This is definitely an improvement over the previous output – we now at least know which packages we were working with.

However, it isn’t close enough to what we’re looking for. For one, the package names are often cut off (because they can get really long in Linux and not fit in the output), and second, there’s no filter for us to only display the commands related to installing packages with “install”.

Luckily, this information is available, but we can’t access it directly through the yum command. Instead, we have to go to the backend database where YUM stores its transaction history, and extract it from there.

Accessing the Yum SQLite Database

Instead of a text file, YUM stores its transaction data in an SQLite file. This data is located in the directory /var/lib/yum/history.

When we list the files found at this location, we can see the one with the “SQLite” extension, like this:

SQLite3 Database Location

Just like with a regular database, we can query it using the built-in sqlite3 package that comes pre-installed with Linux. What we want is to find all rows where the “cmdline” contains the word “install”. Here’s the command:

sqlite3 /var/lib/yum/history/history-2013-01-26.sqlite "select tid, cmdline from trans_cmdline WHERE cmdline LIKE '%install%'"

Replace history-2013-01-26.sqlite with the name of the SQLite file you got in the previous screenshot. Upon running this command, we see the following:

List the Installed Packages

And that’s all that we need – this gives us all of the commands executed that manually installed a package. Using this, you can get an idea of what packages you’re still using, and which ones you no longer need. You can also check any other SQLite files if needed in case there’s more than one. 

The downside of this method is that there’s no way to tell if these packages are still being used. You may already have uninstalled them, or some other package might have done it for you. Of course, you can cross-reference the packages with the “remove” command, but it can become a hassle.

That’s why YUM is now being replaced with DNF – the new package manager that’s already well entrenched in the Fedora environment. With it, you can get a list of user-installed packages as well as a lot of other cool features that you can’t yet get with YUM.

But for now, if you’ve been using YUM, this tutorial will help you get a grip on the user-installed-packages in CentOS.


Of course, you don’t have to do any of this if you use one of our Outsourced Server Support Services, in which case you can simply ask our expert Linux admins to find out which packages were installed manually through YUM for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to see your installed package history, please share it with your friends on the social networks using the share shortcut buttons on the left, or simply leave a comment in the comments section below. Thanks.

The post How to Reveal All “Install” Commands Using Yum appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-reveal-all-install-commands-using-yum/feed/ 0