Software package management in linux

LFCA: How to Manage Software Packages in Linux – Part 7

This article is Part 7 of the LFCA series, here in this part, you will acquaint yourself with the general system administration commands to manage software packages in the Linux system.

As a systems administrator, you will be tasked with the responsibility of managing software packages. This includes installing, upgrading, and removing or uninstalling packages from your system.

There are two types of packages in a Linux system:

  • Binary packages: These contain configuration files, executables, man pages among other documentation. For Debian, the binary packages have a .deb file extension. For Red Hat, the binary packages bear a .rpm file extension. Binary packages are unpacked using the Debian utility dpkg – For .deb binary files and rpm for .rpm binary packages as we shall see later on.
  • Source packages: A source package is a compressed file that contains the source code of the application, a brief description of the package, and instructions on how to build the application.

Different Linux distributions have their own package managers and here, we are going to look at 2 Linux families: Debian and Red Hat.

Debian Package Management

Debian provides APT (Advanced Package Manager) as a front-end package management solution. It’s a powerful command-line utility that works with core libraries and allows you to download, install, update and remove packages from your system.

Install a Package in Debian/Ubuntu Systems

If you are coming from a Windows environment, you are used to downloading a .exe package from a software vendor and running it on your system using an installation Wizard.

In Linux, installing an application is quite different. Software packages are downloaded and installed from online repositories using a package manager. The list of repositories is defined in the /etc/apt/sources.list file and /etc/sources.list.d directory.

On Debian-based distributions, the APT package manager is used to download and install packages from the online repositories. Not only does it install a package but also the dependencies required by the packages

It’s always recommended to update the repositories in the /etc/apt/sources.list file before installing any package. To accomplish this, run the command:

To install a software package, use the syntax:

$ sudo apt install package_name

For example, to install Apache web server, run the command:

Читайте также:  Developing windows applications in linux

Install Apache in Ubuntu

Search a Package Before Installing

To search for the availability of a package in the repositories, use the syntax:

For example, to search for the availability of the package called neofetch, run the command:

Search for Package in Ubuntu

Show Information of Package

To display more information about a package, use the apt command as follows.

For example, to reveal more information about the neofetch package, run:

Check Package Info in Ubuntu

Upgrade Packages in Ubuntu

To upgrade the installed packages on your system run the command:

Remove Package in Ubuntu

To remove a software package, say apache2 run the command:

To remove the package alongside the configuration files use the purge option as shown.

The Dpkg Package Manager

Debian-based Linux distributions also offer the dpkg package manager. This is a low-level package manager that handles binary packages that do not require any dependencies during installation. If dpkg detects that a binary package file requires dependencies, it reports the missing dependencies and halts.

To install a package from a .deb file use the dpkg command as follows:

For example, to install the AnyDesk package from its Debian file shown, execute:

$ sudo dpkg -i anydesk_6.1.0-1_amd64.deb OR $ sudo dpkg --unpack anydesk_6.1.0-1_amd64.deb

Install Package in Ubuntu

To check if the package was installed, run the command:

Verify Package in Ubuntu

To remove the package, use the -r option as shown:

Remove Package in Ubuntu

To remove the package alongside all its configuration files, use the -P option for purging all the files associated with the package.

YUM / DNF and RPM Package Management

Modern RedHat Linux distributions such as RHEL & CentOS 8 and Fedora 21 and later versions use DNF (Dandified YUM) which is an upgrade of the now deprecated YUM package manager, which was the de facto package manager for older versions of Red Hat Linux distributions such as RedHat and CentOS 7.

Just like APT, the DNF or YUM package managers are used to install packages from online repositories.

Install Software Packages in CentOS

To install a package, use the syntax:

$ sudo dnf install package-name OR $ sudo yum install package-name (For older versions)

For instance, to install the Apache httpd package, run the command:

$ sudo dnf install httpd OR $ sudo yum install httpd

Search for a Software Package

You can also search for the availability of a package from the repositories as follows:

Update Software Packages

To update all packages to their latest version execute:

$ sudo dnf update OR $ sudo yum update

Remove Software Package

$ sudo dnf remove package_name OR $ sudo yum remove package_name

For example, to remove the httpd package, run

$ sudo dnf remove httpd OR $ sudo yum remove httpd

The RPM Package Manager

The rpm package manager is another open-source package management tool for handling .rpm binary packages on RedHat Linux distributions. Just like APT package manager rpm manages binary packages.

Читайте также:  Лучшие аудиоплееры для linux

Install Software Package

To install an application using a .rpm file, use the syntax below:

For instance, to install the AnyDesk application from the .rpm file shown, run the command:

$ sudo rpm -i anydesk-6.1.0-1.el8.x86_64.rpm

To verify or check the presence of a software application on your system use the syntax:

For instance, to check if Anydesk is installed, run the command:

Verify Package Installation

To query all the present software packages, use the command:

Query Software Packages

Remove Software Package

To uninstall a package using the rpm command use the syntax:

Conclusion

The apt, dpkg, rpm, dnf, and yum commands are handy command-line tools that can help you to install, update and remove software packages on your Linux system.

Источник

Linux package management with YUM and RPM

Gift package wrapped in purple with lavender ribbon

Installing, patching, and removing software packages on Linux machines is one of the common tasks every sysadmin has to do. Here is how to get started with Linux package management in Linux Red Hat-based distributions (distros).

Package management is a method of installing, updating, removing, and keeping track of software updates from specific repositories (repos) in the Linux system. Linux distros often use different package management tools. Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

Yellow Dog Updater, Modified (YUM)

[ Editor’s Note: DNF or Dandified YUM is the updated default since Red Hat Enterprise Linux 8, CentOS 8, Fedora 22, and any distros based on these. Generally, the options are the same. Read more about DNF here. ]

YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM performs dependency resolution when installing, updating, and removing software packages. YUM can manage packages from installed repositories in the system or from .rpm packages. The main configuration file for YUM is at /etc/yum.conf , and all the repos are at /etc/yum.repos.d .

You can learn more about adding repositories to your system from this article on how to add a YUM repo from Amy Marrich.

It’s easy to manage packages in Linux with YUM . At the command line, enter:

There are many options and commands available to use with YUM . I’ve listed some commonly-used commands for YUM below:

Command Purpose
yum install Installs the specified packages
remove Removes the specified packages
search Searches package metadata for keywords
info Lists description
update Updates each package to the latest version
repolist Lists repositories
history Displays what has happened in past transactions
Читайте также:  Linux boot error grub

The following are commonly-used options with YUM :

Options Purpose
-C Runs from system cache
—security Includes packages that provide a fix for a security issue
-y Answers yes to all questions
—skip-broken Skips packages causing problems
-v Verbose

The history option gives you an overview of what happened in past transactions. This provides some useful information, like the date when the transaction happened and what command was run.

yum-history

You can undo or redo certain transactions using the history command. Here is an example of undoing a transaction:

YUM provides many options for package management. For detailed option information, look at man yum and yum –help . Also, here is a link to YUM documentation.

RPM is a popular package management tool in Red Hat Enterprise Linux-based distros. Using RPM , you can install, uninstall, and query individual software packages. Still, it cannot manage dependency resolution like YUM . RPM does provide you useful output, including a list of required packages. An RPM package consists of an archive of files and metadata. Metadata includes helper scripts, file attributes, and information about packages.

RPM maintains a database of installed packages, which enables powerful and fast queries. The RPM database is inside /var/lib , and the file is named __db* .

RPM has some basic modes: query, verify, install, upgrade, erase, show querytags, show configuration. At least one of these modes needs to be selected to perform package management tasks. Every mode has its own set of options. For example, install mode i has its own set of installation options. Options for the modes are found on the RPM man pages at man rpm .

Some commonly-used modes are listed below:

Mode Description
-i Installs a package
-U Upgrades a package
-e Erases a package
-V Verifies a package
-q Queries a package

Here are some commonly-used general options:

General options Purpose
-? | —help Prints help
—version Prints version number
-v Prints verbose output

To install or upgrade an .rpm package using RPM, issue this command:

The flag -i is for install, U is for upgrade, v for verbose, h for hash (this option displays the # as a progress bar for the operation). In this example, v and h are optional flags.

rpm-ivh

To query for a package using RPM issue following command:

rpm -q query-options package

Option a queries all installed packages on the system.

rpm-qa

To erase a package, use the following command:

rpm -e erase-options package-name

rpm-evh

Package management is a common task for every system. YUM and RPM provide efficient ways to install, upgrade, remove, and track software packages on Red Hat Enterprise Linux systems.

[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]

Источник

Оцените статью
Adblock
detector