Introduce the installation package management tools of common Linux operating systems, and mainly introduce their usage commands!
In addition to installing software, a package management system provides tools to update already installed packages. Package repositories help ensure that the code used in your system is reviewed and the installed version of the software has been approved by developers and package maintainers.
1. dpkg
Ubuntu, Debian
dpkg
Commands are Debian Linux
utilities that the system uses to install, create, and manage software packages.
-
command line usage
# dpkg(选项)(参数)
$ dpkg --help
Usage: dpkg [<option> ...] <command>
# 选项
-i:安装软件包
-r:删除软件包
-P:删除软件包的同时删除其配置文件
-L:显示于软件包关联的文件
-l:显示已安装软件包列表
--unpack:解开软件包
-c:显示软件包内文件列表
--confiugre:配置软件包
# 参数
Deb软件包:指定要操作的.deb软件包
-
example presentation
# 安装包
$ dpkg -i package.deb
# 删除包
$ dpkg -r package
# 删除包(包括配置文件)
$ dpkg -P package
# 列出与该包关联的文件
$ dpkg -L package
# 显示该包的版本
$ dpkg -l package
# 解开deb包的内容
$ dpkg --unpack package.deb
# 搜索所属的包内容
$ dpkg -S keyword
# 列出当前已安装的包
$ dpkg -l
# 列出deb包的内容
$ dpkg -c package.deb
# 配置包
$ dpkg --configure package
# 列出已安装软件包
$ sudo dpkg-query -l
$ sudo dpkg-query -l | less
$ sudo dpkg-query -l | grep tmux
2. apt
Ubuntu, Debian
apt-get
Command is Debian Linux
the APT package management tool in the distribution. All based Debian
distributions use this package management system. deb
A package wraps an application's files together, much like Windows
the installation files above.
-
command line usage
# apt-get(选项)(参数)
$ apt --help
Usage: apt [options] command
# 选项
-c:指定配置文件
# 参数
管理指令:对APT软件包的管理操作
软件包:指定要操纵的软件包
-
example presentation
# 更新所有已安装的软件包
$ apt-get upgrade
# 将系统升级到新版本
$ apt-get dist-upgrade
# 更新
$ apt-get update
# 安装一个新软件包
$ apt-get install packagename
# 卸载一个已安装的软件包(保留配置文件)
$ apt-get remove packagename
# 卸载一个已安装的软件包(删除配置文件)
$ apt-get –purge remove packagename
# 来删除你已经删掉的软件
$ apt-get autoclean apt
# 会把安装的软件的备份也删除
$ apt-get clean
# 列出已安装软件包
$ sudo apt list --installed
$ sudo apt list --installed | less
$ sudo apt list --installed | grep tmux
3. rpm
RHEL, CentOS
rpm
Commands are RPM
management tools for packages. rpm
Originally a program used by Red Hat Linux
distributions to manage Linux
various suites, GPL
it is very popular because it follows the rules and is powerful and convenient. Gradually adopted by other distributions. RPM
The emergence of the package management method makes it Linux
easy to install and upgrade, and indirectly improves the Linux
applicability.
-
command line usage
# rpm(选项)(参数)
$ rpm --help
Usage: rpm [OPTION...]
# 选项
-a:查询所有套件
-c:只列出组态配置文件,本参数需配合"-l"参数使用
-d:只列出文本文件,本参数需配合"-l"参数使用
-e<套件档>或--erase<套件档>:删除指定的套件
-f<文件>+:查询拥有指定文件的套件
-h或--hash:套件安装时列出标记
-i:显示套件的相关信息
-i<套件档>或--install<套件档>:安装指定的套件档
-l:显示套件的文件列表
-p<套件档>+:查询指定的RPM套件档
-q:使用询问模式,当遇到任何问题时,rpm指令会先询问用户
-R:显示套件的关联性信息
-s:显示文件状态,本参数需配合"-l"参数使用
-U<套件档>或--upgrade<套件档>:升级指定的套件档
-v:显示指令执行过程
-vv:详细显示指令执行过程,便于排错
# 参数
软件包:指定要操纵的rpm软件包
-
example presentation
# 安装
$ rpm -ivh your-package.rpm
# 强制安装
$ rpm --force -ivh your-package.rpm
# 卸载
$ rpm -e proftpd-1.2.8
# 列出所有安装过的包
$ rpm -qa
$ rpm -qa | grep sql
# rpm包中的文件安装到那里
$ rpm -ql ***.rpm
# 一个没有安装过的软件包
$ rpm -qlp ***.rpm
# 一个已经安装过的软件包
$ rpm -ql ***.rpm
# 某个程序是哪个软件包安装
$ rpm -qf `which 程序名` # 返回软件包的全名
$ rpm -qif `which 程序名` # 返回软件包的有关信息
$ rpm -qlf `which 程序名` # 返回软件包的文件列表
4. yum
CentOS6, CentOS7
yum
Command is a package manager based in Fedora
and RedHat
and in, which enables system administrators to update and manage software packages interactively and automatically, can automatically download and install packages from specified servers, can automatically handle dependencies, and install in one go All dependent software packages do not need to be downloaded and installed again and again.SUSE
rpm
RPM
RPM
-
command line usage
# yum(选项)(参数)
$ yum --help
Loaded plugins: fastestmirror, langpacks
Usage: yum [options] COMMAND
# 选项
-h:显示帮助信息;
-y:对所有的提问都回答“yes”;
-c:指定配置文件;
-q:安静模式;
-v:详细模式;
-d:设置调试等级(0-10);
-e:设置错误等级(0-10);
-R:设置yum处理一个命令的最大等待时间;
-C:完全从缓存中运行,而不去下载或者更新任何头文件。
# 参数
install:安装rpm软件包;
update:更新rpm软件包;
check-update:检查是否有可用的更新rpm软件包;
remove:删除指定的rpm软件包;
list:显示软件包的信息;
search:检查软件包的信息;
info:显示指定的rpm软件包的描述信息和概要信息;
clean:清理yum过期的缓存;
shell:进入yum的shell提示符;
resolvedep:显示rpm软件包的依赖关系;
localinstall:安装本地的rpm软件包;
localupdate:显示本地rpm软件包进行更新;
deplist:显示rpm软件包的所有依赖关系。
-
example presentation
# 安装
$ yum install # 全部安装
$ yum install package1 # 安装指定的安装包package1
$ yum groupinsall group1 # 安装程序组group1
# 更新和升级
$ yum update # 全部更新
$ yum update package1 # 更新指定程序包package1
$ yum check-update # 检查可更新的程序
$ yum upgrade package1 # 升级指定程序包package1
$ yum groupupdate group1 # 升级程序组group1
# 查找显示
$ yum list installed | grep mysql
$ yum list installed mysql*
$ yum info package1 # 显示安装包信息package1
$ yum list # 显示所有已经安装和可以安装的程序包
$ yum list package1 # 显示指定程序包安装情况package1
$ yum groupinfo group1 # 显示程序组group1信息
# 删除程序
$ yum remove/erase package1 # 删除程序包package1
$ yum groupremove group1 # 删除程序组group1
$ yum deplist package1 # 查看程序package1依赖情况
# 清除缓存
$ yum clean packages # 清除缓存目录下的软件包
$ yum clean headers # 清除缓存目录下的 headers
$ yum clean oldheaders # 清除缓存目录下旧的 headers
5. dnf
RHEL8, CentOS8
DNF
Use libsolv
for dependency resolution, SUSE
developed and maintained for performance. Yum
Mainly Python
written in , it has its own way of dealing with dependency resolution. It's API
not fully documented and its extension system only allows Python
plugins. Yum
Yes RPM
front-end tool that manages dependencies and repositories and then uses RPM
to install, download and remove packages.
The package manager has been superseded by the package manager Yum
as many of the long-standing issues remain unresolved . These problems include poor performance, excessive memory usage, slow dependency resolution, etc. For more differences between the two management pack tools, read What is the difference between DNF and YUM?.Yum
DNF
-
Install the DNF package manager
# 依赖
$ yum install -y epel-release
# 安装
$ yum install -y dnf
# 检查
$ dnf –version
-
Introduction to common commands
# 安装软件包
$ dnf install nano
# 升级软件包
$ dnf update systemd
# 升级所有系统软件包
$ dnf update
$ dnf upgrade
# 检查系统软件包的更新
$ dnf check-update
# 删除软件包
$ dnf remove nano
$ dnf erase nano
# 删除无用孤立的软件包
$ dnf autoremove
# 删除缓存的无用软件包
$ dnf clean all
# 查看系统中可用的DNF软件库
$ dnf repolist
# 查看系统中可用和不可用的所有的DNF软件库
$ dnf repolist all
# 列出所有RPM包
$ dnf list
# 列出所有安装了的RPM包
$ dnf list installed
# 列出所有可供安装的RPM包
$ dnf list available
# 搜索软件库中的RPM包
$ dnf search nano
# 查找某一文件的提供者
$ dnf provides /bin/bash
# 查看软件包详情
$ dnf info nano
# 查看所有的软件包组
$ dnf grouplist
# 安装一个软件包组
$ dnf groupinstall 'Educational Software'
# 升级一个软件包组中的软件包
$ dnf groupupdate 'Educational Software'
# 删除一个软件包组
$ dnf groupremove 'Educational Software'
# 重新安装特定软件包
$ dnf reinstall nano
# 回滚某个特定软件的版本
$ dnf downgrade acpid
# 查看DNF命令的执行历史
$ dnf history
# 查看所有的DNF命令及其用途
$ dnf help
# 获取有关某条命令的使用帮助
$ dnf help clean
This article is reproduced from: "Escape's Blog", the original text: https://url.hi-linux.com/No9Xd, the copyright belongs to the original author. Contributions are welcome, submission email: [email protected].
Recently, we established a technical exchange WeChat group . At present, many great gods in the industry have joined the group. Interested students can join and exchange technology with us, and directly reply to "Jiaqun" on the "Wonderful Linux World" public account to invite you to join the group.
You might also like
Click the image below to read
How to choose the right public DNS
Click on the picture above, "Meituan|Ele.me" will sell red envelopes for free every day
For more interesting Internet news, pay attention to the "Wonderful Internet" video account to learn all about it!