How to Enable Proxy Settings for Yum Command on AlmaLinux 9

Yum is a package manager written in Python used for getting, installing, querying, and managing Red Hat Enterprise Linux RPM software packages.

Sometimes the files that we need to download and access are not accessible directly on remote servers, and we need to configure a proxy so we can download them on our machine. That is why we need to configure Yum to use a proxy server.

Enabling proxy settings for Yum is a straightforward process that may take up to 5 minutes. Let’s get started!

  • A server with AlmaLinux 9 as OS
  • User privileges: root or non-root user with sudo privileges

Update the System

We assume that you have a fresh installation of AlmaLinux 9, so let’s first update the system packages to their latest versions available:

sudo dnf update -y && sudo dnf upgrade -y

Explaining the Proxy settings

Before we enable the proxy settings, we will explain them in a couple of sentences:

<strong>proxy</strong> is the URL of the proxy server Yum will use along with the TCP port number.

<strong>proxy_username</strong> is the proxy server username for the Proxy URL. This is optional and sometimes it is unset.

<strong>proxy_password</strong> is the password for the proxy_username, and if the username is unset than we do not have a password. It is an optional field as well.

<strong>logfile</strong> is an essential field and we must declare it so we can read the errors if they occur when enabling the proxy.

Enable Proxy Settings

To enable proxy settings for the Yum command, open the file /etc/yum.conf and edit it to look like this:

[main]

cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
tolerant=1
errorlevel=1
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1

proxy=http://<strong>YourDomainProxy.com</strong>:<strong>TCP_Port</strong>
proxy_username=<strong>ProxyUsername</strong>
proxy_password=<strong>YourStrongPasswordHere</strong>

Save the file, close it and update the system.

yum update -y

Enable Proxy Settings for a Single User

Let’s say that we need proxy settings only for specific users. To do that, you only need to add the following lines of code to the user’s shell profile:

http_proxy="http://<strong>YourDomainProxy.com</strong>:<strong>TCP_Port</strong>"
export http_proxy

If there is proxy_username and proxy_password set, then it will look like this:

http_proxy="http://<strong>ProxyUsername</strong>:<strong>YourStrongPasswordHere</strong>@<strong>YourDomainProxy.com</strong>:<strong>TCP_Port</strong>
export http_proxy

Test Settings

Once you configure the proxy settings for yum, you can easily test them by searching some packages. For example, we will search the Exim package:

yum search exim

If everything is set properly, you should get output similar to this:

[root@host ~]# yum search exim
exim.x86_64 : The exim mail transfer agent
exim-greylist.x86_64 : Example configuration for greylisting using Exim
exim-mon.x86_64 : X11 monitor application for Exim
exim-mysql.x86_64 : MySQL lookup support for Exim
exim-pgsql.x86_64 : PostgreSQL lookup support for Exim

We trust that you found our directions on how to enable proxy settings for Yum Command on AlmaLinux 9 simple and practical.

Now, we’d like to get your input.

Is there an aspect you feel we haven’t covered or a step that’s unclear and needs more detail? Are there other topics or guides you wish to see from us?

We’re eager to hear your thoughts. Please leave a comment below.

Leave a Comment