To check the SHA1 hash of a file on Linux, FreeBSD, or any other Unix-like operating system, you can use the sha1sum
command. This command calculates and displays the SHA1 hash of a file.
To check the SHA1 hash of a file, use the following syntax:
sha1sum file
Replace file
with the name of the file you want to check. For example, to check the SHA1 hash of a file named example.txt
, you would use the following command:
sha1sum example.txt
This will display the SHA1 hash of the file, along with the name of the file.
You can also use the sha1sum
command to check the SHA1 hash of multiple files at the same time. Simply specify the names of the files you want to check, separated by a space. For example:
sha1sum file1 file2 file3
If you want to check the SHA1 hash of a file and compare it to a known hash value, you can use the -c
option. This option allows you to specify a file containing known hash values, and the sha1sum
command will compare the calculated hash values to the known values.
For example, to compare the SHA1 hash of a file named example.txt
to a known hash value, you can use the following syntax:
sha1sum -c checksum.txt
Replace checksum.txt
with the name of the file containing the known hash values. The file should contain the hash value and the name of the file, separated by a space. For example:
6f1ed002ab5595859014ebf0951522d9 example.txt
If the calculated hash value of the file matches the known value, the sha1sum
command will display OK
. If the values do not match, it will display an error message indicating that the hash values do not match.
You can also use the sha1
command to calculate the SHA1 hash of a file. This command is similar to sha1sum
, but it does not display the name of the file in the output.
To calculate the SHA1 hash of a file using the sha1
command, use the following syntax:
sha1 file
Replace file
with the name of the file you want to check. For example:
sha1 example.txt
This will display the SHA1 hash of the file.