Path contains ‘..’ tar.gz error

Last modified date

Comments: 0

Contents

Problem

When running the command:

tar -xvf archive.tar.gz

The following message is printed out next to the file names:

Path contains '..'

This is caused by pathnames of the files in the archive that contain a leading '..'.

From the tar documentation:

Tar will refuse to extract archive entries whose pathnames contain '..' or whose target directory would be altered by a symlink

Tar Documentation

Solution

The way to solve this is to change the way you are archiving the files.

If you have an archive command like this:

tar czvf archive.tar.gz ../myFolder/myFile.docx

Then you will get the Path contains '..' error because the pathname contains a leading '..'.

Tar will keep the .. in the pathname but will refuse to extract it.

To solve this you need to tell tar to change directory.

Use the -C command to change directory for the files you want to archive and use a fullstop . to tell tar to archive all the files if you are archiving the files in a directory.

The following command solves the problem:

tar czvf archive.tar.gz -C ../myFolder/myFile.docx .

JakTech

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.