# unzip and retain original ownersip/permissions



## collingwood (Oct 13, 2008)

Hi all 

(first time poster)

I develop on XP but host sites on a Linux VPS. To speed the upload process I zip the site on mp XP machine, ftp the zip file to the server and then SSH to the server and 'unzip' the file.

This works fine most of the time, however in one particular application there are some important permissions that I need retained. XP of course has no specific permissions and therefore unzip applies the default umask and the currently logged on users ownership and group. What I really need is the original ownership of the existing file retained.

Any ideas how this can be done?

Cheers
mc


----------



## Sugi (Mar 6, 2008)

I am unsure of what you are asking for? You want the permissions of a zipped windows xp file to go over to an Unix/GNU system to remain the same permission? Or you want a Unix/GNU zipped file permission to remain the same while transing to Windows XP? But as you stated before Window's OS and Unix/GNU's OS has two different permission tree if you will. So, that's an issue already.

As what I have seen in transfering files between the two OSs usally anything from Window's base OS will require a root access to write to the original file. And anything from an Unix/GNU's base OS will be write-able as default.

Hope that helps some,
Sugi

PS: Please reply with more details


----------



## collingwood (Oct 13, 2008)

Okay - being really specific:

XP file: index.php - no particular permissions
XP zip of index.php to site.zip

FTP site.zip to Linux machine

Linux now has two files: 
index.php user7 group2 -rw-rw-r-- (this is the existing file that will be replaced)
site.zip ftpuser group1 -rw-r--r-- (this has been created via ftp)

Linux - now I unzip the site.zip file and I will be overwriting index.php, what I want is:
index.php user7 group2 -rw-rw-r-- (the new file with the same ownership etc)

Linux - but what I get is:
index.php collingwood group1 -rw-r--r-- (the ownership of me currently logged in)

Hope this is clear.

Cheers
mc


----------



## lensman3 (Oct 19, 2007)

Piece of cake!!! Sort-of.

Add group1 to the /etc/group file using /usr/sbin/groupadd. 

"/usr/sbin/usermod -G group2 collinswood" (you already belong to group1 because your administrator set that up for you)

If you run the command "groups" you should see that you now belong to two groups "group1" and "group2"

You are going to have to setup "user7" the normal way of adding a new user. To become the new user just do "su - user7" from user "collingwood" and enter the password. Remember that the program "su" is for "set user" not "superuser". 

If user7 does not belong to group2 then to change it to the new group enter "newgrp group2" and you are now in the proper group. Test this by using the "touch" command.

It might just be easier to add yourself "collinwood" to both groups (group1 and group2) and run "chmod 664 index.php" and then run "chown user7.group2 index.php". Unix used to allow you to set a file to a group or user to which you didn't belong. Somebody went stupid and fixed this feature! Don't forget the dot between user7 and group2.

Recall that 664 stands for rw-rw-r--. r's are 4's, w's are 2's, and x's are 1's. Just add then up. x stands for the execute bit. Values are grouped into threes.


Hope this helps.


----------

