包阅导读总结
1.
关键词:Linux 软件管理、包管理器、软件编译、软件仓库、发行版
2.
总结:本文介绍了 Linux 软件管理的多种方式,包括不同发行版的包管理器(如 RPM、YUM、DNF、APT、Zypper),还讲解了软件包仓库及从源代码编译软件的方法,强调要根据发行版选择合适的软件管理方式。
3.
主要内容:
– 引言
– Linux 软件管理方式灵活多样,本文重点介绍命令行包管理器。
– 包管理器的差异
– 不同 Linux 发行版有各自的包管理器。
– 常见的包管理器如源于 Red Hat 的 RPM、YUM、DNF,源于 Debian 的 APT,以及 SUSE 的 Zypper。
– 介绍了它们的安装、删除、更新和获取信息等命令。
– 软件包仓库
– 发行商和开发者将软件包存于在线仓库。
– 可编辑配置文件管理仓库。
– 软件编译
– Linux 用户可从源代码编译软件。
– 开源软件允许获取和修改源代码。
– 编译步骤包括解压、配置、编译和安装。
– 总结
– 管理 Linux 软件先确定发行版的包管理器,学会基本操作,保持软件更新。
思维导图:
文章地址:https://thenewstack.io/how-to-manage-linux-software/
文章来源:thenewstack.io
作者:Damon M. Garn
发布时间:2024/8/2 20:22
语言:英文
总字数:1816字
预计阅读时间:8分钟
评分:88分
标签:Linux,包管理器,系统管理,Red Hat,Debian
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
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
Three of the most common package managers derive from Red Hat Linux, Debian Linux, and SUSE Linux. The Red Hat approach includes several tools, while the Debian software manager relies on one primary utility.
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 |
The additional flags run the command in verbose mode (–v ) and show a progress bar (–h).
Display version and source information for a package using the–q (query) and–i (information) flags.
$ 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 |
Get information about an installed package with thisyum command:
$ sudo yum info package.rpm |
Theyum command also recognizes theupdate andupgrade commands for when you need to bring an older software package current.
$ 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 thednf repolist subcommand:

Figure 2: Display a list of configured repositories with the dnf repolist command.
Here are examples of installing and removing software using thednf command:
$ sudo dnf install package.rpm |
$ sudo dnf remove package.rpm |
You’ll often need to update installed software. Use theupgrade subcommand withdnf:
$ sudo dnf upgrade package.rpm |
How do you know if a package needs an update? You can use theinfo subcommand to display package information, including version. Compare that against the vendor’s latest version.
$ sudo dnf info package.rpm |

Figure 3: Partial output from the dnf info command.
DNF has many other interesting subcommands. Trydnf history to see what DNF commands you’ve run in the past. Typednf upgrade to upgrade all packages that have upgrades available. Search for information about a package without installing it by typingdnf search packagename.
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:
To install or remove software with theapt command, type:
$ sudo apt install package.deb |
$ sudo apt remove package.deb |

Figure 4: Use the apt install command to add a package.
Theupgrade subcommand brings existing packages current. You can also use theinfo subcommand to display information about a particular 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 thezypper refresh command to accomplish this:
Zypper uses the same two subcommands as DNF and APT to add or remove software:
$ sudo zypper install package |
$ sudo zypper remove package |
Bring the installed packages current by using theupdate subcommand:
Theinfo subcommand displays package details:
$ 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.
Some organizations also maintain repositories on site or on removable media for better control of software versions.
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 |
The Nmap vendor provides the above instructions.
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 YouTubechannel to stream all our podcasts, interviews, demos, and more.