Tar “mode” flag is being ignored

command-line-interfacetar

I try to tar a file and set the permissions to 666 using the mode flag. But whatever permission I set, it is simply being ignored. Command:

tar xvzf backup.tar.gz --mode=666 -C /home/user/

Till all files show up with their original permissions.

Am I doing something wrong?

Best Answer

From the man page for GNU tar:

 --mode=CHANGES
       force (symbolic) mode CHANGES for added files

The key word there is symbolic. You've used numeric permissions. The corresponding symbolic mode for 666 is a=rw.

However, even if you make this change it will probably not do what you want because it will remove the execute flag from directories. Maybe what you really want is a+rw which will only add flags, not remove them.