Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


LPI Linux Essentials Exam 010-160 - Topic 1.2 - Package Management Tools & Repositories

Linux distributions come with a default set of pre-installed applications and provide access to extensive software repositories via package managers. These package managers play a pivotal role in the Linux ecosystem, facilitating the installation, update, and removal of software packages. While Linux distributions often share common applications, the choice of package manager varies depending on the distribution's lineage.

Package Management Systems

In the exercises in this guide you will notice the -y flag being used when installing and removing a package. This is used to automatically answer yes to any prompts the command may issue. Typically you would answer yes to confirm the install or removal of software but it can also be to confirm security keys are correct.

Debian-Based Distributions

Debian-based distributions, such as Debian itself, Ubuntu, and Linux Mint, rely on a trio of tools for package management: dpkg, apt-get, and apt. These tools handle DEB packages, which are the standard package format for these distributions.

  • dpkg: Serving as the core package management utility, dpkg deals with individual Debian packages, facilitating their installation, removal, and maintenance.
  • apt-get and apt: These user-friendly commands complement dpkg by streamlining the management of packages, handling dependencies, and ensuring smooth updates.

The following exercises will get you practicing using the apt and apt-get commands:

Search for a Package:

Use the apt search command to search for a package. For example, you can search for the packages related to nginx.

apt search nginx

The output of the command will resemble:

Sorting... Done
Full Text Search... Done
...
...
nginx/jammy-updates 1.18.0-6ubuntu14.4 amd64
  small, powerful, scalable web/proxy server

nginx-common/jammy-updates 1.18.0-6ubuntu14.4 all
  small, powerful, scalable web/proxy server - common files

nginx-confgen/jammy 2.0-1 amd64
  nginx configuration file macro language and preprocessor

nginx-core/jammy-updates 1.18.0-6ubuntu14.4 amd64
  nginx web/proxy server (standard version)

nginx-doc/jammy-updates 1.18.0-6ubuntu14.4 all
  small, powerful, scalable web/proxy server - documentation

nginx-extras/jammy-updates 1.18.0-6ubuntu14.4 amd64
  nginx web/proxy server (extended version)

nginx-full/jammy-updates 1.18.0-6ubuntu14.4 amd64
  nginx web/proxy server (standard version with 3rd parties)

nginx-light/jammy-updates 1.18.0-6ubuntu14.4 amd64
  nginx web/proxy server (basic version)
...
...

Install a Package:

Use the apt-get command to install a package. For example, to install NGINX, run:

sudo apt-get -y install nginx

The output of the command will resemble:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libnginx-mod-http-geoip2 libnginx-mod-http-image-filter
  libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
  libnginx-mod-stream-geoip2 nginx-common nginx-core
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  libnginx-mod-http-geoip2 libnginx-mod-http-image-filter
  libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
  libnginx-mod-stream-geoip2 nginx nginx-common nginx-core
0 upgraded, 9 newly installed, 0 to remove and 5 not upgraded.
Need to get 697 kB of archives.
After this operation, 2,395 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-common all 1.18.0-6ubuntu14.4 [40.0 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-geoip2 amd64 1.18.0-6ubuntu14.4 [11.9 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-image-filter amd64 1.18.0-6ubuntu14.4 [15.4 kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-xslt-filter amd64 1.18.0-6ubuntu14.4 [13.7 kB]
Get:5 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-mail amd64 1.18.0-6ubuntu14.4 [45.7 kB]
Get:6 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream amd64 1.18.0-6ubuntu14.4 [72.9 kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream-geoip2 amd64 1.18.0-6ubuntu14.4 [10.1 kB]
Get:8 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-core amd64 1.18.0-6ubuntu14.4 [484 kB]
Get:9 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx amd64 1.18.0-6ubuntu14.4 [3,872 B]
Fetched 697 kB in 0s (2,400 kB/s) 
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 214498 files and directories currently installed.)
Preparing to unpack .../0-nginx-common_1.18.0-6ubuntu14.4_all.deb ...
Unpacking nginx-common (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-http-geoip2.
Preparing to unpack .../1-libnginx-mod-http-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../2-libnginx-mod-http-image-filter_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../3-libnginx-mod-http-xslt-filter_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../4-libnginx-mod-mail_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../5-libnginx-mod-stream_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package libnginx-mod-stream-geoip2.
Preparing to unpack .../6-libnginx-mod-stream-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package nginx-core.
Preparing to unpack .../7-nginx-core_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking nginx-core (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package nginx.
Preparing to unpack .../8-nginx_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking nginx (1.18.0-6ubuntu14.4) ...
Setting up nginx-common (1.18.0-6ubuntu14.4) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
Setting up libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
Setting up nginx-core (1.18.0-6ubuntu14.4) ...
 * Upgrading binary nginx                                                [ OK ] 
Setting up nginx (1.18.0-6ubuntu14.4) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for ufw (0.36.1-4ubuntu0.1) ...
Scanning processes...                                                           
Scanning linux images...                                                        

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

Remove a Package:

To remove a package, you can use the apt-get command as well. For instance, to remove NGINX, execute:

sudo apt-get -y remove nginx

The output of the command will resemble:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  nginx
0 upgraded, 0 newly installed, 1 to remove and 5 not upgraded.
After this operation, 50.2 kB disk space will be freed.
(Reading database ... 214586 files and directories currently installed.)
Removing nginx (1.18.0-6ubuntu14.4) ...

Red Hat-Based Distributions

Red Hat-based distributions such as Red Hat Enterprise Linux (RHEL), Fedora, and CentOS employ a different package management system based on the rpm, yum, and dnf commands. These commands work with RPM packages.

  • rpm: RPM is the foundational package management tool in this ecosystem, allowing users to interact with RPM packages directly.
  • yum and dnf: These user-friendly tools make software package installation, updates, and removal straightforward. They also excel at managing dependencies, ensuring system stability.

The following exercises will get you practicing using the dnf command:

Search for a Package:

Use the dnf search (or yum search) command to search for a package. For example, search for the package nginx.

dnf search nginx

The output of the command will resemble:

Not root, Subscription Management repositories not updated
Red Hat Enterprise Linux 9 for x86_64 - BaseOS  9.8 MB/s |  14 MB     00:01    
Red Hat Enterprise Linux 9 for x86_64 - AppStre  12 MB/s |  24 MB     00:02    
Last metadata expiration check: 0:00:03 ago on Sat 23 Sep 2023 15:29:14 BST.
========================= Name Exactly Matched: nginx ==========================
nginx.x86_64 : A high performance web server and reverse proxy server
======================== Name & Summary Matched: nginx =========================
nginx-all-modules.noarch : A meta package that installs all available Nginx
                         : modules
nginx-core.x86_64 : nginx minimal core
nginx-filesystem.noarch : The basic directory layout for the Nginx server
nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module
nginx-mod-http-perl.x86_64 : Nginx HTTP perl module
nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module
nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules
pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx
                      : Webserver

Install a Package:

Use the dnf command to install a package. For example, to install NGINX, run:

sudo dnf -y install nginx

The output of the command will resemble:

Updating Subscription Management repositories.
created by dnf config-manager from file:///loca 2.9 MB/s | 3.0 kB     00:00    
Puppet 8 Repository el 9 - x86_64               6.7 kB/s | 2.5 kB     00:00    
Puppet 8 Repository el 9 - x86_64               592 kB/s | 816 kB     00:01    
Red Hat Enterprise Linux 9 for x86_64 - BaseOS  8.1 kB/s | 4.1 kB     00:00    
Red Hat Enterprise Linux 9 for x86_64 - BaseOS  9.9 MB/s |  14 MB     00:01    
Red Hat Enterprise Linux 9 for x86_64 - AppStre  16 kB/s | 4.5 kB     00:00    
Red Hat Enterprise Linux 9 for x86_64 - AppStre  15 MB/s |  24 MB     00:01
================================================================================
 Package          Arch   Version         Repository                        Size
================================================================================
Installing:
 nginx            x86_64 1:1.20.1-14.el9 rhel-9-for-x86_64-appstream-rpms  43 k
Installing dependencies:
 nginx-core       x86_64 1:1.20.1-14.el9 rhel-9-for-x86_64-appstream-rpms 576 k
 nginx-filesystem noarch 1:1.20.1-14.el9 rhel-9-for-x86_64-appstream-rpms  13 k

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 632 k
Installed size: 1.7 M
Downloading Packages:
(1/3): nginx-filesystem-1.20.1-14.el9.noarch.rp  34 kB/s |  13 kB     00:00    
(2/3): nginx-1.20.1-14.el9.x86_64.rpm           100 kB/s |  43 kB     00:00    
(3/3): nginx-core-1.20.1-14.el9.x86_64.rpm      1.2 MB/s | 576 kB     00:00    
--------------------------------------------------------------------------------
Total                                           1.3 MB/s | 632 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: nginx-filesystem-1:1.20.1-14.el9.noarch                1/3 
  Installing       : nginx-filesystem-1:1.20.1-14.el9.noarch                1/3 
  Installing       : nginx-core-1:1.20.1-14.el9.x86_64                      2/3 
  Installing       : nginx-1:1.20.1-14.el9.x86_64                           3/3 
  Running scriptlet: nginx-1:1.20.1-14.el9.x86_64                           3/3 
  Verifying        : nginx-filesystem-1:1.20.1-14.el9.noarch                1/3 
  Verifying        : nginx-core-1:1.20.1-14.el9.x86_64                      2/3 
  Verifying        : nginx-1:1.20.1-14.el9.x86_64                           3/3 
Installed products updated.

Installed:
  nginx-1:1.20.1-14.el9.x86_64              nginx-core-1:1.20.1-14.el9.x86_64  
  nginx-filesystem-1:1.20.1-14.el9.noarch  

Complete!

Remove a Package:

To remove a package, use the dnf command. To remove Nginx, execute:

sudo dnf -y remove nginx

The output of the command will resemble:

Updating Subscription Management repositories.
Dependencies resolved.
================================================================================
 Package         Arch   Version         Repository                         Size
================================================================================
Removing:
 nginx           x86_64 1:1.20.1-14.el9 @rhel-9-for-x86_64-appstream-rpms 148 k
Removing unused dependencies:
 nginx-core      x86_64 1:1.20.1-14.el9 @rhel-9-for-x86_64-appstream-rpms 1.6 M
 nginx-filesystem
                 noarch 1:1.20.1-14.el9 @rhel-9-for-x86_64-appstream-rpms   0  

Transaction Summary
================================================================================
Remove  3 Packages

Freed space: 1.7 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: nginx-1:1.20.1-14.el9.x86_64                           1/3 
  Erasing          : nginx-1:1.20.1-14.el9.x86_64                           1/3 
  Running scriptlet: nginx-1:1.20.1-14.el9.x86_64                           1/3 
  Erasing          : nginx-core-1:1.20.1-14.el9.x86_64                      2/3 
  Erasing          : nginx-filesystem-1:1.20.1-14.el9.noarch                3/3 
  Running scriptlet: nginx-filesystem-1:1.20.1-14.el9.noarch                3/3 
  Verifying        : nginx-1:1.20.1-14.el9.x86_64                           1/3 
  Verifying        : nginx-core-1:1.20.1-14.el9.x86_64                      2/3 
  Verifying        : nginx-filesystem-1:1.20.1-14.el9.noarch                3/3 
Installed products updated.

Removed:
  nginx-1:1.20.1-14.el9.x86_64              nginx-core-1:1.20.1-14.el9.x86_64  
  nginx-filesystem-1:1.20.1-14.el9.noarch  

Complete!

SUSE-Based Distributions

SUSE-based distributions, including SUSE itself and OpenSUSE, utilize the ZYpp package management library along with its command-line tool, zypper, for comprehensive package, dependency, and repository management. ZYpp ensures that software management in SUSE-based distributions is efficient and reliable.

The following exercises will get you practicing using the zypper command:

Search for a Package:

Use the zypper search command to search for a package. For example, search for the package nginx.

sudo zypper search nginx

The output of the command will resemble:

Loading repository data...
Reading installed packages...

S | Name                          | Summary                                                                         | Type
--+-------------------------------+---------------------------------------------------------------------------------+--------
  | dehydrated-nginx              | Nginx Integration for dehydrated                                                | package
  | fcgiwrap-nginx                | System services for using fcgiwrap with nginx                                   | package
  | nginx                         | A HTTP server and IMAP/POP3 proxy server                                        | package
  | nginx-geolite-asn             | IP ASN geolocation databases for nginx                                          | package
  | nginx-geolite-city            | Free IP city geolocation databases for nginx                                    | package
  | nginx-geolite-country         | Free IP country geolocation databases for nginx                                 | package
  | nginx-macros                  | Just some macros to make packaging nginx and modules easier                     | package
  | nginx-module-brotli           | NGINX module for Brotli compression                                             | package
  | nginx-module-cookie-flag      | The Nginx module for adding cookie flag                                         | package
  | nginx-module-devel-kit        | Additional generic tools for nginx module development                           | package
  | nginx-module-devel-kit-source | The nginx-module-devel-kit source                                               | package
  | nginx-module-http-auth-digest | Digest Authentication for Nginx                                                 | package
  | nginx-module-set-misc         | Various set_xxx directives added to nginx's rewrite module                      | package
  | nginx-module-sticky-ng        | Nginx module to add a sticky cookie to be forwarded to the same upstream server | package
  | nginx-module-vts              | Nginx virtual host traffic status module                                        | package
  | nginx-source                  | The nginx source                                                                | package
  | pagure-web-nginx              | Nginx configuration for Pagure                                                  | package
  | pcp-pmda-nginx                | Performance Co-Pilot (PCP) metrics for the Nginx Webserver                      | package
  | python3-certbot-nginx         | Nginx plugin for Certbot                                                        | package
  | rubygem-passenger-nginx       | Passenger Nginx module                                                          | package

Install a Package:

Use the zypper command to install a package. To install NGINX, run:

sudo zypper install -y nginx

The output of the command will resemble:

Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  nginx

1 new package to install.
Overall download size: 703.3 KiB. Already cached: 0 B.
After the operation, additional 2.3 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): n
dtvlinux@localhost:~> man zypper
dtvlinux@localhost:~> sudo zypper install -y nginx
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  nginx

1 new package to install.
Overall download size: 703.3 KiB. Already cached: 0 B.
After the operation, additional 2.3 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving: nginx-1.21.5-150400.3.3.1.x86_64 (openSUSE-Leap-15.       (1/1), 703.3 KiB
Retrieving: nginx-1.21.5-150400.3.3.1.x86_64.   rpm ..............[done (3.1   MiB/s)]

Checking for file     conflicts: ...................   .........................[done]
/usr/sbin/useradd -r -c User for nginx -d /var/lib/nginx -U nginx -s /usr/sbin/nologin
(1/1) Installing: nginx-1.21.5-150400.3.3.1.    x86_64 .....................    [done]

Remove a Package:

To remove a package, use the zypper command. For example, to remove NGINX, execute:

sudo zypper remove -y nginx

The output of the command will resemble:

Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
  nginx

1 package to remove.
After the operation, 2.3 MiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
rm: cannot remove '/var/lib/systemd/migrated/nginx': No such file or directory
(1/1) Removing nginx-1.21.5-150400.3.3.1.   x86_64 ...........................   ..[done]

Understanding Repositories

A repository in the context of Linux package management is a centralized location or database where software packages are stored, organized, and made available for distribution. These repositories serve as the primary source for obtaining software packages for your Linux distribution.

Key points about repositories include:

  • Official Repositories:
    • Debian-Based Distributions: For Debian-based distributions like Debian itself, Ubuntu, and Linux Mint, official repositories are typically located at /etc/apt/sources.list. You can also find individual repository configuration files in /etc/apt/sources.list.d/.
    • Red Hat-Based Distributions: Red Hat-based distributions such as Red Hat Enterprise Linux (RHEL) and CentOS store official repository information in /etc/yum.repos.d/. Each repository configuration is typically stored in a separate .repo file within this directory.
    • SUSE-Based Distributions: SUSE-based distributions like openSUSE and SUSE Linux Enterprise use Zypper as their package manager. Official repositories are specified in files located within the /etc/zypp/repos.d/ directory.

These official repositories contain thoroughly tested and trusted software packages that are considered stable and safe for use on your system.

  • Third-Party Repositories: In addition to official repositories, you can often add third-party repositories to access a broader range of software. However, exercise caution when adding third-party repositories, as they may not undergo the same level of scrutiny and testing as official ones.
  • Package Metadata: Repositories not only store the software packages themselves but also include metadata about each package. This metadata contains information like package names, versions, descriptions, and dependencies. Package managers use this metadata to ensure that software is installed correctly and that all required dependencies are satisfied.
  • Package Signing: Security is a paramount concern in package management. To protect against tampering and ensure package integrity, repositories often use digital signatures. Package managers can verify these signatures to confirm the authenticity of packages before installation.
  • Updates and Maintenance: Repositories are regularly updated to include new software versions and security patches. Package managers can automatically fetch and apply these updates, keeping your system secure and up-to-date.

Understanding repositories and how they interact with package managers is essential for effective software management on your Linux system. While this diversity can seem daunting, most users can rely on their distribution's package manager to seamlessly handle installations, updates, and dependencies, ensuring a smooth and efficient Linux experience.


Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.