实际上,为了开发目的,我正在开发Windows操作系统。我有一些配置文件,我想部署在一个基于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命令,以保留原所有者的粉碎文件?我看了手册,但我看到了与这个案子有关的任何东西。
注意:如果有其他类型的归档解决方案,它也可以解决我的问题(我可以生成其他存档格式)。
发布于 2019-08-21 23:52:04
您可以尝试su命令以要拥有这些文件的用户的身份运行unzip:
su -c "unzip myRootFolder.zip" superman su允许您以另一个用户的身份运行命令,或在当前登录会话中临时成为该用户。跑
man su有关命令的完整描述。
https://unix.stackexchange.com/questions/536624
复制相似问题