Drew C. Decker

Linux Systems Administrator, Solutions Implementer, Technology Enthusiast, Husband, and Dad


Generating Checksums on Solaris 9/10

Just the other day, I was needing to generate checksums of files and compare them through a shell script; useful when you want to know when a file has been changed without comparing what has been changed.

On Linux, it's pretty simple (md5sum), however, on Solaris, it's a totally different set of commands - and on top of that - Solaris 9 and 10 are totally different. First thing though, my disclaimer is, I'm using stock Solaris 9 and 10 machines and I am well aware that I could install md5sum and/or the Solaris 10 equivalent onto the Solaris 9 machine, however I assume that you cannot just install software without proper change management schedules.

Solaris 9

## Full Format
[root@server:~]# cksum /dev/null
4294967295      0       /dev/null

## Only display the checksum
[root@server:~]# cksum /dev/null | cut -f1
4294967295

Solaris 10

cksum

## Full Format
[root@server:~]# cksum /dev/null
4294967295      0       /dev/null

## Only display the checksum
[root@server:~]# cksum /dev/null | cut -f1
4294967295

digest

## Full Format - MD5
[root@server:~]# digest -v -a md5 /dev/null 
md5 (/dev/null) = d41d8cd98f00b204e9800998ecf8427e

## Full Format - SHA1
[root@server:~]# digest -v -a sha1 /dev/null     
sha1 (/dev/null) = da39a3ee5e6b4b0d3255bfef95601890afd80709

## Full Format - SHA256
[root@server:~]# digest -v -a sha256 /dev/null   
sha256 (/dev/null) = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

## Full Format - SHA512
[root@server:~]# digest -v -a sha512 /dev/null 
sha512 (/dev/null) = cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e

## Only display the checksum - MD5
[root@server:~]# digest -a md5 /dev/null          
d41d8cd98f00b204e9800998ecf8427e

## Only display the checksum - SHA1
[root@server:~]# digest -a sha1 /dev/null    
da39a3ee5e6b4b0d3255bfef95601890afd80709

## Only display the checksum - SHA256
[root@server:~]# digest -a sha256 /dev/null  
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

## Only display the checksum - SHA512
[root@server:~]# digest -a sha512 /dev/null    
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e

For comparing files, I usually just use mksum or MD5 algorithm.

Comments