0

Usually as far as I know when extracting files with tar the users umask should be used for new permissions. My umask is 0007. So when I create new files they have the permission: -rw-rw----

I have a tar file that contains files with these permissions: -rw-r--r--

When I extract the tar file using tar -xzf file.tar.gz the files change their permissioning to -rw-r-----

So the permissions change but the groups write permission is missing.

Am I missing something?

1 Answer 1

1

The umask doesn't outright replace the permissions, it is applied to the base permissions that the program specifies when trying to create a file. Its purpose is only to remove permission bits, that's why it's called a "mask".

For example, when you use touch, it asks the OS to create a file with permissions 0666 and after applying the umask to it you get 0666 & ~0007 = 0660.

However, when tar is extracting your file which was 0644, the umask is applied to that 0644 so the final result is of course 0644 & ~0007 = 0640.

In short, the umask can only make permissions more restrictive, not less. (Similarly, when e.g. ssh-keygen wants to create a 0600 file to hold your private key, it will still remain 0600 even after the umask has been applied – it will never become 0644 nor 0660 nor something else.)

1
  • So there is no way to accomplish this without manually changing permissions afterwards? Commented Jun 1, 2021 at 8:00

You must log in to answer this question.

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