Why doesn't tar save file permissions?

I noticed that a tarball created on one Linux does not preserve file permissions when retrieving on another Linux.

How can I make tar save file permissions?

+7
linux tar
source share
3 answers

Use the p parameter, both when creating the tarball and when retrieving it.

+5
source share

Can you try:

 tar -pcvzf xxx.tar.gz 

p == save permissions
c == create archive
v == verbose (print names when creating tar)
z == gzip
f == tar file name

A source

+14
source share

A quick overview of the man page explains your problem:

  -p, --preserve-permissions, --same-permissions extract information about file permissions (default for superuser) 

But remember that expanding your archive on some file systems, such as FAT, will not save permissions because they do not support it.

In addition, numerically saving the owner / access time may be of interest to you:

  --numeric-owner always use numbers for user/group names --atime-preserve preserve access times on dumped files, either by restoring the times 
+3
source share

All Articles