0

I'm performing a backup of some server files that are owned by the server user. If I try to backup them up using the tar command I get:

tar: ./somedir Cannot open: Permission denied
tar: Exiting with failure due to previous errors

However if I do sudo tar ... then everything appears to archive file. Will this change any file ownership / directory ownership / permissions on any of the files being archived?

3

It shouldn't change, as long as you extract the archive also as superuser.

There are few interesting options. Note the default behavior. From man tar:

--same-owner
   try extracting files with the same ownership as exists in the ar‐
   chive (default for superuser)

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

Additionally you may want to read the answers to this question on Ask Ubuntu.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.