LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Installing .tar file changes user and group to a numeric value (https://www.linuxquestions.org/questions/linux-newbie-8/installing-tar-file-changes-user-and-group-to-a-numeric-value-4175532963/)

JockVSJock 02-03-2015 02:29 PM

Installing .tar file changes user and group to a numeric value
 
I'm trying to install a tar file and as root, when I use the following tar commands

Code:


tar -xvfp file.tar

or

tar -xf file.tar


For some reason, it strips out the user id and group id and replaces with the the following numbers: 544 for UID and 400 for GID.

Also, from what I'm reading, it looks like tar preverses permissions from one server to another, which I didn't know.

Because of this, I can't install this file, is there a way around this?

thanks

suicidaleggroll 02-03-2015 02:44 PM

You don't install a tar file. A tar file is just an archive full of other files, which could be anything (music, movies, data files, etc.). It's similar to a zip file.

What UID/GIDs get "stripped out"? Is it changing the permission of your existing files? Or are you just curious why the extracted files belong to a different user?

From the tar man page:
Code:

      --same-owner
              try extracting files with the same ownership as exists in the ar‐
              chive (default for superuser)

and
Code:

      --no-same-owner
              extract files as yourself (default for ordinary users)

So the reason it's preserving the owner is because you're extracting as root, which is generally not a good idea, since you don't know what could be in that file. Either way, root can still use the files regardless of their owner, because it's root. If you don't want to keep the original owner, then set the --no-same-owner flag in tar. And regardless, you can always just chown/chmod the files/dirs after they're extracted to change them to whatever you want.

JockVSJock 02-03-2015 02:54 PM

I did use the -p flag and that didn't work, still the same issue.

I went back and used the --no-same-permissions and that worked. I didn't realize that a non-root user can use that. Learn something new everyday.

suicidaleggroll 02-03-2015 02:58 PM

Quote:

Originally Posted by JockVSJock (Post 5311457)
I did use the -p flag and that didn't work, still the same issue.

I went back and used the --no-same-permissions and that worked. I didn't realize that a non-root user can use that. Learn something new everyday.

The -p flag was already doing what you didn't want tar to do.

root and regular users extract tar files differently, as explained in the man page.

root preserves all permissions and owners from the archive, but this can be changed with --no-same-owner and --no-same-permissions.

Regular users extract the files as themselves with their default umask, but this can be changed with --same-owner and --same-permissions (which is what -p does).


All times are GMT -5. The time now is 05:17 AM.