From man 1 tar
:
[...]
-p, --preserve-permissions, --same-permissions
extract information about file permissions (default for superuser)
[...]
--no-same-permissions
apply the user's umask when extracting permissions from the archive
(default for ordinary users)
[...]
From this I understand that by default extracted files' permissions are set based on the user's umask, unless the user is root:
% umask
002
So files extracted by me should have permissions 664
(666
-002
).
However:
% touch foo
% chmod +x foo
% ls -l
total 0
-rwxrwxr-x 1 user user 0 nov 3 19:36 foo
% tar cf foo.tar foo
% rm foo
% tar xf foo.tar
% ls -l
total 12
-rwxrwxr-x 1 user user 0 nov 3 19:36 foo
-rw-rw-r-- 1 user user 10240 nov 3 19:36 foo.tar
I.e., Tar is preserving the permissions of the original file even though I didn't pass the -p
, --preserve-permissions
or --same-permissions
switch.
Nonetheless if I pass the --no-same-permissions
switch:
% tar xf foo.tar --no-same-permissions
% ls -l
total 12
-rwxrwxr-x 1 user user 0 nov 3 19:36 foo
-rw-rw-r-- 1 user user 10240 nov 3 19:36 foo.tar
Still Tar is preserving the permissions of the original file.
Can someone please explain why is that?
002
applied on a file with permissions775
doesn't change anything. I knew it was a silly thing, thanks. Do you mind posting that as answer? – kos Nov 03 '15 at 20:35