1

Lets suppose a file is being owned by a user named mrxyz with UID and GID 1000, and has RW permissions for the file (esp. in ext file-systems). Now if the file is brought to my system will my user hash with UID 1000 inherit the permissions or will I have to make changes to fit my context? So basically, I want to know how changing ownership and permission with chown and chmod work from portability point of view?

PS. It was a curiosity raised in this comment "...would there be issues with permissions/ownership if I plugged the disk into another box?" that I posted this Q. (So, it would be great to have answers covering portability of files as well as filesystem.)

2
  • What do you use for transport? Also an ext filesystem? scp or NFS? Do you use tar (as @Timo suggested)?
    – Zelda
    Jan 17, 2014 at 9:57
  • portable USB storages.. actually I was concerned more with how the permissions for normal files (I do use archive files too, when I need to preserve more of the metadatas with my files) would behave across systems in such devices..
    – rusty
    Jan 17, 2014 at 10:30

2 Answers 2

7

It depends on how you bring it to your computer and who and how you extract that file.

In a .tar file both the user name and UID are written. If you extract that as yourself, the files get your UID and GID, if you try to extract it as root it will try to restore the UID based on the username and failing to find that based on the UID. The permissions are normally influenced by your umask when extracting as normal user, not when extracting as root. Several commandline options for tar influence that (--numeric-owner, --preserve, --same-permissions).

Other programs like cpio have similar behaviour, but of course different commandline options.

Assuming that you extract as yourself (and not as root), your current umask is probably the defining factor. Try that out and if you have specific problems with your transport mechanism getting things to work, come back and ask (or update the question).

3
  • nice... and please, if you could also include how they would carry with file systems in portable devices..
    – rusty
    Jan 17, 2014 at 7:37
  • @hash it all depends on how you intend to move things around, please extend your question with that information (medium, filesystem on medium, direct or tarred/zipped). If you copy a file to FAT without putting it in a tar (or zip or cpio) file, you loose a lot of info.
    – Timo
    Jan 17, 2014 at 7:53
  • it's portable USB storages.. and already stated in the Q with ext filesystem (ext4 to be more precise).. I do get what you've written about .tar files, and about the incompatibility of Unix permission with FAT, NTFS systems.. to summarize, it's normal files in ext4 partitioned USB drive.
    – rusty
    Jan 17, 2014 at 10:45
0

Only the UID counts. If ls -l shows a file as owned by tstaerk on my computer it may well be hash on your computer. Then you are allowed to modify (in case of rwx------). This is usual not only in ext file systems.

You must log in to answer this question.

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