linux命令之shasum

1.shasum介绍

linux命令shasum用于核实文件传输结束后的完整性。通常在网络传输文件的过程中,可能造成文件丢失,所以可以用来检查文件传输是否完整。

2.shasum用法

shasum [参数] [file]

[root@elasticsearch ztj]# shasum -h
Usage: shasum [OPTION]... [FILE]...
Print or check SHA checksums.
With no FILE, or when FILE is -, read standard input.

  -a, --algorithm   1 (default), 224, 256, 384, 512, 512224, 512256
  -b, --binary      read in binary mode
  -c, --check       read SHA sums from the FILEs and check them
  -t, --text        read in text mode (default)
  -p, --portable    read in portable mode
                        produces same digest on Windows/Unix/Mac
  -0, --01          read in BITS mode
                        ASCII '0' interpreted as 0-bit,
                        ASCII '1' interpreted as 1-bit,
                        all other characters ignored

The following two options are useful only when verifying checksums:
  -s, --status      don't output anything, status code shows success
  -w, --warn        warn about improperly formatted checksum lines

  -h, --help        display this help and exit
  -v, --version     output version information and exit

When verifying SHA-512/224 or SHA-512/256 checksums, indicate the
algorithm explicitly using the -a option, e.g.

  shasum -a 512224 -c checksumfile

The sums are computed as described in FIPS-180-4.  When checking, the
input should be a former output of this program.  The default mode is to
print a line with checksum, a character indicating type (`*' for binary,
` ' for text, `?' for portable, `^' for BITS), and name for each FILE.

Report shasum bugs to mshelor@cpan.org
[root@elasticsearch ztj]# 

3.shasum样例

命令:

shasum -a 512 -c elasticsearch-7.11.1-linux-x86_64.tar.gz.sha512

#检查elasticsearch-7.11.1传输后的完整性

[root@elasticsearch ~]# cat elasticsearch-7.11.1-linux-x86_64.tar.gz.sha512 
49db18ecb8c67dd904106165f599d5757f5ce3cdbe5835e8d4babf85f5274368b45fb6bbaf23350107305904ea1823d929444858cf3df686df3c52e8506ce569  elasticsearch-7.11.1-linux-x86_64.tar.gz
[root@elasticsearch ~]# shasum -a 512 -c elasticsearch-7.11.1-linux-x86_64.tar.gz.sha512 
elasticsearch-7.11.1-linux-x86_64.tar.gz: OK
[root@elasticsearch ~]# 

命令:

shasum -a 512 aaa >aaa.sha512

shasum -a 512 -c aaa.sha512

[root@elasticsearch ztj]# shasum -a 512 aaa >aaa.sha512
[root@elasticsearch ztj]# shasum -a 512 -c aaa.sha512
aaa: OK
[root@elasticsearch ztj]# 

#创建自定义文件shasum,并进行校验(文件传输后,如果传输后,文件内容有变化,校验会失败)

[root@elasticsearch ztj]# echo aa > aaa
[root@elasticsearch ztj]# shasum -a 512 -c aaa.sha512
aaa: FAILED
shasum: WARNING: 1 computed checksum did NOT match
[root@elasticsearch ztj]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值