What is sum Linux command?
The Linux sum command calculates and prints the checksum and block counts of a file. It can be used to verify the integrity of files and detect any changes or corruption.
sum Syntax:
Section titled “sum Syntax:”sum [OPTION]... [FILE]...
sum Options:
Section titled “sum Options:”Option | Description |
---|---|
-s | Print only the sum of data |
-r | Print in reverse order |
-0 | End each output line with ASCII NUL |
Parameters:
Section titled “Parameters:”Parameter | Description |
---|---|
FILE | Specify the paths to the files to sum |
sum Command Usage Examples:
Section titled “sum Command Usage Examples:”Check the Checksum of a File
Section titled “Check the Checksum of a File”sum file.txt
Calculates and displays the checksum of the file “file.txt”.
Verify Multiple Files Checksum
Section titled “Verify Multiple Files Checksum”sum file1.txt file2.txt file3.txt
Calculates and displays the checksum of multiple files “file1.txt”, “file2.txt”, and “file3.txt”.
Compare Checksums between Two Files
Section titled “Compare Checksums between Two Files”sum file1.txt file2.txt
Calculates and displays the checksums of “file1.txt” and “file2.txt” for comparison.
Redirect Sum Output to a File
Section titled “Redirect Sum Output to a File”sum file.txt > checksum.txt
Calculates and saves the checksum of “file.txt” in a separate file named “checksum.txt”.
Display Checksum in Binary/Hexadecimal Form
Section titled “Display Checksum in Binary/Hexadecimal Form”sum -r file.txt
Calculates and displays the checksum of “file.txt” in binary and hexadecimal form.
How do I use sum in Linux?
Section titled “How do I use sum in Linux?”To use the sum command in bash, execute the following command:
sum file.txt
How can I output the checksum in a specific format with sum?
Section titled “How can I output the checksum in a specific format with sum?”To output the checksum in a specific format, use the following command:
sum --format=null file.txt
How can I display the help information for sum command?
Section titled “How can I display the help information for sum command?”To display the help information for the sum command, use the following command:
sum --help
How do I verify the integrity of a file using sum?
Section titled “How do I verify the integrity of a file using sum?”To verify the integrity of a file using sum, execute the following command:
sum -c checksum.txt
How to calculate the checksum of multiple files with sum?
Section titled “How to calculate the checksum of multiple files with sum?”To calculate the checksum of multiple files, use the following command:
sum file1.txt file2.txt
Can I ignore warnings when using sum in Linux?
Section titled “Can I ignore warnings when using sum in Linux?”To ignore warnings when using sum, you can use the -w
flag in the command. For example:
sum -w file.txt
How to specify a different hashing algorithm with sum?
Section titled “How to specify a different hashing algorithm with sum?”To specify a different hashing algorithm, use the -a
option in the command. For example, to use SHA256, run:
sum -a SHA256 file.txt
Is there a way to only display the checksum without the filename using sum?
Section titled “Is there a way to only display the checksum without the filename using sum?”To display only the checksum without the filename, use the -t
option in the command. For example:
sum -t file.txt
Applications of the sum command
Section titled “Applications of the sum command”- Checking for changes in files
- Verifying data integrity