tar ファイルとその内容の所有者を現在のユーザーに設定する方法

tar ファイルとその内容の所有者を現在のユーザーに設定する方法

tar ファイルの所有者とその内容を現在のユーザーとして設定する必要があります。

ユーザーFOOからフォルダ内のファイルを受け取りますconfig_files/請求/xml/受信請求書 tar ファイルがこの場所にコピーされるたびに、所有者を現在のユーザー (つまり BAR) に設定したいです。また、tar ファイルの内容も BAR として設定したいです。

答え1

ファイル自体について話しているのであればtar、ファイルの所有者またはルート ユーザーが する必要がありますchown newusername /path/to/file。または、スーパーユーザー アクセス権を持っている場合は できますsudo chown $(whoami) /path/to/file

所有権情報について話しているのであれば内でファイルtarについては、マニュアルに従います。

 -o      (x mode) Use the user and group of the user running the program rather than those specified in the archive.  Note that this has no significance unless -p is specified, and the program is being run by the root user.  In this case,
         the file modes and flags from the archive will be restored, but ACLs or owner information in the archive will be discarded.

関連情報