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.

  • vfat does not support unix filesystem permissions. You will need to store them in a tarball, or something similar, if you want to preserve them.
    – Alex L.
    Dec 5, 2012 at 20:37
  • why not rsync, as i suggested? Dec 6, 2012 at 21:25

3 Answers 3


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.

  • Don't forget the -p flag to tar to ensure permissions are preserved.
    – haziz
    Dec 5, 2012 at 23:47
  • @haziz Actually, the -p isn't really needed, see my comment to @mikewhatever's answer. The -z also isn't necessary when untarring, as tar is able to figure out the type of compression itself, unless it's an old version. Including the flags in the command doesn't hurt, tough. Dec 6, 2012 at 0:54
  • 4
    I don't think you can count on this behavior. BTW quoting from the man tar page "-p, --preserve-permissions, --same-permissions extract information about file permissions (default for superuser)" this appears to be the default behavior only if tar is ivoked as superuser. Would not count on this as default behavior. I would also always explicitly spell out the -z flag when compressing or decompressing (or -j if using bzip2).
    – haziz
    Dec 6, 2012 at 1:07
  • Could (basic) encryption be easily added? (I guess there'd be many ways of doing it, but I'm wondering, but if done via the command line, how would the password / encryption key/passphrase be supplied? Like so ******** or like the sudo-password, where no key-strokes are made visible?) Apr 29, 2013 at 5:58
  • tar suffers from a very serious problem - it chokes on paths longer than 100 characters. Nov 10, 2015 at 4:30

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.

  • 6
    I do like rsync (love it, in fact :-]), but the ext4 file permissions will be lost if the destination device is vfat formatted, like oshirowanen described. The tar solution is better in this case.
    – yuric
    Jan 31, 2013 at 14:17

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.

  • I just did a quick test to be sure and -p is not needed -- tar preserves permissions by default, at least when the user owns the files being archived/extracted. Dec 5, 2012 at 21:05
  • 2
    True, but you've not told us what files you wanted to copy, and I had no reason to assume anything on my own. Dec 5, 2012 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .