LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2015, 03:29 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,198
Blog Entries: 4

Rep: Reputation: 131Reputation: 131
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
 
Old 02-03-2015, 03:44 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,353

Rep: Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989
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.

Last edited by suicidaleggroll; 02-03-2015 at 03:55 PM.
 
Old 02-03-2015, 03:54 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,198
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
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.
 
Old 02-03-2015, 03:58 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,353

Rep: Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989
Quote:
Originally Posted by JockVSJock View Post
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).

Last edited by suicidaleggroll; 02-03-2015 at 04:00 PM.
 
1 members found this post helpful.
  


Reply

Tags
gid, permissions, tar, uid


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does Linux require a file/user to have a group? NotionCommotion Linux - Newbie 10 08-22-2014 11:38 PM
[SOLVED] extracting group of files from a tar.bz that was created with the following tar - lleb Linux - Newbie 1 06-06-2012 04:06 PM
[SOLVED] User can't access file that is accessible by a group she's in Eredeath Linux - General 2 08-05-2010 10:27 PM
gnu tar creates multiple odd directories with numeric names when extracting froff Linux - Software 2 02-05-2010 09:12 AM


All times are GMT -5. The time now is 05:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration