I'm using an ubuntu server and the project I am working on has very strict requirements regarding making sure data is not corrupted. I can't seem to find a good answer on this, when doing a local copy of files to a new directory, is it necessary to do an Md5sum, or does the operating system do this sort of check by default to make sure the file transfer goes through properly?

| |

Neither cp nor any of the common (or uncommon) desktop environment's file managers will check md5 sums after they copy. You will need to do that yourself. Depending on the type of file manager you use, or through the use of scripts, you could automate the check.

Also be aware that sha1 is a strong algorithm than md5 if you are looking to do more than just "checksum" the copy.

| |
  • thanks for the info, interesting about sha1, but the Project manager wants md5 so I don't care to bother trying to change his mind :) – Rick May 18 '11 at 0:03
  • 4
    MD5 is enough; you don't need it to be cryptographically secure since bit errors will result in a different hash. – Ignacio Vazquez-Abrams May 18 '11 at 0:13

well, you could probably use rsync locally to do that - it has its own rolling checksum algorithm and it'd be more painless than checksumming each and every file.

| |
  • I'm going to be doing it from or Java app so its not a big deal to code it up to do the check automatically – Rick May 18 '11 at 0:08

One option that might be easier than using md5sum in file copying is to use rsync with the -c option. rsync is a capable file copying and backup command. For example, to copy the contents of /src/foo to /dest/foo:

rsync -acv /src/foo/ /dest/foo

Note the idiosyncratic use of the trailing slash in the first parameter.

See the man page for rsync for more details.

Edit: -c is for "checksumming".

| |

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.