deb-md5sums - Linux
Overview
deb-md5sums calculates and prints the MD5 checksums for one or more Debian package files. This command is used to verify the integrity of downloaded packages before installation, ensuring they have not been corrupted during transmission.
Syntax
deb-md5sums [options] <package_file>...
Options/Flags
- -c (check): Checks the checksums of the specified packages against the checksums in the Debian package index.
- -q (quiet): Suppresses all output except for errors.
- -s (skips): Skips the checksum validation if the package is already installed.
- -t (type): Specifies the hash function to use for checksum calculation. Supported options include ‘sha256’ and ‘sha512’. Defaults to ‘md5’.
- –help (-h): Displays help information.
Examples
Calculating checksums for a single package:
deb-md5sums example-package.deb
Checking checksums against a Debian package index:
deb-md5sums -c example-package.deb
Skipping checksum validation for installed packages:
deb-md5sums -s example-package.deb
Common Issues
Error: No Debian package index found
This error occurs when the Debian package index is not available or accessible. Make sure you have an active internet connection and the package index file is located in the correct directory.
Error: Checksum mismatch
A checksum mismatch indicates that the downloaded package has been corrupted. Retry the download or obtain the package from a different source.
Integration
Verifying package integrity before installation:
wget example-package.deb
deb-md5sums -c example-package.deb
sudo dpkg -i example-package.deb
Creating a script to automate package verification:
#!/bin/bash
# Get the package checksums
CHECKSUMS=$(deb-md5sums example-package.deb | md5sum)
# Download the package
wget example-package.deb
# Verify the downloaded package checksums
DOWNLOAD_CHECKSUM=$(md5sum example-package.deb | cut -d' ' -f1)
# Compare the checksums
if [[ "$CHECKSUMS" == "$DOWNLOAD_CHECKSUM" ]]; then
echo "Package integrity verified."
else
echo "Checksum mismatch. Package may be corrupted."
exit 1
fi
Related Commands
- dpkg: Manage Debian packages.
- md5sum: Calculate MD5 checksums.