Permissions cannot be restored for a tar
Solution 1
Question: Permissions cannot be restored for a tar
Answer: only root can.
Reference: read this informative Q&A on askubuntu:
even if you use
tar
's--same-owner
flag, you will still need to extract the files as root to preserve ownership.
Update: Here's some more details about tar
's behaviour. Let's say we are user1
and have created an archive with tar cvpzf test.tar.gz .
that includes files owned by user2
. If we extract the archive in a directory owned by user2
with permissions 777
, here's the outcome:
$ tar xpvzf test.tar.gz
./
./file1
./file2
tar: .: Cannot utime: Operation not permitted
tar: .: Cannot change mode to rwxrwxr-x: Operation not permitted
tar: Exiting with failure status due to previous errors
$ ls -al
drwxrwxrwx 2 user2 user2 .
-rw-rw-r-- 1 user1 user1 file1
-rw-rw-r-- 1 user1 user1 file2
tar
throws an error because it cannot change ownership and permissions for files owned by user2
. The files are however extracted, although owned by user1
.
Here's what happens if the extraction is performed in a directory owned by user1
instead:
$ tar xpvzf test.tar.gz
./
./file1
./file2
$ ls -al
drwxrwxr-x 2 user1 user1 .
-rw-rw-r-- 1 user1 user1 file1
-rw-rw-r-- 1 user1 user1 file2
Permissions are restored for both the folder and the files, and no error is thrown even though user2
ownership could not be restored.
Judging from the OP's own answer, it seems then that the installer checks tar
's exit code and stops if an error was encountered. chown
ing the folder to the current user makes tar
fail silently so the installer can continue.
Solution 2
chmod -R 777 Downloads/*
sudo chmod -R 777 /opt/*
mkdir /opt/pkg
cd /home/my_ubuntu/Downloads
chmod +x petalinux-v2017.1-final-installer.run
./petalinux-v2017.1-final-installer.run /opt/pkg
now it will install and tar file permissions are restored when u create the directory pkg as normal user and not the root user.
Related videos on Youtube
jenny
Updated on September 18, 2022Comments
-
jenny over 1 year
tar: .: Cannot utime: Operation not permitted tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted tar: Exiting with failure status due to previous errors
I have my files in Downloads folder and I am running the installation file from Downloads folder to the /opt/pkg folder and here are the commands I used
chmod -R 777 Downloads/* sudo chmod -R 777 /opt/* chmod +x petalinux-v2017.1-final-installer.run ./petalinux-v2017.1-final-installer.run /opt/pkg
at the end the installer is failing giving the above error messages. And I am providing all permissions needed to Downloads folder and also for
/opt/pkg
folder.-
simlev almost 7 years
chmod
needs to be run as root. The installer tries to set permisisons and this operation can be carried out only by root. See here: even if you usetar
's--same-owner
flag, you will still need to extract the files as root to preserve ownership. -
jenny almost 7 yearsThe problem is according to petalinux tool installation rules one shouldnot run and install it as root user and also when I tried it shows an error message it cant be installed as root so I want to give access permissions for the two folders using the above commands and trying to run the installer into the folder in the root.
-
jenny almost 7 yearsI think i can copy all these from Downloads folder into pkg folder in the root and can I run the installer from the same pkg folder?
-
simlev almost 7 yearsYou can certainly try running
tar
as root and then performing the rest of the installation according to the documentation of your product. Can't help you any further as I don't know anything about the installer (maybe you should ask a separate question for it). -
kenorb almost 7 yearsNote: If you're untaring the file on some different system, uids can be different and point to non-existing or different users.
-