sha1sum
Print or check SHA1 (160-bit) checksums. With no FILE, or when FILE is -, read standard input.
sha1sum {file}
If you want to send the file together with its sha1sum output redirect the output to a file:
sha1sum {file} > {file}.sha1
Send both files and the other party can do a...
sha1sum -c {file}.sha1
It should show OK
if the sha1
is correct.
Ubuntu publishes a manifest that is signed with an RSA key. The manifest lists individual Packages
index files, each with MD5, SHA-1 and SHA-256 hashes. Each Packages
file lists individual .deb
files with MD5, SHA-1 and SHA-256 hashes.
For verification, apt uses the best hash that it supports and is published by the archive it is downloading from. In the case of the Ubuntu archive, this is SHA-256.
So the entire chain of installing packages on your Ubuntu system is protected by RSA and SHA-256.
The MD5 protection that exists in dpkg is really only useful for accidental corruption, and not necessary to protect the installation path.
You might be interested in the debsums
package, but since it uses MD5s, it also is only useful for checking for accidental corruption.
If you want to check for malicious system modification, then these are not the appropriate tools for you. You will need to take the system offline and check against either a previous record, the original package files, or secure hashes generated from these.
Note that since a successful malicious modification might be to simply downgrade a package to the one prior to a security update, checking that all installed package files match against their originals may not be sufficient either.
Best Answer
Read the first 500 bytes of the first file:
head -c 500 file1.mp3 > fragment1
Use
curl -r 0-499 -o fragment2 http://...
to retrieve the first 500 bytes of the second file. Then, dodiff fragment1 fragment2
to see if they are equal.curl
is a tool likewget
only with more options. The-r
flag lets you specify a range, which will result in a partial download.wget
has a quota option that will not, however, let you do a partial download.