How to Manage Linux Software
This article explains the role of command-line package managers, examines the package manager options for various distributions and demonstrates how to manage software with some of the most common tools.
Aug 4th, 2024 12:00pm by
Feature image via Unsplash.
This article on services fits into a larger series of Linux articles covering various sysadmin topics, including hardware identification and managing system processes. You can build a lab environment by following the information in the Linux: Companion Lab for Linux Skill Blocks Repository article. In this series, we also covered how to pick a distribution and installation platform, how the Linux kernel interacts with hardware and how Linux manages system services, storage, file permissions, system processes, and user and group permissions.
Windows and macOS tend to have just one or two ways of managing software, but Linux offers far more flexibility and freedom. Many applications are compiled directly from the source code, while others are packaged and handled by various package managers. Several distributions have their own preferred package manager, while some rely on package managers developed by other distributions.
This article explains the role of command-line package managers, examines the package manager options for various distributions and demonstrates how to manage software with some of the most common tools.
Package managers are one of the easiest differentiators between Linux distributions. Some distributions use their own package managers to handle software maintenance, though most use package managers derived from either the Red Hat or Debian approaches.
Linux installations that use a graphical user interface (GUI) usually also contain a mouse-driven tool for installing, updating and removing software. This article focuses on command-line package managers, which are often faster and more flexible.
Another unique aspect of Linux software management is compiling applications from source code. Linux software usually falls under an open-source license, meaning you have direct access to the programming code. That allows you to alter the code or customize the program before compiling and installing it, a capability not usually available for Windows or macOS software.
Note: It is poor security practice to log on to a Linux system as the root (administrator) user. Most systems force you to log on as a regular user and then use the sudo (super user do) command to elevate your privileges. You may be prompted for your password when using sudo.
Package Managers Differ Among Distributions
Various Linux distributions developed their own software package managers. You’ll need to learn to use the preferred package manager for your chosen distro. While the specific commands vary among package managers, the general concepts are the same. Package managers typically handle the following software maintenance tasks:- Inventory software, including version information
- Display software information
- Install software
- Update software
- Remove software
Use RPM
The Red Hat Package Manager (RPM) has a long history with many Linux distributions, including Red Hat Linux, Red Hat Enterprise Linux, Fedora and others. It’s a command-line tool with extensive options for modifying its use. The following two rpm subcommands install (-i ) and remove (-e ) software:
$ sudo rpm -ivh package.rpm
$ sudo rpm -evh package.rpm
$ sudo rpm -qi package.rpm
Figure 1: Use the rpm -qi option to display package information, including version.
Use YUM
For many years, Red Hat and other distributions relied on the Yellowdog Updater Modified (YUM) package manager. It works with the same .rpm packages and offers similar features. However, it also includes more extensible features. Type these two yum commands to install or remove software:
$ sudo yum install package.rpm
$ sudo yum remove package.rpm
$ sudo yum info package.rpm
$ sudo yum update package.rpm
Use DNF
Today’s Red Hat-derived distributions use the Dandified YUM (DNF) package manager. It provides the same basic functionality as YUM and RPM, though it offers faster dependency resolution and runs quicker. The base command is dnf. Display the configured software repositories using the dnf repolist subcommand:
$ sudo dnf repolist
Figure 2: Display a list of configured repositories with the dnf repolist command.
$ sudo dnf install package.rpm
$ sudo dnf remove package.rpm
$ sudo dnf upgrade package.rpm
$ sudo dnf info package.rpm
Figure 3: Partial output from the dnf info command.
Use APT
The Debian Linux distribution is nearly as old as Linux itself. The developers at Debian created a package manager early on, and its descendants are still in use today. The modern version of Debian’s package manager is the Advanced Packaging Tool (APT). You’ll use it with Debian, Ubuntu, Mint and many other popular Linux distributions. APT provides similar functionality to RPM, YUM and DNF. It installs, removes, updates and reports on software packages containing the .deb file extension. You’ll need to update the package manager repository information to access the most recent packages. The related apt command is:
$ sudo apt update
$ sudo apt install package.deb
$ sudo apt remove package.deb
Figure 4: Use the apt install command to add a package.
Figure 5: The apt info command displays package information, including version.
Use Zypper
OpenSUSE Linux and SUSE Linux Enterprise Server use the Zypper command-line package manager. Managing software from the command line allows for scripting, consumes fewer resources and works on Linux servers without a graphical user interface (GUI), which is common. Zypper works with RPM packages, but the package manager itself is fundamentally different. The parent command is zypper. It’s a good practice to refresh the package manager with current remote repository information before installing or updating packages. Use the zypper refresh command to accomplish this:
$ sudo zypper refresh
$ sudo zypper install package
$ sudo zypper remove package
$ sudo zypper update
$ sudo zypper info package
What Are Software Package Repositories?
Distribution vendors and software developers store available packages in online repositories. Your package management software automatically searches these repositories when you attempt to install or update an application. You can edit the package manager’s configuration files to add or remove repositories. For example, you can manage the repositories DNF will pull software from by editing the /etc/dnf/dnf.conf file. The similar configuration file for APT repositories is /etc/apt/sources.list .
Figure 6: The /etc/apt/sources.list file contains package repository information.
What About Compiling Software?
Linux users have another software management option that is less common for Windows or macOS folks. Linux users often compile applications from the original source code. The three-step process is relatively straightforward but may seem intimidating at first. Most software developed for Windows and macOS systems is closed-source, meaning the licensing does not allow access to the original source code. It also does not allow that code to be modified. Open-source software makes the original code available to anyone. Furthermore, anyone can change the source code and release their changes. This approach allows open-source software to evolve quickly and embrace new ideas. Some application developers will compile and package the code using one of the packaging approaches discussed earlier. Others let end-users do it. Most provide both options. Users might choose to compile software themselves for several reasons, including those listed below:- Get cutting-edge software for testing or beta use.
- Customize the software in ways packaged software can’t be.
- Obtain software not packaged for their chosen distribution.
How to Compile Software
Many software developers provide specific instructions for compiling their software. Here are the instructions for compiling Nmap, a popular network analysis tool:
bzip2 -cd nmap-7.95.tar.bz2 | tar xvf -
cd nmap-7.95
./configure
make
su root
make install
Wrap Up
The first step with managing Linux software is recognizing which package manager application your distribution uses. There’s a good chance it is DNF or APT, but many other options exist. These options may seem confusing compared to other operating systems, but they quickly become second nature. Once you know your system’s package manager, learn the basic commands for installing, updating and removing software. Remember to use the package manager to keep track of version numbers and other information about the software. Keeping software current increases your system’s security and ensures you have the most current software features. Linux users have another option. They can compile applications directly from the open-source code, enabling access to new features and additional customization. Compiling software may seem intimidating, but it is actually pretty easy. Check your selected distribution’s preferred package manager and begin updating your software for security and feature enhancements. Then use a lab environment and a few other distributions to learn more about the various types of Linux package managers.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.