{"id":13601,"date":"2019-04-03T11:33:28","date_gmt":"2019-04-03T11:33:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13601"},"modified":"2019-04-03T11:33:28","modified_gmt":"2019-04-03T11:33:28","slug":"how-to-check-md5-sums-of-installed-packages-in-debian-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-check-md5-sums-of-installed-packages-in-debian-ubuntu-linux\/","title":{"rendered":"How to Check MD5 Sums of Installed Packages in Debian\/Ubuntu Linux"},"content":{"rendered":"<p>Have you ever wondered why a given binary or package installed on your system does not work according to you expectations, meaning it does not function correctly as it is supposed to do, perhaps it can not event start at all.<\/p>\n<p>While downloading packages, you may face challenges of unsteady network connections or unexpected power blackouts, this can result into installation of corrupted package.<\/p>\n<p>Considering this as an important factor in maintaining uncorrupted packages on your system, it is therefore a vital step to verify the files on the file system against the information stored in the package by using following article.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/generate-verify-check-files-md5-checksum-linux\/\" target=\"_blank\" rel=\"noopener\">Learn How to Generate and Verify Files with MD5 Checksum in Linux<\/a><\/p>\n<h3>How to Verify Installed Debian Packages Against MD5 Checksums<\/h3>\n<p>On\u00a0<strong>Debian\/Ubuntu<\/strong>\u00a0systems, you can use the\u00a0<strong>debsums<\/strong>\u00a0tool to check the\u00a0<strong>MD5<\/strong>\u00a0sums of installed packages. If you want to know the information about\u00a0<strong>debsums<\/strong>\u00a0package before installing it, you can use\u00a0<a href=\"https:\/\/www.tecmint.com\/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management\/\" target=\"_blank\" rel=\"noopener\">APT-CACHE<\/a>\u00a0like so:<\/p>\n<pre>$ apt-cache search debsums\r\n<\/pre>\n<p>Next, install it using\u00a0<a href=\"https:\/\/www.tecmint.com\/apt-advanced-package-command-examples-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">apt command<\/a>\u00a0as follows:<\/p>\n<pre>$ sudo apt install debsums\r\n<\/pre>\n<p>Now its time to learn how to use\u00a0<strong>debsums<\/strong>\u00a0tool to verify\u00a0<strong>MD5sum<\/strong>\u00a0of installed packages.<\/p>\n<p><strong>Note<\/strong>: I have used\u00a0<strong>sudo<\/strong>\u00a0with all the commands below because certain files may not have read permissions for regular users.<\/p>\n<p>In addition, the output from the\u00a0<strong>debsums<\/strong>\u00a0command shows you the file location on the left and the check results on the right. There are three possible results you can get, they include:<\/p>\n<ol>\n<li><strong>OK<\/strong>\u00a0\u2013 indicates that a file\u2019s MD5 sum is good.<\/li>\n<li><strong>FAILED<\/strong>\u00a0\u2013 shows that a file\u2019s MD5 sum does not match.<\/li>\n<li><strong>REPLACED<\/strong>\u00a0\u2013 means that the specific file has been replaced by a file from another package.<\/li>\n<\/ol>\n<p>When you run it without any options,\u00a0<strong>debsums<\/strong>\u00a0checks every file on your system against the stock\u00a0<strong>md5sum<\/strong>\u00a0files.<\/p>\n<pre><strong>$ sudo debsums<\/strong>\r\n<\/pre>\n<div class=\"code-label\">Scans File System for MD5 Sums<\/div>\n<pre>\/usr\/bin\/a11y-profile-manager-indicator                                       OK\r\n\/usr\/share\/doc\/a11y-profile-manager-indicator\/copyright                       OK\r\n\/usr\/share\/man\/man1\/a11y-profile-manager-indicator.1.gz                       OK\r\n\/usr\/share\/accounts\/providers\/facebook.provider                               OK\r\n\/usr\/share\/accounts\/qml-plugins\/facebook\/Main.qml                             OK\r\n\/usr\/share\/accounts\/services\/facebook-microblog.service                       OK\r\n\/usr\/share\/accounts\/services\/facebook-sharing.service                         OK\r\n\/usr\/share\/doc\/account-plugin-facebook\/copyright                              OK\r\n\/usr\/share\/accounts\/providers\/flickr.provider                                 OK\r\n\/usr\/share\/accounts\/qml-plugins\/flickr\/Main.qml                               OK\r\n\/usr\/share\/accounts\/services\/flickr-microblog.service                         OK\r\n\/usr\/share\/accounts\/services\/flickr-sharing.service                           OK\r\n\/usr\/share\/doc\/account-plugin-flickr\/copyright                                OK\r\n\/usr\/share\/accounts\/providers\/google.provider                                 OK\r\n\/usr\/share\/accounts\/qml-plugins\/google\/Main.qml                               OK\r\n\/usr\/share\/accounts\/services\/google-drive.service                             OK\r\n\/usr\/share\/accounts\/services\/google-im.service                                OK\r\n\/usr\/share\/accounts\/services\/picasa.service                                   OK\r\n\/usr\/share\/doc\/account-plugin-google\/copyright                                OK\r\n\/lib\/systemd\/system\/accounts-daemon.service                                   OK\r\n\/usr\/lib\/accountsservice\/accounts-daemon                                      OK\r\n\/usr\/share\/dbus-1\/interfaces\/org.freedesktop.Accounts.User.xml                OK\r\n\/usr\/share\/dbus-1\/interfaces\/org.freedesktop.Accounts.xml                     OK\r\n\/usr\/share\/dbus-1\/system-services\/org.freedesktop.Accounts.service            OK\r\n\/usr\/share\/doc\/accountsservice\/README                                         OK\r\n\/usr\/share\/doc\/accountsservice\/TODO                                           OK\r\n....\r\n<\/pre>\n<p>To enable checking of every file and configuration files for each package for any changes, include the\u00a0<code>-a<\/code>\u00a0or\u00a0<code>--all<\/code>\u00a0option:<\/p>\n<pre><strong>$ sudo debsums --all<\/strong>\r\n<\/pre>\n<div class=\"code-label\">Check MD5 Sums of All Configuration Files<\/div>\n<pre>\/usr\/bin\/a11y-profile-manager-indicator                                       OK\r\n\/usr\/share\/doc\/a11y-profile-manager-indicator\/copyright                       OK\r\n\/usr\/share\/man\/man1\/a11y-profile-manager-indicator.1.gz                       OK\r\n\/etc\/xdg\/autostart\/a11y-profile-manager-indicator-autostart.desktop           OK\r\n\/usr\/share\/accounts\/providers\/facebook.provider                               OK\r\n\/usr\/share\/accounts\/qml-plugins\/facebook\/Main.qml                             OK\r\n\/usr\/share\/accounts\/services\/facebook-microblog.service                       OK\r\n\/usr\/share\/accounts\/services\/facebook-sharing.service                         OK\r\n\/usr\/share\/doc\/account-plugin-facebook\/copyright                              OK\r\n\/etc\/signon-ui\/webkit-options.d\/www.facebook.com.conf                         OK\r\n\/usr\/share\/accounts\/providers\/flickr.provider                                 OK\r\n\/usr\/share\/accounts\/qml-plugins\/flickr\/Main.qml                               OK\r\n\/usr\/share\/accounts\/services\/flickr-microblog.service                         OK\r\n\/usr\/share\/accounts\/services\/flickr-sharing.service                           OK\r\n\/usr\/share\/doc\/account-plugin-flickr\/copyright                                OK\r\n\/etc\/signon-ui\/webkit-options.d\/login.yahoo.com.conf                          OK\r\n\/usr\/share\/accounts\/providers\/google.provider                                 OK\r\n\/usr\/share\/accounts\/qml-plugins\/google\/Main.qml                               OK\r\n\/usr\/share\/accounts\/services\/google-drive.service                             OK\r\n\/usr\/share\/accounts\/services\/google-im.service                                OK\r\n\/usr\/share\/accounts\/services\/picasa.service                                   OK\r\n\/usr\/share\/doc\/account-plugin-google\/copyright                                OK\r\n...\r\n<\/pre>\n<p>It is as well possible to check only the configuration file excluding all other package files by using the\u00a0<code>-e<\/code>\u00a0or\u00a0<code>--config<\/code>\u00a0option:<\/p>\n<pre><strong>$ sudo debsums --config<\/strong>\r\n<\/pre>\n<div class=\"code-label\">Only Check MD5 Sums of Configuration Files<\/div>\n<pre>\/etc\/xdg\/autostart\/a11y-profile-manager-indicator-autostart.desktop           OK\r\n\/etc\/signon-ui\/webkit-options.d\/www.facebook.com.conf                         OK\r\n\/etc\/signon-ui\/webkit-options.d\/login.yahoo.com.conf                          OK\r\n\/etc\/signon-ui\/webkit-options.d\/accounts.google.com.conf                      OK\r\n\/etc\/dbus-1\/system.d\/org.freedesktop.Accounts.conf                            OK\r\n\/etc\/acpi\/asus-keyboard-backlight.sh                                          OK\r\n\/etc\/acpi\/events\/asus-keyboard-backlight-down                                 OK\r\n\/etc\/acpi\/ibm-wireless.sh                                                     OK\r\n\/etc\/acpi\/events\/tosh-wireless                                                OK\r\n\/etc\/acpi\/asus-wireless.sh                                                    OK\r\n\/etc\/acpi\/events\/lenovo-undock                                                OK\r\n\/etc\/default\/acpi-support                                                     OK\r\n\/etc\/acpi\/events\/ibm-wireless                                                 OK\r\n\/etc\/acpi\/events\/asus-wireless-on                                             OK\r\n\/etc\/acpi\/events\/asus-wireless-off                                            OK\r\n\/etc\/acpi\/tosh-wireless.sh                                                    OK\r\n\/etc\/acpi\/events\/asus-keyboard-backlight-up                                   OK\r\n\/etc\/acpi\/events\/thinkpad-cmos                                                OK\r\n\/etc\/acpi\/undock.sh                                                           OK\r\n\/etc\/acpi\/events\/powerbtn                                                     OK\r\n\/etc\/acpi\/powerbtn.sh                                                         OK\r\n\/etc\/init.d\/acpid                                                             OK\r\n\/etc\/init\/acpid.conf                                                          OK\r\n\/etc\/default\/acpid                                                            OK\r\n...\r\n<\/pre>\n<p>Next, to only display changed files in the output of debsums, use the\u00a0<code>-c<\/code>\u00a0or\u00a0<code>--changed<\/code>\u00a0option. I didn\u2019t found any changed files in my system.<\/p>\n<pre><strong>$ sudo debsums --changed<\/strong>\r\n<\/pre>\n<p>The next command prints out files that do not have md5sum info, here we use the\u00a0<code>-l<\/code>\u00a0and\u00a0<code>--list-missing<\/code>option. On my system, the command does not show any file.<\/p>\n<pre><strong>$ sudo debsums --list-missing<\/strong>\r\n<\/pre>\n<p>Now it\u2019s time to verify the\u00a0<strong>md5 sum<\/strong>\u00a0of a single package by specifying its name:<\/p>\n<pre><strong>$ sudo debsums apache2 \r\n<\/strong><\/pre>\n<div class=\"code-label\">Check MD5 Sum of Installed Package<\/div>\n<pre>\/lib\/systemd\/system\/apache2.service.d\/apache2-systemd.conf                    OK\r\n\/usr\/sbin\/a2enmod                                                             OK\r\n\/usr\/sbin\/a2query                                                             OK\r\n\/usr\/sbin\/apache2ctl                                                          OK\r\n\/usr\/share\/apache2\/apache2-maintscript-helper                                 OK\r\n\/usr\/share\/apache2\/ask-for-passphrase                                         OK\r\n\/usr\/share\/bash-completion\/completions\/a2enmod                                OK\r\n\/usr\/share\/doc\/apache2\/NEWS.Debian.gz                                         OK\r\n\/usr\/share\/doc\/apache2\/PACKAGING.gz                                           OK\r\n\/usr\/share\/doc\/apache2\/README.Debian.gz                                       OK\r\n\/usr\/share\/doc\/apache2\/README.backtrace                                       OK\r\n\/usr\/share\/doc\/apache2\/README.multiple-instances                              OK\r\n\/usr\/share\/doc\/apache2\/copyright                                              OK\r\n\/usr\/share\/doc\/apache2\/examples\/apache2.monit                                 OK\r\n\/usr\/share\/doc\/apache2\/examples\/secondary-init-script                         OK\r\n\/usr\/share\/doc\/apache2\/examples\/setup-instance                                OK\r\n\/usr\/share\/lintian\/overrides\/apache2                                          OK\r\n\/usr\/share\/man\/man1\/a2query.1.gz                                              OK\r\n\/usr\/share\/man\/man8\/a2enconf.8.gz                                             OK\r\n\/usr\/share\/man\/man8\/a2enmod.8.gz                                              OK\r\n\/usr\/share\/man\/man8\/a2ensite.8.gz                                             OK\r\n\/usr\/share\/man\/man8\/apache2ctl.8.gz                                           OK\r\n<\/pre>\n<p>Assuming that you are running\u00a0<strong>debsums<\/strong>\u00a0as a regular user without\u00a0<strong>sudo<\/strong>, you can treat permission errors as warnings by employing the\u00a0<code>--ignore-permissions<\/code>\u00a0option:<\/p>\n<pre>$ debsums --ignore-permissions \r\n<\/pre>\n<h3>How To Generate MD5 Sums from .Deb Files<\/h3>\n<p>The\u00a0<code>-g<\/code>\u00a0option tells debsums to generate MD5 sums from deb contents, where:<\/p>\n<ol>\n<li><strong>missing<\/strong>\u00a0\u2013 instruct debsums to generate MD5 sums from the deb for packages which don\u2019t provide one.<\/li>\n<li><strong>all<\/strong>\u00a0\u2013 directs debsums to ignore the on disk sums and use the one present in the deb file, or generated from it if none exists.<\/li>\n<li><strong>keep<\/strong>\u00a0\u2013 tells debsums to write the extracted\/generated sums to \/var\/lib\/dpkg\/info\/package.md5sums file.<\/li>\n<li><strong>nocheck<\/strong>\u00a0\u2013 means the extracted\/generated sums are not checked against the installed package.<\/li>\n<\/ol>\n<p>When you look at the contents of the directory\u00a0<code>\/var\/lib\/dpkg\/info\/<\/code>, you will see md5sums for various files that packages as in the image below:<\/p>\n<pre><strong>$ cd \/var\/lib\/dpkg\/info<\/strong>\r\n<strong>$ ls *.md5sums\r\n<\/strong><\/pre>\n<div class=\"code-label\">List All MD5 Sums for Packages<\/div>\n<pre>a11y-profile-manager-indicator.md5sums\r\naccount-plugin-facebook.md5sums\r\naccount-plugin-flickr.md5sums\r\naccount-plugin-google.md5sums\r\naccountsservice.md5sums\r\nacl.md5sums\r\nacpid.md5sums\r\nacpi-support.md5sums\r\nactivity-log-manager.md5sums\r\nadduser.md5sums\r\nadium-theme-ubuntu.md5sums\r\nadwaita-icon-theme.md5sums\r\naisleriot.md5sums\r\nalsa-base.md5sums\r\nalsa-utils.md5sums\r\nanacron.md5sums\r\napache2-bin.md5sums\r\napache2-data.md5sums\r\napache2.md5sums\r\napache2-utils.md5sums\r\napg.md5sums\r\napparmor.md5sums\r\napp-install-data.md5sums\r\napp-install-data-partner.md5sums\r\n...\r\n<\/pre>\n<p>Remember that using\u00a0<code>-g<\/code>\u00a0option is the same as\u00a0<code>--generate=missing<\/code>, you can try to generate a md5 sum for\u00a0<strong>apache2<\/strong>\u00a0package by running the following command.<\/p>\n<pre>$ sudo debsums --generate=missing apache2 \r\n<\/pre>\n<p>Since\u00a0<strong>apache2<\/strong>\u00a0package on my system already has\u00a0<strong>md5<\/strong>\u00a0sums, it will show the output below, which is the same as running:<\/p>\n<pre>$ sudo debsums apache2\r\n<\/pre>\n<p>For more interesting options and usage info, look through the\u00a0<strong>debsums<\/strong>\u00a0man page.<\/p>\n<pre>$ man debsums\r\n<\/pre>\n<p>In this article, we shared how to verify installed\u00a0<strong>Debian\/Ubuntu<\/strong>\u00a0packages against\u00a0<strong>MD5<\/strong>\u00a0checksums, this can be useful in order to avoid installing and executing corrupted binaries or package files on your system by checking the files on the file system against the information stored in the package.<\/p>\n<p>For any questions or feedback, take advantage of the comment form below. Imaginably, you can as well offer one or two suggestions to make this post better.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/check-verify-md5sum-packages-files-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered why a given binary or package installed on your system does not work according to you expectations, meaning it does not function correctly as it is supposed to do, perhaps it can not event start at all. While downloading packages, you may face challenges of unsteady network connections or unexpected power &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-check-md5-sums-of-installed-packages-in-debian-ubuntu-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Check MD5 Sums of Installed Packages in Debian\/Ubuntu Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13601","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13601"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13601\/revisions"}],"predecessor-version":[{"id":13602,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13601\/revisions\/13602"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}