Skip to content

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.

Terminal window
sum [OPTION]... [FILE]...
OptionDescription
-sPrint only the sum of data
-rPrint in reverse order
-0End each output line with ASCII NUL
ParameterDescription
FILESpecify the paths to the files to sum
Terminal window
sum file.txt

Calculates and displays the checksum of the file “file.txt”.

Terminal window
sum file1.txt file2.txt file3.txt

Calculates and displays the checksum of multiple files “file1.txt”, “file2.txt”, and “file3.txt”.

Terminal window
sum file1.txt file2.txt

Calculates and displays the checksums of “file1.txt” and “file2.txt” for comparison.

Terminal window
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”
Terminal window
sum -r file.txt

Calculates and displays the checksum of “file.txt” in binary and hexadecimal form.

To use the sum command in bash, execute the following command:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
sum -t file.txt
  • Checking for changes in files
  • Verifying data integrity