1

related to Tar without retaining directory and tar creation without directory to be retain

Hi All,

Thanks for making understand -C use to create a tar(tar -cf a/b/c/tarfile.tar -C a/b/c .) without retaining directory structure.

But when i un-tar its changing parent directory permission. Please help me understanding more about it. It should not change parent directory permission while extracting tar(tar -xvf).

Community
  • 1
  • 1
  • What parent directory permission is being changed exactly? Show us before and after `ls -l` output. Also show us the `tar -tvvf` output of your tarball. – Etan Reisner Jan 20 '16 at 13:30
  • Try using `--no-same-permissions` (although it should be the default, unless you are root) – Andrea Corbellini Jan 20 '16 at 13:40
  • This isn't a question about software development, which is StackOverflow's scope. Consider either SuperUser or http://unix.stackexchange.com/. – Charles Duffy Jan 20 '16 at 16:28
  • 1
    ...also, before asking it somewhere else, consider trying to build a standalone reproducer -- a script someone can run themselves, with no prior setup or configuration, that demonstrates the problem. For your example, that would mean creating and setting permissions on the directories at hand, including the directory that should not change, then running the untar and listing permissions of the directory that changed. – Charles Duffy Jan 20 '16 at 16:29
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Feb 04 '18 at 05:58

1 Answers1

3

The command

tar -cf a/b/c/tarfile.tar -C a/b/c .

has an entry for . (the directory which you are tarring). When you extract the tar, that directory's permissions apply. If you do not want this behavior, you can either

  • specify the names (other than just ".") that you put into the tar file, e.g., tar -cf a/b/c/tarfile.tar -C a/b/c foo
  • specify the names of the items you want to extract. You can see what is available using tar tvf using your tarfile as the parameter.
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105