私は実際に開発目的でWindows OSで作業しています。 Linux ベースのシステムにデプロイする構成ファイルがいくつかあります。 Windowsの結果のzip構造はターゲットと同じです。
Linuxシステムでマイアーカイブを解凍すると、unzipコマンドは元のファイルの所有者を解凍したユーザー(root)に変更します。
減圧前:
[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
減圧後
[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
詳細については、解凍したバージョンは次のとおりです。
[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]
zipコマンドに破砕されたファイルの元の所有者を保持するオプションはありますか?ドキュメントを読んでいますが、このような場合に関連するものはありません。
メモ:他の種類のアーカイブに対する解決策がある場合は、私の問題も解決することができます(他のアーカイブ形式を作成できます)。
ベストアンサー1
su コマンドを使用して、ファイルを所有するユーザーとして解凍を実行できます。
su -c "unzip myRootFolder.zip" superman
suを使用すると、他のユーザーとしてコマンドを実行したり、現在のログインセッション中に一時的にそのユーザーになることができます。走る
man su
コマンドの完全な説明です。