I'm actually working on a Windows OS for development purposes. I have some config files which i want to deploy on a linux based system. The structure of the zip generated on Windows is the same as the target.
When i unzip my archive in the linux system, the unzip command change the owner of original files with the user who make the unzip (root).
Before unzip :
[root@supermachine /]# ll /myRootFolder -R
/myRootFolder:
total 4
-rw-r--r-- 1 superman superman 5 21 août 10:18 file.TXT
drwxr-xr-x 2 superman superman 25 21 août 10:17 mySubFolder
/myRootFolder/mySubFolder:
total 4
-rw-r--r-- 1 superman superman 4 21 août 10:17 subFile.TXT
After unzip
[root@supermachine /]# unzip myRootFolder.zip
Archive: myRootFolder.zip
replace myRootFolder/file.TXT? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: myRootFolder/file.TXT
replace myRootFolder/mySubFolder/subFile.TXT? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: myRootFolder/mySubFolder/subFile.TXT
[root@supermachine /]# ll /myRootFolder -R
/myRootFolder:
total 4
-rw-r--r-- 1 root root 5 21 août 10:18 file.TXT
drwxr-xr-x 2 superman superman 25 21 août 10:21 mySubFolder
/myRootFolder/mySubFolder:
total 4
-rw-r--r-- 1 root root 4 21 août 10:17 subFile.TXT
For information, unzip version is :
[root@supermachine /]$ unzip -v
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;
see ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.
Compiled with gcc 4.8.5 20150623 (Red Hat 4.8.5-26) for Unix (Linux ELF) on Jan 10 2018.
UnZip special compilation options:
COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)
SET_DIR_ATTRIB
SYMLINKS (symbolic links supported, if RTL and file system permit)
TIMESTAMP
UNIXBACKUP
USE_EF_UT_TIME
USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)
USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)
UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 paths)
MBCS-support (multibyte character support, MB_CUR_MAX = 6)
LARGE_FILE_SUPPORT (large files over 2 GiB supported)
ZIP64_SUPPORT (archives using Zip64 for large files supported)
USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.6, 6-Sept-2010)
VMS_TEXT_CONV
[decryption, version 2.11 of 05 Jan 2007]
UnZip and ZipInfo environment options:
UNZIP: [none]
UNZIPOPT: [none]
ZIPINFO: [none]
ZIPINFOOPT: [none]
Is there an option on zip command to preserve original owner of crushed files ? I read the manual but i see anything related to these case.
Note : If there is a solution with other kind of archive, it can also resolve my issue (i can generate other archive formats).
unzip --version
. (I think the answer will still be "no, there's no such option", but can only be sure by systematically going through every option supported by that exact version.)