I have a tarball. This tarball contains—of course—various files and directories. When I extract the tar, some of these files already exist, while others don't.

What I would like to know is this: how can I extract a tarball to keep the metadata of already existing files intact (ownership, group, read, write, execute etc.), regardless who executes the command and what was the original directory layout upon tar creation?

So far what I have found are these:

--mode='555' --owner=owner --group=group

When I use these flags when creating the tarball, it actually does change the metadata of all the files in the tar accordingly. However I don't know how could I change it for a small set of files which should have other permissions.


As I understand this flag is used when extracting the tarball and should keep the metadata of already existing files, but I don't get the expected results.

  • I think you stumbled on some of the default arguments by chance. You don't want --owner or --group (you're going to get them anyway unless you're running as a privileged user) - I will assume from your arguments that you're running linux (not always a guarantee). Try `--skip-old-files --no-overwrite-dir --atime-preserve=''system' – quadruplebucky Jun 16 '17 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.