Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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?

share|improve this question
up vote 0 down vote accepted

From the man page for GNU tar:

       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.

share|improve this answer
Thanks, but this has no effect. Also, from the same manual: "permissions can be specified either as an octal number or as symbolic permissions, like with chmod". So even the numbers should work. But neither do. Tested under Ubuntu and CentOS - neither work. – user60129 May 29 '11 at 14:32
Maybe the "p" flag is required too during extraction. – Tom Shaw May 29 '11 at 14:41
I just realized you were using --mode during extraction. Isn't it just for creation of the tar? – Tom Shaw May 29 '11 at 14:48
I did not read anywhere if this is for creation only. But it would explain my problem. However, I can not change the way the tar is created, only the way it is extracted. Is there a way to extract with certain permissions? – user60129 May 29 '11 at 15:31
You could always extract it and then follow up with a "chmod" command (either recursive or inside a "find") – Tom Shaw May 29 '11 at 23:41

Your Answer


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