sum command in Linux, Uses of sum command with examples

sum command in Linux gives us information about file checksum and the number of blocks in a file. The sum command is often used to find out whether a file has been copied.

  • It is one of the oldest checksum commands, dating back to the first version of Unix, from 1971.
  • sum command displays the block count and checksum for each specified file.
  • When no file is specified then it will read the standard input.
  • If no options are specified, a byte-by-byte algorithm is used.

Syntax for sum command

sum [OPTION]...[file1] [file2]....

How to use sum command

To know how to use sum command and get help for sum command and find options available with sum command, Use sum –help command.

 sum --help

sum --help command in Linux

Version

TO check sum installed version, use command sum –version.

sum --version

sum --version command in Linux

Using sum command with examples

sum command can be used with single file or multiple files. Simply using sum command with any file and without any option will display file checksum and the number of 1024-byte blocks in that file.

For single file

sum filename
sum a.txt

sum filename command in LinuxHere sum command is used with filename “a.txt”, checksum of the file “a.txt” is 30177 and this file containing four blocks.

For multiple files

sum file1 file2
sum a.txt b.txt

sum file1 file2 command in Linux

Here sum command is used with filename “a.txt, b.txt”. Checksum of the file named “a.txt” is 30177 and this file containing four blocks and checksum of the file named “b.txt” is 13054 and this file is also containing four blocks.

Using sum command with -r option

sum command with -r option display file checksum and the number of 1K blocks in that file.

** 1K is equivalent to 1024 bytes. Since, using sum command without any option display the checksum and number of 1024-byte blocks in that file. So, you may notice the output of sum command with -r option and without any option is same.

sum -r filename
sum -r a.txt

sum -r filename command in Linux

Using sum command with -s option

sum command with -s option display file checksum and the number of 512 bytes blocks in that file.

Since, sum command without any option display number of 1024-byte blocks in that file. So, you may notice the number of blocks with -s option is double the number of blocks without any option.

sum -s filename
sum -s a.txt

sum -s filename command in Linux

sum command can be used to verify copied file

sum command can be used to verify copied file

sum command can be used to verify copied file

 

A
adduser | addgroup | alias | anacron | apt | aptitude | arp | at | atq | atrm | awk
B
basename | banner | batch | bc | bg | bzip
C
cat | cal | cd | chgrp | chown | cksum | chmod | clear | cmp | comm | cp
D
date | dd | df | diff | dir | dmidecode | du
E
echo | eject | env | exit | expr
F
factor | find | free
G
grep | groups | gunzip | gzip
H
head | history | hostname | hostnamectl | htop | hwclock | hwinfo
I
id | ifconfig | ionice | iostat | ip | iptables | iw | iwlist
J
K
kill | kmod
L
last | less | ln | locate | login | lp | ls | lshw | lscpu | lsof | lsusb
M
man | mdsum | mkdir | more| mv
N
nano | nc | neofetch | netcat | netstat | nice | nmap | nproc
O
openssl
P
passwd | pidof | ping | pr | ps | pwd | pstree
Q
R
rdiff-backup | reboot | rename | rm | rmdir | rnmod
S
scp | shred | shutdown | sleep | sort | split | ssh | stat | su | sudo | sum
T
tac | tail | talk | tar | tee | time | tree | top | touch | tr
U
unalias | uname | uniq | unzip | uptime | users
V
vim | vi
W
w | wall | watch | wc | wget | whatis | whereis | which | who | whoami
X
xargs
Y
yes | youtube-dl
Z
zcmp | zdiff | zip | zz

Sharing is Caring
Scroll to Top