python-3.xpython-2.7tarfile

Unable to extract the tar file in python because of permission issue


I am unable to extract the tar file in python.

This is the code base am using to extract the tar file in Python.

file_path = os.path.join(extracted_tar_files, file.strip('.tar'))
tf = tarfile.open(os.path.join(files_directory, file))
tf.extractall(file_path)
tf.close()

Some of the tar files are working fine. Some of the tar files am getting the following error.

*** PermissionError: [Errno 13] Permission denied: '\home\piercer\etc.sudoers'

Can you please help here. Thank you!


Solution

  • the file seems to belong to someone else and you seem to have no read permissions. as is to be expected for a sudoers file. you could change the permissions:

    $ sudo -E chown $USER /home/piercer/etc.sudoers