11

I was looking this question and appears everything but crc. Is there a good Ubuntu way around there to do this?

17

As always(maybe sometimes), google is my friend:

$ sudo apt-get install libarchive-zip-perl
$ crc32 my_file
| improve this answer | |
  • 2
    perl-Archive-Zip in fedora, mind you – Nemo Dec 18 '15 at 13:00
  • Very helpful for comparing that a file inside a JAR is the correct version. – jjj Oct 6 '17 at 15:40
  • 2
    Adding to what Nemo said, for CentOs, Redhat, Fedora, and similar distros the library is installed with yum install perl-Archive-Zip – Terry Sep 25 '19 at 19:33
14

One way to calculate it is this:

cksum "file"

Another one is

crc32 "file"

To use this last command you need to install libarchive-zip-perl package

| improve this answer | |
  • 6
    cksumis not compatible with crc32, it uses different algorithm – red75prime Apr 27 '18 at 8:29
4

I'd use the internal md5sum one of the provided sha programs:

sha1sum (1)          - compute and check SHA1 message digest
sha224sum (1)        - compute and check SHA224 message digest
sha256sum (1)        - compute and check SHA256 message digest
sha384sum (1)        - compute and check SHA384 message digest
sha512sum (1)        - compute and check SHA512 message digest

cksum is pretty much outmoded these days because of its problems.

| improve this answer | |
  • 1
    What problems? I want to know if two files are duplicates - is cksum not good enough for that purpose? – Marc.2377 Nov 24 '19 at 6:06
  • Perhaps the "problem" is the fact that CRC is not a cryptographic hash (meaning it's considered easy to create two files with different contents that have the same CRC if that's what you're trying to do). However, when you're talking about random errors, CRC is not too bad AFAIK. – AnthonyD973 Jan 28 at 19:28
2

cksfv app from cksfv package generates CRC32 checksum as well.

| improve this answer | |
  • 2
    could you give a usage example? – Zanna Dec 8 '16 at 6:58
  • cksfv -c "file" prints the CRC32 to stdout. If you want to suppress the header, a cksfv -c "file" 2>/dev/null | grep -v ^\; gives the filename + CRC32 and no warning for a directory. – emk2203 Jun 14 '19 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.