I'm creating a tar file from a list of files with the -T option. When extracting the tar file, subdirectory permissions are root:root instead of the permissions on the directory itself? Any ideas how to fix this?


# cat filelist.txt




# tar cf files.tar -T filelist.txt

# tar xf files.tar

Ownership on extracted files match original ownership on file1.txt, file2.txt, and file3.txt Ownership on dir1 and dir2 does not match. Owner is root:root

I could follow a solution similar to Preserve ownership & rights of parent directory when extracting tar archive but was hoping there was another way as that might add up to some more work for a bunch of directories.


You need to back up the directories as well as the files, for which you have to do two things:-

1) Add the directories to your file list:


2) Add --no-recursion to the back-up run string to stop all the other files in the directories being included:

tar cf files.tar --no-recursion -T filelist.txt

Note that the order is important: the directories must precede any reference in a subdirectory or file; and the --no-recursion parameter must come before the -T, but after the cf FileName command.

| improve this answer | |

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.