I have noticed that a tarball created on one linux does not preserve the file permissions when extracted on another linux.
How can I make tar preserve the file permissions?
By default, tar will preserve file permissions and ownership when creating the archive. To extract file permissions and ownership, you will need to run tar as root when extracting, since changing file ownership usually requires superuser privileges.
Preserve File Permissions Using cp You can use the -p option of cp to preserve the mode, ownership, and timestamps of the file. However, you will need to add the -r option to this command when dealing with directories. It will copy all sub-directories and individual files, keeping their original permissions intact.
Preserving the symbolic linksBy default, the tar utility archives the symbolic links such that they can be restored when the archive is unpacked and saves hard-linked files only once within the archive. From the size of the file archive.
The * is what tells tar to include all files and local directories recursively. The tar command will never move or delete any of the original directories and files you feed it – it only makes archived copies. You should also note that using a dot (.)
Can you try:
tar -pcvzf xxx.tar.gz
p == preserve permissions
c == create archive
v == verbose (print names while making tar)
z == gzip
f == tar file name
Source
Use the p
option, both when creating the tarball and when extracting it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With