The kernel problem with recent updates has been solved. Find the solution here

Important information
-- Required MX 15/16 Repository Changes
-- Information on torrent hosting changes
-- Information on MX15/16 GPG Keys
-- Spectre and Meltdown vulnerabilities

-- Introducing our new Website
-- MX Linux on social media: here

Current releases
-- MX-18.3 Point Release release info here
-- Migration Information to MX-18 here
-- antiX-17.4.1 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Verify if files have been copied correctly

Post Reply
User avatar
Forum Regular
Forum Regular
Posts: 307
Joined: Thu Jul 13, 2006 6:35 pm

Verify if files have been copied correctly


Post by outlaw » Sat Apr 28, 2018 10:01 am

I want to copy / transfer files from location to another then verify the files were copied correctly.

One technique to verify if a group of files has been copied correctly to another location would be to:
1) Create a archive of the files ... (tar, cpio or bz - whatever)
2) Create a md5sum for the archive then copy or transfer the archive to the new location.
3) Then create a new md5sum for the archive in the new location.
4) Use diff to compare the 2 md5sum files.

Can cp or another command be used to accomplish this task.
I need to copy all files in the specified directory and sub-directories.

Thanks in advance for any advice / suggestions offered.

Naturally nuts no pharmaceuticals required :happy:

User avatar
Forum Veteran
Forum Veteran
Posts: 9945
Joined: Wed Jul 12, 2006 1:42 am

Re: Verify if files have been copied correctly


Post by Adrian » Sat Apr 28, 2018 10:15 am

rsync checks md5 of the copied files use that, it also gives you nice option to update the copied files without having to copy all the stuff again.

User avatar
Forum Veteran
Forum Veteran
Posts: 4053
Joined: Wed Apr 11, 2018 5:09 pm

Re: Verify if files have been copied correctly


Post by fehlix » Sat Apr 28, 2018 12:34 pm

If rsync together with md5-checksum does not fit into your file-transfer scenario
an alternative approach would be to recursively create a checksum file of that directory tree
and transfer this checksum file with the transfered files itself.
For checking file transfer success shortly after it took place
md5-checksum might sufficient. But as md5 does have a well-known collusion security-issue
I would not recommend using it for anything else. I.e. if you are going to verify
the checksum long time after the file transfer took place a better approach migth be to use sha256.
To use the more collusion-robust sha256 in combination with creating a hashsum tree
here en axample:

Code: Select all

# to get recursive hashsum-tool hashtree
# sudo apt-get install hashtree
# my source dir
cd $DIR
sha256deep -lr . | tee $DIR.sha256
# to verify after transfer use
echo "sha256sum -c $DIR.sha256"
Happy hashing :happy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

Post Reply

Return to “Desktop Environment”