如何使用DNF历史记录列出手动安装的包
时间:2020-03-05 15:26:33 来源:igfitidea点击:
偶尔作为Linux用户,我们可能希望在Linux机器上进行各种已安装软件包状态的审核。
主要目的是跟踪安装的包装以及在某个时间点删除的包装。
在本文中,我们将使用DNF History命令查看Fedora 27中已安装软件包的事务状态。
这将为我们提供手动安装和删除的包的历史记录。
使用DNF检索手动安装的软件包列表
要检索用户手动安装的包列表,请运行以下命令
dnf history userinstalled
示例输出
Packages installed by user httpd gnome-tweak-tool nodejs
检索所有交易的列表
要显示系统中执行的所有先前事务的列表,请在下面的命令运行
dnf history list all
示例输出
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------ 3 | install gnome-tweak-tool | 2016-02-11 22:50 | Install | 2 2 | remove httpd | 2016-02-11 22:42 | Erase | 4 1 | install nodejs | 2016-02-11 22:33 | Install | 4
列出特定交易的更改
要列出特定事务的更改,请将事务的ID添加在命令的末尾。
例如,如果我们想在上面的示例中检查ID 1的更改,该更改是安装NodeJS的idejs我们运行命令,如图所示
dnf history list 1
示例输出
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------ 1 | install nodejs | 2016-02-11 22:33 | Install | 4
检索有关某个交易包的信息
要显示有关某个事务的包的信息,请按照显示运行该命令
dnf history info 1
示例输出
Transaction ID : 1 Begin time : Sun Nov 11 22:33:32 2016 Begin rpmdb : 1403:93d810e4d47f231ae56e62f96163e3d6b01ba7aa End time : 22:33:52 2016 (20 seconds) End rpmdb : 1407:77a7d6293b725b707e548ed7015a05eaf503d49c User : jamie Return-Code : Success Command Line : install nodejs Transaction performed with: Installed dnf-0.6.1-1.fc21.noarch (unknown) Installed rpm-4.12.0.1-3.fc21.x86_64 (unknown) Packages Altered: Install http-parser-2.0-7.20121128gitcd01361.fc21.x86_64 @fedora Install libuv-1:0.10.34-1.fc21.x86_64 @updates Install nodejs-0.10.36-3.fc21.x86_64 @updates Install v8-1:3.14.5.10-18.fc21.x86_64 @updates
如何撤消完整的交易
如果要重新回滚事务,请说出卸载或者安装包,请使用撤消选项后跟命令中的事务ID作为所示。
首先,我们将列出事务历史记录。
dnf history list all
示例输出
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------ 3 | install gnome-tweak-tool | 2016-02-11 22:50 | Install | 2 2 | remove httpd | 2016-02-11 22:42 | Erase | 4 1 | install nodejs | 2016-02-11 22:33 | Install | 4
让我们回滚Httpd Web服务器的卸载
dnf history undo 2
以上将重新安装HTTPD示例输出
[root@localhost ~]# dnf history undo 2 Undoing transaction 2, from Sun Nov 11 22:42:55 2016 Erase gnome-user-share-3.14.0-2.fc21.x86_64 (unknown) Erase httpd-2.4.16-1.fc21.x86_64 (unknown) Erase mod_dnssd-0.6-12.fc21.x86_64 (unknown) Erase php-5.6.15-1.fc21.x86_64 (unknown) ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gnome-user-share x86_64 3.14.0-2.fc21 fedora 135 k httpd x86_64 2.4.16-1.fc21 updates 1.2 M mod_dnssd x86_64 0.6-12.fc21 fedora 27 k php x86_64 5.6.15-1.fc21 updates 2.6 M Transaction Summary ================================================================================ Install 4 Packages Total download size: 4.0 M Installed size: 13 M Is this ok [y/N]: Thank you for reading this post. If you have any questions regarding the usage of DNF history command, do not hesitate to contact us.