Copy files without losing file/folder permissions
33 down vote favorite 20
How can I copy files/folders from an ubuntu computer on a ext4 filesystem to another ubuntu computer which also is on an ext4 filesystem, using a usb stick which uses a vfat filesystem without losing file permissions?
I've tried the basic ctrl-c from source computer, then ctrl-v to usb, then ctrl-c from usb then ctrl-v to target computer, and none of the file/folder permissions stay intact. 12.04 chmod shareimprove this question edited Oct 14 '13 at 4:49 Nathan Osman 20k30135229 asked Dec 5 '12 at 20:19 oshirowanen 1,561175589
add a comment 3 Answers active oldest votes up vote 48 down vote accepted
You can make a tar archive of the source, copy that to the other computer using the USB drive, and extract it there. Tar preserves file permissions.
1 - On the source computer:
cd /path/to/folder/to/copy tar cvpzf put_your_name_here.tar.gz .
2 - Copy put_your_name_here.tar.gz to the USB drive and then to the other computer
3 - On the destination computer:
cd /path/to/destination/folder tar xpvzf put_your_name_here.tar.gz
tar will recreate the archived folder structure with all permissions intact.
Those commands will archive the contents of the source folder and then extract them into the destination folder. If you want to copy the folder itself, then you should, at step 1:
cd /path/to/parent/folder tar cvpzf put_your_name_here.tar.gz folder_to_copy
The same mechanism could be used for single files.
If you can connect from one computer to the other using ssh, @siddharthart answer (rsync) might be more practical.
shareimprove this answer
edited Dec 6 '12 at 0:16
Marco Ceppi
show 2 more comments up vote 11 down vote
You could try rsync with -a flag to maintain all permissions while copying. I'm not aware of a simpler solution, but I had used it for a purpose in the past.
Rsync gives brilliant support to repeated copying, updating folders etc. while remaining blazingly fast. shareimprove this answer answered Dec 5 '12 at 20:31 SiddharthaRT 4,2481917
add a comment up vote 6 down vote
I think taring and then untaring should work on both files and directories.
to tar:
tar cvpfz /target.tar.gz /source/
to untar:
tar xvpfz /source/
The p flag stands for --preserve-permissions.
You should see man tar for more info. shareimprove this answer answered Dec 5 '12 at 20:35 mikewhatever 21k75880
https://askubuntu.com/questions/225865/copy-files-without-losing-file-folder-permissions