I have a tarball called playground.tar with the following file:


When I extract everything there is no problem but when I try and extract a single file it throws the following error when I run this command:

 tar xf playground.tar test.txt

tar: test.txt: Not found in archive

tar: Exiting with failure status due to previous errors

What gives I have also tried it with the path enclosed in quotes. The file definitely exists.


The tarball was created with this command:

tar cf playground.tar playground

  • 1
    Update the question with the exact command you have used to create the archive.
    – thanasisp
    Dec 13, 2020 at 11:06
  • 1
    It probably doesn't have test.txt exactly stored as that. It might be ./test.txt or some/path/to/test.txt
    – roaima
    Dec 13, 2020 at 11:12
  • 1
    So you want to extract playground/test.txt not test.txt
    – thanasisp
    Dec 13, 2020 at 11:18
  • 1
    You can also use the TAB completion into the interactive shell. Type tar xf playground.tar <TAB> and it's like being into the directory tree. You can select the file you want.
    – thanasisp
    Dec 13, 2020 at 11:19
  • Yea I figured it out the name of the tarball has to be in the relative path even though this is not done in the linux command line book I am following. Figures, thanks for the help
    – nrmad
    Dec 13, 2020 at 11:21

2 Answers 2


You need to specify the whole path:

tar -xf playground.tar playground/test.txt

You can use tar --list or tar -t to list the contents of an archive to see what's in there:

$ tar -tf playground.tar

Here's a complete log of what I did to reproduce your issue:

$ cd $(mktemp -d)                              # Go to a new empty directory
$ mkdir playground
$ touch playground/test.txt                    # Make the file we will tar

$ tar cf playground.tar playground             # Make the tar
$ tar -tf playground.tar                       # List the contents of a tar
playground/test.txt                            # There's our file! It has a full path

$ rm -r playground                             # Let's delete the source so we can test extraction
$ tar -xf playground.tar playground/test.txt   # Extract that file
$ find .                                       # Check if the file is now there
./playground/text.txt                          # Here it is!

Alternatively, you didn't need to pack the whole directory. This would have also worked. I also added test2.txt to show the whole directory isn't unpacked.

$ cd $(mktemp -d)                 # New directory
$ touch test.txt test2.txt        # Let's make a few files
$ tar -cf playground.tar *.txt    # Pack everything
$ tar -tf playground.tar          # What's in the archive?
test.txt                          # Look: No directory!
$ rm *.txt                        # Clear the source files to test unpacking
$ tar -xf playground.tar test.txt # Unpack one file (no directory name)
$ find .
./playground.tar                  # There it is!

The tarball name must be included in the file paths:

tar xf playground.tar playground/test.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.