
no-same-ownerĮxtract files as yourself (default for ordinary users). tar xvfj 2 Ahh, nice and simple, just the way we like it. tar xvfz To use bunzip2 to extract your tar.bz2 file in a single step, use the j switch instead. You should by default get same ownership as user running untar command when not root user. To gunzip and untar a file in a single step, use the followingnote that the z switch is the important one that tells tar to unzip it. You can also use cpio to extract from tar as some user:group cpio -iR user:group -F file.tar If it gets run as root you can use sudo -u username or su username -c to run command as some other user, and you should get ownership as that user then. v: This option will list all of the files one by one in the archive. The options are pretty straightforward for this: x: This tells tar to extract the files. show progress -f : File, work.1 answer Top answer: Use the following tar command:tar -xzvf data.tgzThe tar options are as follows to extract tgz file in Linux:-x : Extract file-z : Deal with compressed. tgz) If your tar file is compressed using a gZip compressor, use this command: tar xvzf.
#Untar command linux archive#
filter the archive through gzip -v : Verbose output i.e. If you are running untar as root then they get extracted with same uid:gid ownership that they were packed with by default, because root user can do chown to any user. x : Extract file -z : Deal with compressed file i.e. When you extract tar files as non-root user you extract them with the user running the untar command by default, because regular user cannot do chown to other users. If you try to extract something from tar as regular user with -same-owner, in case it would try to extract files with ownership not same as user running untar command you will get "Cannot change ownership to uid x, gid x: Operation not permitted". Regular user wouldn't be able to change ownership of extracted files to root, that would be a huge security issue (you could put setuid and 777 on any file and then get root privileges that way, by changing file ownership to root). If you get root ownership on untared files you are running it as root user. If you run tar extract as non-root user it gets extracted as current user by default.
