Last Updated : 14 Oct, 2024
The sum command in Linux is used to calculate the checksum and block count of files. This command helps in verifying file integrity by comparing the calculated checksum with an expected value. The sum command can operate on one or more files, and when no file is specified, it reads from standard input.
SyntaxThe general syntax for the sum command is as follows:
sum [OPTION]... [FILE]...Basic Example
It will ask for the input of the file we want to calculate the checksum. In the following example, we calculate the checksum for "myfile.txt".
Key Options used with the sum command 1. sum -rUses the BSD algorithm, with 1K blocks. This is useful when working in environments that prefer BSD-style checksum algorithms.
Example:
sum -r myfile.txt2. sum -s
Uses the System V algorithm, with 512-byte blocks. This option is commonly used in older systems that rely on the System V algorithm.
Example:
sum -s myfile.txt3. sum --help
Displays help text with a list of all options and exits.
Example:
sum --help4. sum --version
Shows version information of the sum command and exits.
sum --version
Option
Description
-r
Uses the BSD algorithm with 1K blocks. Suitable for environments that rely on the BSD-style checksum.
-s
Uses the System V algorithm with 512-byte blocks. Useful for older systems with the System V algorithm.
--help
Displays help text with a list of options.
--version
Shows the version information of the sum command.
ConclusionThe sum command is a simple yet powerful tool for verifying file integrity in Linux systems. By using options such as -r and -s, you can choose different algorithms and block sizes based on your requirements. Whether you're verifying file downloads or automating checksum verification, sum is an essential command to know.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4