The tar archive format and/or the command-line utility for working with tar files.
Questions tagged [tar]
1276 questions
249
votes
6 answers
How to extract specific file(s) from tar.gz
How can we extract specific files from a large tar.gz file? I found the process of extracting files from a tar in this question but, when I tried the mentioned command there, I got the error:
$ tar --extract --file={test.tar.gz} {extract11}
tar:…

Ankit Vashistha
- 3,745
117
votes
14 answers
tar --exclude doesn't exclude. Why?
I have this very simple line in a bash script which executes successfully (i.e. producing the _data.tar file), except that it doesn't exclude the sub-directories it is told exclude via the --exclude option:
/bin/tar -cf /home/_data.tar …

ateiob
- 1,717
112
votes
7 answers
creating a tar archive without including parent directory
I am trying to create a graphical program for my script.
Inside the script I use tar to create a tar archive.
From the graphical program I get the full name of file that I want to create a tar archive.
tar -cvf temp.tar…

Sujit Maharjan
- 1,445
93
votes
5 answers
tar exits on "Cannot stat: No such file of directory", why?
I'm trying to create tar.gz file using the following command:
sudo tar -vcfz dvr_rdk_v1.tar.gz dvr_rdk/
It then start to create files (many files in folder), but then I get the following error:
tar: dvr_rdk_v1.tar.gz: Cannot stat: No such file or…

ransh
- 1,407
60
votes
4 answers
How to create tar archive in a different directory?
I want to create a tar archive in a different directory rather than the current directory.
I tried this command:
tar czf file.tar.gz file1 -C /var/www/
but it creates the archive in the current directory. Why?

Omid
- 3,391
58
votes
3 answers
Extract multiple .tar.gz files with a single tar call
I was wondering whether (and, of course, how) it’s possible to tell tar to extract multiple files in a single run.
I’m an experienced Unix user for several years and of course I know that you can use for or find or things like that to call tar once…

scy
- 820
37
votes
5 answers
How to untar safely, without polluting the current directory in case of a tarbomb?
Respectable projects release tar archives that contain a single directory, for instance zyrgus-3.18.tar.gz contains a zyrgus-3.18 folder which in turn contains src, build, dist, etc.
But some punk projects put everything at the root :'-( This…

Nicolas Raoul
- 8,205
36
votes
2 answers
Why is tar archive so much bigger than text file, 10240 bytes?
I've checked these two questions (question one, question two), but they were not helpful for me to understand. I have a file file.txt with 40 lines of Hello World! string. ls -l shows that its size is 520 bytes. Now I archive this file with tar -cvf…

Boris Kalinin
- 471
36
votes
2 answers
Prevent showing time stamp message when running "tar xzf"
When running tar xzf, how to prevent this message (Prevent showing time stamp message):
tar: node: time stamp 2011-06-07 02:02:30 is 8309 s in the future
tar: user/Node: time stamp 2011-06-07 01:56:05 is 7924 s in the future

Mark Peepee
- 361
35
votes
4 answers
tar with relative paths
I try to create an archive with tar using relative paths. I use the following command:
tar czf ~/files/wp/my-page-order.tar.gz -C ~/webapps/zers/wp-content/plugins/ ~/webapps/zers/wp-content/plugins/my-page-order
But the archived files still have…

Mert Nuhoglu
- 661
30
votes
3 answers
What does the -f parameter do in the tar command
When using tar I always include -f in the parameters but I have no idea why.
I looked up the man and it said;
-f, --file [HOSTNAME:]F
use archive file or device F (default
"-", meaning stdin/stdout)
But to be honest I have no idea what that means.…

Toby
- 3,993
29
votes
4 answers
Remove files from tar archive
I have a large file foo.tar.xz that contains a lot (say 200000) of files. I figured out that this archive contains some (around 5000) files I don't want. I don't have sufficient disk space to decompress the whole thing onto my disk; additionally, I…

FUZxxl
- 785
29
votes
7 answers
How do I extract with tar to a different directory?
This doesn't work:
tar xf /tmp/foo.tar.gz foo/bar
tar: foo/bar: Not found in archive
It's not obvious to me what would do this beyond extracting it in place and moving the files over.

Kit Sunde
- 4,504
- 10
- 31
- 34
29
votes
5 answers
tar extract into directory with same base name?
I have a zipped file like myArchive123.tar.gz. Inside, it contains a folder like helloWorld
If I extract it with tar -xf myArchive123.tar.gz, I get the helloWorld folder:
ls
myArchive123.tar.gz
helloWorld
I want the output to be the same as the…

Leo Ufimtsev
- 921
22
votes
4 answers
tar list files only
Fun fact: If you use Archive Manager and extract a .tar.gz so that you have "Keep directory structure" unticked, you will get a tarbomb.
tar -ztf lists all the files and directories in a tar file.
Is there a way to list all the files in a tar file,…

Eero Aaltonen
- 621
- 1
- 5
- 13