[CentOS] Tar of files

Wed Mar 3 15:41:42 UTC 2021
Stephen John Smoogen <smooge at gmail.com>

On Wed, 3 Mar 2021 at 09:54, Jerry Geis <jerry.geis at gmail.com> wrote:

> When I "tar" up an archive the files have an owner bob,
> when I extract that to another machine bob is there also but user number is
> different.
> So when I extract bob is no longer the owner of the files but someone else.
> Is there a good way to account for this ?
> User ID on one box being different to the next box ?
> I was expecting to untar and bob still be the owner .
The system has no way of knowing that bob:uid1 and bob:uid2 are the same
person and in fact on a lot of systems they are not (aka if you downloaded
a tar ball from my box and it had the user bob on it.. it definitely is not
your bob).

The ways to do this are any of the following or a list of ones not there.
1. find ./tree_you_untarred -uid <bob1_uid> -print0 | xargs -0 chown bob2
2. su bob2 (cd /tree_place_to_untar; tar xzvf <file you wanted to untar>)
3. use gnu tar's many options to create the tar file with the correct
uid/gid you wanted using --owner --group (or a map if there are multiple).

> Thanks,
> Jerry
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos

Stephen J Smoogen.