LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help understanding tar xvf and permissions (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-understanding-tar-xvf-and-permissions-4175441331/)

misterpiddles 12-13-2012 11:54 AM

Need help understanding tar xvf and permissions
 
We have a QA and production server being set up for a new site. There are a group of files in several different directories I'd like to be able to copy from QA to production once they've been tested in QA.

In QA we have super-user root authority. In production we do not. So if we create new files in QA, they typically have owner and group of 'root.'

So I created an .sh file in QA that creates a .tar file of all the affected files (about 20-25). I create the .tar file in QA then move the .tar to PROD.

The problem is when I extract the .tar file in production via 'tar xvf file' I typically get several permission errors such as:

Cannot open: File exists
Cannot utime: Operation not permitted
Cannot change mode to rwxr-xr-x: Operation not permitted

My questions are:
1) When I create the .tar file from QA, is it also storing the owner and group names for each file?

2) If any of the files in the .tar are new to production and were created in QA via the superuser root, does that cause problems copying to production because in prod we don't have superuser authority? In QA should we be using the same group name we use in prod?

3) In the case of "Cannot open: File exists" errors, I was able to fix some by changing the prod group name, but in other cases, even when giving 777 file authority, I continued to get this error message.

Man, I'm confused. Any guidance appreciated. Let me know if I can provide more detail.

shivaa 12-13-2012 12:07 PM

Does both QA and production servers use any name service? that means, can they identify same user account?
Well, it depends. It do store ownership, but owner's account (i.e. same username) should be present on both servers. If both servers are using a name service and both can identify same user, then you'll not have any problem in copying/extracting tar files.

misterpiddles 12-13-2012 12:51 PM

Quote:

Originally Posted by shivaa (Post 4848637)
Does both QA and production servers use any name service? that means, can they identify same user account?
Well, it depends. It do store ownership, but owner's account (i.e. same username) should be present on both servers. If both servers are using a name service and both can identify same user, then you'll not have any problem in copying/extracting tar files.

Both production and QA recognize the same user account, call it "NiceGroup." The owner's account, however is not the same in production. In production, when we sign on to the server, we use the id of, call it "ProdOwner." So if we copy a new file to prod, instead of "root" or "NiceGroup" as the owner as on QA, we have "ProdOwner."

So in prod, many files have "ProdOwner" for the owner, and "NiceGroup" for the group.

Is the simplest thing to do, for both QA and prod, to have the owner and group both be "NiceGroup"?

shivaa 12-13-2012 01:11 PM

It means, you can login into production from QA using ssh or telnet etc. Then tar file will carry it's ownership/group after copy into QA.
Once try following from QAServer:
QAserver# scp -r ProdOwner@prodserver:/path/to/source/example.tar /path/to/target/
And check what ownership it has, using:
Code:

ls -l example.tar
Then you can:
Code:

chown qauser:qagroup /path/to/target/example.tar

misterpiddles 12-13-2012 02:10 PM

Quote:

Originally Posted by shivaa (Post 4848686)
It means, you can login into production from QA using ssh or telnet etc. Then tar file will carry it's ownership/group after copy into QA.
Once try following from QAServer:
QAserver# scp -r ProdOwner@prodserver:/path/to/source/example.tar /path/to/target/
And check what ownership it has, using:
Code:

ls -l example.tar
Then you can:
Code:

chown qauser:qagroup /path/to/target/example.tar

Thanks, shivaa. I'll have to run some tests since I'm a newb and haven't gone quite this deep before, but thanks for the info!

shivaa 12-13-2012 02:25 PM

Quote:

...I'm a newb and haven't gone quite this deep before
No problem, but just a tip:- If there's any name service (I actually doubt there's any such setup between QA and production) like NIS, NIS+ or LDAP, then there will be no problem in copying, accessing or extracting etc. But if it's not there, and both server maintains there own /etc/passwd to manager there users, then you might need to do some extra work, as mentioned above :)


All times are GMT -5. The time now is 09:55 AM.