Getting started with Linux software package management
Most modern Unix-like operating systems provide a centralized software package management mechanism to help users search, install and manage software. Software is usually stored in the repository "repository" in the form of "packages". The use and management of software packages is called package management. The basic components of a Linux package include shared libraries, applications, services, and documents.
Package management is generally not limited to one-time installation of software, but also includes tools for upgrading installed software packages. The package repository helps ensure that the code has been reviewed on the system you are using and managed by software developers or package maintainers.
When configuring a Linux server or development environment, it is generally not limited to official sources. Compared with the current fast update iteration of software versions, although the stable version software package used by official sources may be outdated, for system administrators and developers, mastering the basic operations of common Linux package management is still a required common skill.
This article describes the basic methods and quick reference for package management such as search, installation, and upgrade in common Linux distributions. It helps you quickly learn the basic operations and skills of Linux package management.
Software Package Management System: Brief Introduction
Most package management systems are built on a collection of package files. Package files usually contain compiled binary files and other resources: software, installation scripts, metadata, and the list of dependencies required.
Although most popular Linux distributions share similar package management tools, methods, and forms, there are still platform differences:
| System |
Format |
Tools |
| Debian |
. Deb |
Apt, apt-cache, apt-get, and dpkg |
| Ubuntu |
. Deb |
Apt, apt-cache, apt-get, dpkg |
| CentOS |
. Rpm |
Yum |
| Fedora |
. Rpm |
Dnf |
The package formats of Debian and its derivatives such as Ubuntu, Linux Mint, and Raspbian are. deb files. APT is the most common package Operation Command and can be searched for libraries, installation packages, dependencies, and management upgrades. To directly install the ready-made. deb package, run the dpkg command.
CentOS, Fedora, and Red Hat Linux use RPM package files and yum commands to manage package files and interact with software libraries.
In the latest Fedora version, the yum command has been replaced by dnf for package management.
Update the local package database list
Most Linux systems use local databases to store the list of remote available package repositories. Therefore, you are advised to update the database before installing or upgrading the package.
| System |
Command |
| Debian/Ubuntu |
Sudo apt-get update |
| CentOS |
Yum check-update |
| Fedora |
Dnf check-update |
Upgrade installed packages
When there is no package management method, you need to upgrade and keep the installed software in Linux to the latest version, which is a huge project. Administrators and Users have to manually track upstream software version changes and security warnings. With the package management system, you only need a few commands to keep the software up to date.
| System |
Command |
Remarks |
| Debian/Ubuntu |
Sudo apt-get upgrade |
Upgrade only installed software packages |
| |
Sudo apt-get dist-upgrade |
You can add or delete packages to meet new dependencies. |
| CentOS |
Sudo yum update |
|
| Fedora |
Sudo dnf upgrade |
Search for software packages
Most Linux Desktop versions provide interfaces for users to search for and install software packages. This is the best way to find and install software. However, for efficiency and server administrators, using the command line tool to find/search for software packages is the right path.
| System |
Command |
Remarks |
| Debian/Ubuntu |
Apt-cache search content |
|
| CentOS |
Yum search content |
|
| |
Yum search all search content |
Search for all content, including the package description. |
| Fedora |
Dnf search content |
|
| |
Dnf search all search content |
Search for all content, including the package description. |
View information about a software package
Before deciding which package to install, we usually need to view the detailed description of the package. The package description file usually contains metadata such as the package name, version number, and dependency list. You can run the following command to view the metadata.
| System |
Command |
Remarks |
| Debian/Ubuntu |
Apt-cache show package name |
Displays local cache information about the software package |
| |
Dpkg-s package name |
Displays the package's current installation status |
| CentOS |
Yum info package name |
|
| |
Yum deplist package name |
Since the package is listed |
| Fedora |
Dnf info package name |
|
| |
Dnf repoquery-requires package name |
Since the package is listed |
Install the package from the software warehouse
Once we know the name of a software package, we can use the following command to install the package from the software repository.
| Debian/Ubuntu |
Sudo apt-get install package name |
|
| |
Sudo apt-get install Package 1 package 2... |
Install all listed packages |
| |
Sudo apt-get install-y package name |
Installation Without prompt |
| CentOS |
Sudo yum install package name |
|
| |
Sudo yum install Package 1 package 2... |
Install all listed packages |
| |
Sudo yum install-y package name |
Installation Without prompt |
| Fedora |
Sudo dnf install package name |
|
| |
Sudo dnf install Package 1 package 2... |
Install all listed packages |
| |
Sudo dnf install-y package name |
Installation Without prompt |
Directly install the installation package from the local file system
Most of the time, we need to directly install the package from the local file system after testing or getting the software package from somewhere. Debian and derivative systems can be installed using dpkg, and CentOS and Fedora systems can be installed using yum and dnf commands.
| System |
Command |
Remarks |
| Debian/Ubuntu |
Sudo dpkg-I package name. deb |
|
| |
Sudo apt-get install-y gdebi & sudo gdebi package name. deb |
Use gdebi to retrieve missing Dependencies |
| CentOS |
Sudo yum install package name. rpm |
|
| Fedora |
Sudo dnf install package name. rpm |
Remove installed packages
Because the package manager knows which files are provided by which package, a clean system can be obtained after uninstalling unnecessary software packages.
| System |
Command |
Remarks |
| Debian/Ubuntu |
Sudo apt-get remove package name |
|
| |
Sudo apt-get autoremove |
Automatically remove unnecessary packages |
| CentOS |
Sudo yum remove package name |
|
| Fedora |
Sudo dnf erase package name |
Now, this article introduces the common basic operations of Linux release package management to help new users get started faster and get started faster when switching to the Linux release version.
This article permanently updates the link address: