hashdeep supports multiple hash algorithms such as MD5, SHA-1, and SHA-256, making it flexible for various use cases.
You can replace sha256
with md5
, sha1
, or other supported algorithms depending on your preference.
hashdeep -c sha256 -r /path/to/your/directory
3. Saving Hashes to a File
Below are some of the most common use cases.
To do this, use the following command to verify files:
- File Integrity Checking: Ensuring that files have not been tampered with or corrupted over time.
- Digital Forensics: Verifying the integrity of files in forensic investigations.
- Backup and Restoration: Verifying the integrity of backup files and ensuring data consistency during recovery processes.
Installing hashdeep in Linux
hashdeep -r ravi > hashes.txt
cat hashes.txt
4. Verifying File Integrity
The most basic usage of hashdeep is to calculate the hash of a single file or multiple files.
In this article, I’ll provide a detailed understanding of what hashdeep is, how it works, and how you can use it effectively in Linux environments.
1. Calculating Hashes of Files
sudo apt install hashdeep [On Debian, Ubuntu and Mint]
sudo yum install hashdeep [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/hashdeep [On Gentoo Linux]
sudo apk add hashdeep [On Alpine Linux]
sudo pacman -S hashdeep [On Arch Linux]
sudo zypper install hashdeep [On OpenSUSE]
sudo pkg install hashdeep [On FreeBSD]
One such tool that I find particularly useful is hashdeep, which is a powerful command-line utility used primarily for file integrity checking and verifying cryptographic hashes.
-c sha256
specifies the hash algorithm (SHA-256 in this case).myqr.png
is the file you want to hash.
hashdeep -a -k hashes.txt -r /home/ravi/ravi
hashdeep -c sha256 myqr.png
As a seasoned Linux user with over a decade of experience, I’ve come across many tools that help in various aspects of system administration, security, and forensics.
You can also hash all files in a directory, including subdirectories, by using the -r
flag (recursive):
To calculate multiple types of hashes (e.g., MD5, SHA-1, and SHA-256) at once, you can specify more than one algorithm with the -c
flag:
hashdeep -c md5,sha1,sha256 -r /path/to/your/directory
Conclusion
It is most commonly used in:
Before we dive into its usage, let’s first get hashdeep installed on your Linux system, which is available in most distribution package repositories, so installation is easy.