Introduction
The software management system in Linux system mainly includes software package management tools, software warehouses and related dependency management. The following is a detailed introduction:
Package Management Tools
-
dpkg: The underlying package management tool used by Debian and its derivative systems such as Ubuntu. It is used to install, uninstall, query and manage packages in .deb format. For example, use
dpkg -i
The command can install a package named . -
apt: A advanced software package management tool based on dpkg, providing more convenient command line interface and warehouse management functions. Can be passed
apt update
Command updates the package list, useapt install package_name
Command to install the package. -
rpm: A package management tool used by Red Hat and its derivative systems (such as CentOS, Fedora) to manage packages in the .rpm format. For example,
rpm -ivh
Commands can be used to install software packages. -
yum: a rpm-based package management tool that can automatically handle software package dependencies and download and install software packages from a specified software repository. The software package can be installed through yum install package_name, and yum update can be updated.
-
dnf: A new generation of package management tools, gradually replacing yum in systems such as Fedora. It has faster running speeds and cleaner command syntax, and features similar to yum, such as dnf install package_name for installing packages.
Software Repository
Official software repository: Officially maintained by the Linux distribution, it contains tested and certified software packages, with high stability and security. For example, Ubuntu's official software repository contains a large amount of open source software that users can easily obtain and install through the apt tool.
Third-party software warehouses: Some software developers or communities will provide their own software warehouses to facilitate users to obtain the latest version or specific software. For example, the official Google Chrome website provides a repository for Linux systems that users can add to the system and install and update through package management tools.
Dependency management
There may be a dependency between packages, i.e. one package needs to rely on other packages to run properly. Linux's software management system can automatically handle these dependencies. When installing a package using the package management tool, it checks the package's dependencies and automatically downloads and installs the required dependencies packages. For example, when installing a graphical application, you may need to rely on certain graphics libraries, which tools such as apt or yum will automatically recognize and install.
Software Compilation and Installation
In addition to using the package management tool to install the software, you can also compile and install the software from the source code. This method allows users to customize the software according to their needs, but requires users to have certain compilation knowledge and tools. Usually, you need to download the source code of the software first, then configure it using the configure script, then compile it using the make command, and finally install the software into the system using the make install command.
Linux package installation method
-
yum/apt:
yum/apt
The command downloads the software package from the network for us and installs it for us. If the software package has dependencies,yum/apt
It will also download and install for us, but it requires a network -
rpm/dpkg: manually download rpm/deb package,
rpm/dpkg
Command to install manually, if there is any dependency, manually resolve -
Binary software package: Similar to green software, decompression is ready to use, generally requires simple configuration, and if there is a dependency, you need to solve it yourself.
-
Compilation and installation: Download the software source code, configure, compile and install, highly customize, and solve your own dependency problems when you encounter them.
Software installation commandapt
apt is a commonly used advanced package management tool in Linux distributions such as Debian and Ubuntu. It is built on dpkg. It can automatically handle the dependencies between software packages, obtain and install software from the software repository.
Configure apt source
Replacing the apt source with domestic ones will help speed up when downloading and updating software packages.
refer to:/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11dJt3Ko
Taking Ubuntu22.04 as an example:
# Modify /etc/apt/file
vim /etc/apt/
# Replace the file content with the following
deb /ubuntu/ jammy main restricted universe multiverse
deb-src /ubuntu/ jammy main restricted universe multiverse
deb /ubuntu/ jammy-security main restricted universe multiverse
deb-src /ubuntu/ jammy-security main restricted universe multiverse
deb /ubuntu/ jammy-updates main restricted universe multiverse
deb-src /ubuntu/ jammy-updates main restricted universe multiverse
# deb /ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src /ubuntu/ jammy-proposed main restricted universe multiverse
deb /ubuntu/ jammy-backports main restricted universe multiverse
deb-src /ubuntu/ jammy-backports main restricted universe multiverse
Apt query software
Query all installed software
apt list
# Query all installed software
apt list --installed
# Query upgradeable packages
apt list --upgradable
Query the specified installation package
# Search for installed software packages and search for fuzzy based on keywords
apt search [keywords]
# View the detailed information of the specified software package and view the detailed information of the specified software package, such as version, dependencies, etc.
apt show [package_name]
# Example apt show [package_name]
root@master:~$ apt show nginx
Package: nginx
Version: 1.24.0-2ubuntu7.3
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@>
Original-Maintainer: Debian Nginx Maintainers <pkg-nginx-maintainers@>
Bugs: /ubuntu/+filebug
Installed-Size: 1352 kB
Provides: httpd, httpd-cgi, nginx-abi-1.24.0-1
Depends: libc6 (>= 2.34), libcrypt1 (>= 1:4.1.0), libcre2-8-0 (>= 10.22), libssl3t64 (>= 3.0.0), zlib1g (>= 1:1.1.4), iproute2, nginx-common (= 1.24.0-2ubuntu7.3)
Breaks: nginx-core (<< 1.22.1-6~), nginx-extras (<< 1.22.1-6~), nginx-light (<< 1.22.1-6~)
Replaces: nginx-core (<< 1.22.1-6~), nginx-extras (<< 1.22.1-6~), nginx-light (<< 1.22.1-6~)
Homepage:
Download-Size: 520 kB
APT-Sources: /ubuntu noble-updates/main amd64 Packages
Description: small, powerful, scalable web/proxy server
Nginx ("engine X") is a high-performance web and reverse proxy server
created by Igor Sysoev. It can be used both as a standalone web server
and as a proxy to reduce the load on back-end HTTP or mail servers.
Apt installation software
useapt install
Can install software, there is-y
The function is to automatically answer all queries as "yes" to avoid interactive confirmation prompts during execution.
Usage example:
# Install nginx
apt install -y nginx
# Batch installation
apt install -y nginx git jdk
Clean the cache and reinstall it
Sometimes, corrupt packages can be caused by corruption of cache files. You can clean apt's cache and reinstall the package in question.
# Clean the cache
apt clean
# Reinstall
apt install --reinstall [package_name]
Apt update software
Update the package list to ensure that the latest package information is obtained. This helps solve problems caused by outdated package information.
# Update all package list
apt update -y
Upgrade the software package
# Upgrade all installed packages
apt upgrade -y
# Upgrade the specified package
apt upgrade [pakage_name]
# The system is fully upgraded, not only will the installed software packages be updated, but it will also handle software packages that need to be upgraded due to dependency changes.
apt full-upgrade
Apt uninstall software
Uninstall package: Uninstall the package but retains the configuration file.
apt remove package_name
Completely uninstalling the package: both uninstalling the package and also deleting its configuration files.
apt purge package_name
Apt cleaning software
Clean up the cache: Delete all downloaded package files in the /var/cache/apt/archives directory to free up disk space.
apt clean
Automatic cleaning: Only delete package files that can no longer be downloaded.
apt autoclean
Automatic removal: Removes dependency packages that are no longer needed due to uninstallation of other packages.
sudo apt autoremove
dpkg
dpkg
It is the underlying package management tool used by Debian and its derivative systems (such as Ubuntu), which is mainly used for management.deb
Format package
dpkg installation software package
use-i
Options can install the specified.deb
Package.
# Need to be replaced with the actual package file name. However, the package dependencies are not automatically processed when dpkg is installed, and the installation may fail if the package has unmet dependencies.
dpkg -i
Uninstall software package of dpkg
Remove package: Use-r
Options can remove the specified package, but retain its configuration file.
dpkg -r package_name
use-P
Options can completely remove packages and their configuration files.
dpkg -P package_name
dpkg query package
List installed packages
use-l
Options can list all installed packages in the system, or specific packages can be listed by specifying the package name or wildcard character.
# List all installed packages
dpkg -l
# Query the specified package
dpkg -l nginx
View package details:-s
Options can view the detailed information of the specified software package, including version, status, dependencies, etc.
dpkg -s package_name
Find the package to which the file belongs: Use the -S option to find which package the specified file is installed by.
dpkg -S /path/to/file
yum and rpm will be written to it if you have time.