While extracting a tgz
file, I have noticed that the permission changes to something weird! The tgz file belongs to root:root however, the folder belongs to 502:games
[root@rocks7 common]# ls -l
-rw-r--r-- 1 root root 4779534 May 2 2012 scalapack-2.0.2.tgz
[root@rocks7 common]# tar xf scalapack-2.0.2.tgz
[root@rocks7 common]#
[root@rocks7 common]# ls -l
total 98576
drwxr-xr-x 10 502 games 4096 May 2 2012 scalapack-2.0.2
-rw-r--r-- 1 root root 4779534 May 2 2012 scalapack-2.0.2.tgz
What is the issue here?
Best Answer
The tarball contains a
scalapack-2.0.2
directory owned by user id 502 and whatever group id corresponds to the games group (or, perhaps, the games group by name). You can see this by runningTar archives store ownership and permissions in addition to the file contents; since you’re extracting as root, that metadata is applied to the extracted files. The ownership of the tarball itself has no impact on the ownership of the extracted data.
Since you’re running CentOS, you’re presumably running GNU
tar
, and you can use the--no-same-owner
and--no-same-permissions
options to extract tarballs without applying the stored ownership and permissions. Othertar
implementations may have similar options (e.g.-o
on FreeBSDtar
).