Is it possible to tell tar to unpack the archive and set the uid/gid to a specific one, when you run tar as root (while using chef) ?
Things I already know:
- I can use
-o
to extract as root, thenchown uid:gid
afterwards --owner
and--group
apparently only work when adding file, not when unpacking
It would be really convenient to be able to specify the owner while unpacking. Is that possible ?
Best Answer
Oddly enough, you can get closer to what you want using (GNU)
cpio
with your tar archive. GNUcpio
supports tar format files, and provides the-R
command line option to set the user and group of extracted files. This option controls the ownership of all files, not specific files.All this means that you can run, as root, the following command...
...and it will extract all the files owned by user
user1
and groupgroup1
.