The integrity of a file can be verified using checksums. A checksum is a unique digital signature generated using a hashing algorithm such as MD5, SHA-1, or SHA-256.
You can generate the checksum of the original file and compare it with the checksum of the downloaded or modified file. A file is considered intact if the checksums match.
Kindly follow the below-mentioned steps to generate checksums.
Step 1: Access your server via SSH.
Step 2: Enter the below command in the terminal to create a checksum.
Syntax:
sha256sum filename
Example:
sha256sum temp.txt
This command will generate an SHA-256 checksum for the file temp.txt. By changing the command, you can also use other algorithms, such as MD5sum, sha1sum, sha384sum, or sha512sum.
Step 3: Enter the following command to save the checksum into the file.
sha256sum temp.txt > temp.txt.sha256
This command will save the checksum to temp.txt.sha256 file.
Step 4: Enter the following command to verify the file's integrity.
sha256sum -c temp.txt.sha256
Above command will verify the file's integrity by comparing its checksum with the one saved in the temp.txt.sha256 file. If the checksums match, the output will be temp.txt: OK; otherwise, the output will be temp.txt: FAILED
That's all.