Questions tagged [tar]

An archive file format (and the program that reads it) commonly used on Unix and Linux.

tar (usual extension: .tar) is an archive file format commonly used on Unix and Linux. tar archives are informally called "tarballs".

tar is also the name of the command-line program used to read and write tarballs.

While the tar format itself doesn't support compression or encryption, tarballs are often compressed or encrypted using external programs. The resulting files conventionally have extensions like .tar.gz, .tar.xz, .tar.bz2, .tar.gpg, ....

791 questions
274
votes
5 answers

Linux Bash Script, Single Command But Multiple Lines?

I have the following script I wrote by searching Google, and it backs up my Linux system to an archive: #!/bin/bash # init DATE=$(date +20%y%m%d) tar -cvpzf /share/Recovery/Snapshots/$HOSTNAME_$DATE.tar.gz --exclude=/proc --exclude=/lost+found…
Jay LaCroix
  • 2,761
244
votes
3 answers

Why are tar.xz files 15x smaller when using Python's tar library compared to macOS tar?

Context I'm compressing ~1.3 GB folders each filled with 1440 JSON files and find that there's a 15-fold difference between using the tar command and Python's built-in tarfile library on macOS or Raspbian 10 (Buster) Minimal working example This…
237
votes
7 answers

How to specify level of compression when using tar -zcvf?

I gzip directories very often at work. What I normally do is tar -zcvf file.tar.gz /path/to/directory Is there a way to specify the compression level here? I want to use the best compression possible even if it takes more time to compress.
Lazer
  • 18,407
221
votes
18 answers

What is the advantage of using 'tar' today?

I know that tar was made for tape archives back in the day, but today we have archive file formats that both aggregate files and perform compression within the same logical file format. Questions: Is there a performance penalty during the…
MarcusJ
  • 2,145
215
votes
17 answers

Is there a way to see any tar progress per file?

I have a couple of big files that I would like to compress. I can do this with for example tar cvfj big-files.tar.bz2 folder-with-big-files The problem is that I can't see any progress, so I don't have a clue how long it will take or anything like…
Svish
  • 41,258
181
votes
7 answers

How to password protect gzip files on the command line?

I want to create some tar.gz (and possibly tar.bz2) files, using the tar command on Ubuntu 10.04. I want to password protect the file. What is the command to do this (I have Googled, but found nothing that shows how to create and extract compressed…
morpheous
  • 4,463
162
votes
2 answers

create tar with multiple directories and file locations

I have some scripts and files located in various locations like: /etc/dir1 /var/www/html /home/somedir I want to make a tar file so that it copies files and folders with the location structure. When I untar to another location, all the files will…
user1492502
  • 1,723
  • 2
  • 10
  • 5
156
votes
1 answer

How do I unzip a tar gz archive to a specific destination?

I want to unpack a .tar.gz file to a specific directory. The archive file is in /root/Documents. I want to unzip it into /root/Desktop/folder. The folder structure in zipped file should be preserved in the destination directory.
alwbtc
  • 3,085
  • 13
  • 35
  • 43
150
votes
8 answers

How can I unzip a .tar.gz in one step (using 7-Zip)?

I am using 7-Zip on Windows XP and whenever I download a .tar.gz file it takes me two steps to completely extract the file(s). I right-click on the example.tar.gz file and choose 7-Zip --> Extract Here from the context menu. I then take the…
quickcel
  • 4,919
142
votes
1 answer

Cannot decompress .tar.xz file, getting "xz: Cannot exec: No such file or directory" from tar

Per How do I uncompress a tarball that uses .xz?, I tried tar xf php-5.6.0RC4.tar.xz and tar -xJf php-5.6.0RC4.tar.xz and in both cases I get the following: tar (child): xz: Cannot exec: No such file or directory tar (child): Error is not…
neubert
  • 7,574
  • 39
  • 94
  • 156
135
votes
10 answers

How to open a .tar.gz file in Windows?

I need to open a file that sadly is only available in the .tar.gz file format and I am using Windows 7. I can unzip the file using 7-zip but after that I still have a .tar file that I can't open in Windows. Is there a way to open .tar.gz files on…
Jonas
  • 28,660
123
votes
12 answers

Linux / OS X tar incompatibility – tarballs created on OS X give errors when untarred in Linux

When I tar up files on my Macbook and untar them in Linux, I repeatedly get the following warnings/errors: tar: Ignoring unknown extended header keyword `SCHILY.ino' tar: Ignoring unknown extended header keyword `SCHILY.nlink' tar: Ignoring…
Dave Dopson
  • 1,325
115
votes
2 answers

How can I use tar command to group files without compression?

I have a very large folder of 120,000+ files. and I need to move them to another location on my same machine (same partition). I'd like to use the tar command to group them up as a single unit and then mv them to the end location. What command do I…
sergserg
  • 1,344
114
votes
1 answer

How to untar an archive without the root folder, but keeping the full hierarchy inside it?

If I’ve got a .tar archive, and when I extract it, it gives me a single folder foo containing some more stuff, like this: foo/ something.txt another.txt bar/ something-else.txt Is there a way I can modify the .tar command to “skip” the…
callum
  • 2,115
113
votes
8 answers

tar: Exiting with failure status due to previous errors

I have written a little script that tars and compresses a list of directories + files. The script appears to run succesfully, in that a useable .tar.gz file is created after the script runs. However, I get this annoying message after the script…
morpheous
  • 4,463
1
2 3
52 53