如何對照MD5校驗和校驗已安裝的Debian軟件包在Debian/Ubuntu系統上,你可以使用debsums工具來校驗已安裝軟件包的MD5和。如果你想在安裝之前知道關於debsums軟件包的信息,可以使用APT-CACHE,就像這樣:
apt-cache search debsums
下一步,使用apt命令來安裝它,如下所示:
sudo apt install debsums
現在可以了解如何使用debsums工具,來校驗已安裝軟件包的MD5和了。
說明:我在下面的所有命令中使用了sudo,因為普通用戶可能沒有某些文件的讀取權限。
此外,來自debsums命令的輸出在左邊顯示了文件位置,在右邊顯示了檢驗結果。你會得到三種可能的結果,它們包括:
- ·OKDD表明某個文件的MD5和是好的。
- ·FAILEDDD表明某個文件的MD5和不匹配。
- · REPLACEDDD意味著某個特定文件已被來自另一個軟件包的文件所更換。
如果你不用任何選項來運行,debsums會對照常規的md5sum文件來校驗系統上的每個文件,掃描文件系統、尋找MD5和
- /usr/bin/a11y-profile-manager-indicatorOK
- /usr/share/doc/a11y-profile-manager-indicator/copyrightOK
- /usr/share/man/man1/a11y-profile-manager-indicator.1.gzOK
- /usr/share/accounts/providers/facebook.providerOK
- /usr/share/accounts/qml-plugins/facebook/Main.qmlOK
- /usr/share/accounts/services/facebook-microblog.serviceOK
- /usr/share/accounts/services/facebook-sharing.serviceOK
- /usr/share/doc/account-plugin-facebook/copyrightOK
- /usr/share/accounts/providers/flickr.providerOK
- /usr/share/accounts/qml-plugins/flickr/Main.qmlOK
- /usr/share/accounts/services/flickr-microblog.serviceOK
- /usr/share/accounts/services/flickr-sharing.serviceOK
- /usr/share/doc/account-plugin-flickr/copyrightOK
- /usr/share/accounts/providers/google.providerOK
- /usr/share/accounts/qml-plugins/google/Main.qmlOK
- /usr/share/accounts/services/google-drive.serviceOK
- /usr/share/accounts/services/google-im.serviceOK
- /usr/share/accounts/services/picasa.serviceOK
- /usr/share/doc/account-plugin-google/copyrightOK
- /lib/systemd/system/accounts-daemon.serviceOK
- /usr/lib/accountsservice/accounts-daemonOK
- /usr/share/dbus-1/interfaces/org.freedesktop.Accounts.User.xmlOK
- /usr/share/dbus-1/interfaces/org.freedesktop.Accounts.xmlOK
- /usr/share/dbus-1/system-services/org.freedesktop.Accounts.serviceOK
- /usr/share/doc/accountsservice/READMEOK
- /usr/share/doc/accountsservice/TODOOK
- ....
為了能夠校驗每個軟件包的每個文件和配置文件,查找任何變化,請加入-a或--all選項:
sudo debsums --all
校驗所有配置文件的MD5和:
- /usr/bin/a11y-profile-manager-indicatorOK
- /usr/share/doc/a11y-profile-manager-indicator/copyrightOK
- /usr/share/man/man1/a11y-profile-manager-indicator.1.gzOK
- /etc/xdg/autostart/a11y-profile-manager-indicator-autostart.desktopOK
- /usr/share/accounts/providers/facebook.providerOK
- /usr/share/accounts/qml-plugins/facebook/Main.qmlOK
- /usr/share/accounts/services/facebook-microblog.serviceOK
- /usr/share/accounts/services/facebook-sharing.serviceOK
- /usr/share/doc/account-plugin-facebook/copyrightOK
- /etc/signon-ui/webkit-options.d/www.facebook.com.confOK
- /usr/share/accounts/providers/flickr.providerOK
- /usr/share/accounts/qml-plugins/flickr/Main.qmlOK
- /usr/share/accounts/services/flickr-microblog.serviceOK
- /usr/share/accounts/services/flickr-sharing.serviceOK
- /usr/share/doc/account-plugin-flickr/copyrightOK
- /etc/signon-ui/webkit-options.d/login.yahoo.com.confOK
- /usr/share/accounts/providers/google.providerOK
- /usr/share/accounts/qml-plugins/google/Main.qmlOK
- /usr/share/accounts/services/google-drive.serviceOK
- /usr/share/accounts/services/google-im.serviceOK
- /usr/share/accounts/services/picasa.serviceOK
- /usr/share/doc/account-plugin-google/copyrightOK
- ...
還有可能只校驗配置文件,不包括軟件包的其他所有文件,為此只要使用-e或--config選項:
sudo debsums --config
只校驗配置文件的MD5和:
- /etc/xdg/autostart/a11y-profile-manager-indicator-autostart.desktopOK
- /etc/signon-ui/webkit-options.d/www.facebook.com.confOK
- /etc/signon-ui/webkit-options.d/login.yahoo.com.confOK
- /etc/signon-ui/webkit-options.d/accounts.google.com.confOK
- /etc/dbus-1/system.d/org.freedesktop.Accounts.confOK
- /etc/acpi/asus-keyboard-backlight.shOK
- /etc/acpi/events/asus-keyboard-backlight-downOK
- /etc/acpi/ibm-wireless.shOK
- /etc/acpi/events/tosh-wirelessOK
- /etc/acpi/asus-wireless.shOK
- /etc/acpi/events/lenovo-undockOK
- /etc/default/acpi-supportOK
- /etc/acpi/events/ibm-wirelessOK
- /etc/acpi/events/asus-wireless-onOK
- /etc/acpi/events/asus-wireless-offOK
- /etc/acpi/tosh-wireless.shOK
- /etc/acpi/events/asus-keyboard-backlight-upOK
- /etc/acpi/events/thinkpad-cmosOK
- /etc/acpi/undock.shOK
- /etc/acpi/events/powerbtnOK
- /etc/acpi/powerbtn.shOK
- /etc/init.d/acpidOK
- /etc/init/acpid.confOK
- /etc/default/acpidOK
- ...
下一步,如果想在debsums的輸出中只顯示變化的文件,請使用-c或--changed選項。我在自己的系統中沒有找到任何變化的文件。
sudo debsums --changed
下一個命令輸出沒有md5sum信息的文件,這裡我們使用-l和--list-missing選項。在我的系統上,該命令沒有顯示任何文件。
sudo debsums --list-missing
現在只要指定名稱,就可以校驗單一軟件包的md5和:
sudo debsums apache2
校驗已安裝軟件包的MD5和:
- /lib/systemd/system/apache2.service.d/apache2-systemd.confOK
- /usr/sbin/a2enmodOK
- /usr/sbin/a2queryOK
- /usr/sbin/apache2ctlOK
- /usr/share/apache2/apache2-maintscript-helperOK
- /usr/share/apache2/ask-for-passphraseOK
- /usr/share/bash-completion/completions/a2enmodOK
- /usr/share/doc/apache2/NEWS.Debian.gzOK
- /usr/share/doc/apache2/PACKAGING.gzOK
- /usr/share/doc/apache2/README.Debian.gzOK
- /usr/share/doc/apache2/README.backtraceOK
- /usr/share/doc/apache2/README.multiple-instances OK
- /usr/share/doc/apache2/copyrightOK
- /usr/share/doc/apache2/examples/apache2.monitOK
- /usr/share/doc/apache2/examples/secondary-init-scriptOK
- /usr/share/doc/apache2/examples/setup-instanceOK
- /usr/share/lintian/overrides/apache2OK
- /usr/share/man/man1/a2query.1.gzOK
- /usr/share/man/man8/a2enconf.8.gzOK
- /usr/share/man/man8/a2enmod.8.gzOK
- /usr/share/man/man8/a2ensite.8.gzOK
- /usr/share/man/man8/apache2ctl.8.gzOK
假設你以普通用戶的身份運行debsums,沒有sudo權限,那麼可以使用--ignore-permissions選項,把權限錯誤當成警告:
debsums --ignore-permissions
如何利用.Deb文件生成MD5和?-g選項告訴debsums利用deb內容生成MD5和,其中:
- · missingDD指令debsums利用deb,為不提供MD5和的軟件包生成MD5和。
- · allDD指令debsums忽視磁盤上和,使用deb文件中存在的和,或者如果沒有的話,就用它生成一個。
- · keepDD指令debsums把提取/生成的和寫入到/var/lib/dpkg/info/package.md5sums文件。
- · nocheckDD意味著提取/生成的和沒有對照已安裝軟件包來進行校驗。
如果你看一下目錄/var/lib/dpkg/info/的內容,就會看到各個文件的md5sum,如下圖所示:
cd /var/lib/dpkg/infols *.md5sums
列出軟件包的所有MD5和:
- a11y-profile-manager-indicator.md5sums
- account-plugin-facebook.md5sums
- account-plugin-flickr.md5sums
- account-plugin-google.md5sums
- accountsservice.md5sums
- acl.md5sums
- acpid.md5sums
- acpi-support.md5sums
- activity-log-manager.md5sums
- adduser.md5sums
- adium-theme-ubuntu.md5sums
- adwaita-icon-theme.md5sums
- aisleriot.md5sums
- alsa-base.md5sums
- alsa-utils.md5sums
- anacron.md5sums
- apache2-bin.md5sums
- apache2-data.md5sums
- apache2.md5sums
- apache2-utils.md5sums
- apg.md5sums
- apparmor.md5sums
- app-install-data.md5sums
- app-install-data-partner.md5sums
- ...
記住:使用-g選項與--generate=missing一樣,你可以試著為apache2軟件包生成md5和,只要運行下面這個命令:
sudo debsums --generate=missing apache2
由於我系統上的apache2軟件包已經有md5和,它會顯示下列輸出,這與運行$ sudo debsums apache2的結果一樣。
想了解更多有意思的選項和使用方面的信息,請參閱debsums參考手冊頁。
man debsums
在本文中,我們介紹了如何對照MD5校驗和校驗已安裝的Debian/Ubuntu軟件包,為了避免在你的系統上安裝和執行損壞的二進制文件或軟件包文件,有必要對照軟件包中存儲的信息來校驗文件系統上的文件。
原文來自:http://os.51cto.com/art/201610/519012.htm
本文地址:http://www.linuxprobe.com/check-debian-package-md5.html
http://xxxxxx/Linuxjc/1184534.html TechArticle