Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I create a file in Ubuntu, it creates with only read/write permissions for the owner. But if I copy a file from a fat32 USB drive, the file permissions give read/executable powers to Owner,Group and Others.

How do I make files copied from a USB drive adopt the same file permissions as other files in Ubuntu?

share|improve this question
I don't care what the permissions are on the USB stick. When the files are on my desktop (after being copied from USB) I want the permissions to automatically change to the system's permission levels. For example, if I create a file on my computer it takes on the default permission state. I want files added to my computer from USB to do the same. – user9770 Jan 28 '11 at 18:19

Unix-like ownership and permissions are not compatible with fat or ntfs filesytems. If you need your permissions to stick when copied to another drive, better format it with an ext* type filesystem. If it's a flash drive, better yet with ext2 to reduce writes to the drive. The downfall is that it will render the drive unreadable in windows (and unbootable if you use it for instalations). Another way is to make an archive (.tar.gz) with the file(s) and copy the archive, that way you'll preserve the permissions.

share|improve this answer
No. I want files that are added (ie, copied) to my ext3 file system from a FAT file system to adopt the same file permissions that files get when they are created on the ext3 file system. – user9770 Jan 28 '11 at 13:54
I really don't get your point. If the file in your computer is owned by "Nick" and group "Nick" with 0644 permissions, and you copy it as an archive to the USB stick, when you copy it back to your computer it will still retain the same owner-group-permissions. If you copy the file in your computer to another drive formatted as ext* without an archive, when you copy it back to your computer that file will retain "Nick:Nick 0644". If you copy it to another Linux computer where the same user:group doesn't exist, it will still retain the 0644. – nejode Jan 29 '11 at 12:17
Nejode, I am speaking to files that are created on MS Windows. For example, my friend wants to give me a file. He copies it to my USB drive from his NTFS Windows 7 hdd. I take it home and copy it to my Ubuntu ext3 Hard Drive. The file permissions will be -rwx rwx rwx once it lands on my hdd. For security I really want to prevent it landing with executable capabilities. – user9770 Jan 31 '11 at 15:12
Ok, now I get the idea. I have that same problem with a public samba share at work. When a windows machines copies a file remotely to that share it has nouser:nogroup -rwx rwx rwx "owner-group-permissions"... umask is a "create" mask, not a "copy" mask and doesn't work either. What I had to do was to run "chmod -R 755 public" to the public directory from time to time; or right click the directory, then Propierties > Permissions, and change them there while ticking on the "recursive" checkbox before apply. Havn't found a solution for that yet... maybe with a cronjob to automate te process! – nejode Jan 31 '11 at 15:12
Okay, thanks nejode. So you don't have a way to automate the permissions either. I guess I'm stuck having to do it manually like you for the time being :) – user9770 Jan 31 '11 at 15:14

To set permissions for copied files that come from a non-Unix filesystem such as FAT32 use

rsync --chmod=CHMOD source destination

where CHMOD is your desired permissions for the copied file(s). Replace CHMOD by e.g. 0644 will give read/write access to the owner and read-only acess to all other users. For further copy options see rsync manpage.

share|improve this answer
Will this be a "permanent" setting? I do not want to have to do this every time I mount a USB drive. I'm looking for a system-wide setting that will auto-assign all copied files that originate from FAT the same file permissions (for example, I'd like to assign dmask=077, fmask=177 if possible) – user9770 Jan 28 '11 at 13:57
no not permanent, not system-wide (would be unwantedly dangerous), only for the single issued command. For your purpose you could e.g. write this in a script or use a rsync GUI frontend. – Takkat Jan 28 '11 at 14:18

The best answer that I can give you is to use a UNIX/Linux based archival tool, like tar(1) or cpio(1). That will preserve the date and permissions of the file(s), but the archive file itself we don't really care about. tar cf /media/stickdrive/foobar.tar path/to/my/file

share|improve this answer
I don't wan't to preserve anything. I want to prevent files that are copied from a FAT file system from showing up on my ext3 file system with executable permissions. For example, I do not want a copied jpg file to have executable permissions by default. – user9770 Jan 28 '11 at 13:55
If your USB stick has the FAT filesystem, then individual files cannot preserve the Unix permissions. There's nothing you can do about that. However, the workaround of using tar is actually quite good. Alternatively, you can use 7Zip which is quite trendy. – user4124 Jan 28 '11 at 15:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.