Contents
How to change the ownership of a tar file?
I am working as user, and I would like to create a tar archive, which when unpacked (by root) will extract its files with root ownership (otherwise root would have to change the ownership manually for each file, after the files have been extracted to its destination). I have found fakeroot which seems to do exactly that.
Can you create a tar file with contents belonging to a group?
I would like to create a tar file with contents belonging to an owner:group pair who do not exist on the system from which the file is being made. Here’s the direction I’ve tried:
Which is the best command to create a tar file?
The most common uses of the tar command are to create and extract a tar archive. When extracting an archive use the tar -xf command followed by the archive name and to create a new one use tar -czf followed by the archive name and the files and directories you want to add to the archive.
How to create a tar.gz archive in Linux?
For example, to create a tar.gz archive from given files, you would run the following command: Another popular algorithm for compressing tar files is bzip2. When using bzip2, the archive name should end with either tar.bz2 or tbz. To compress the archive with the bzip2 algorithm, invoke tar with the -j option.
Can you create a tar file as a non privileged user?
Your tar file referred to user/group which do not exist on the system where you extracted it. If you extract files as yourself (a non-privileged user), you can only create files owned by yourself. When extracting an archive, tar will attempt to preserve the owner specified in the tar archive with this option present.
Can you re-tar a tar.gz file?
If it’s not a very large archive, it might be better to untar the whole thing and then re-tar it after editing. Alternately, you could use an uncompressed archive. Tar was originally meant to be used for tapes, so “replacing” files is not really in the design.
Can you rename a file in a tar archive?
It shouldn’t be very difficult, at least for archives that are compatible with the old-style format where file names are stored in a fixed-size (100 bytes) field, but I don’t know of any tool that can rename a file in place in a tar archive. Besides, with a compressed archive, you’d need to create a new file anyway.