Questions tagged [tar]

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

Filter by
Sorted by
Tagged with
251 votes
5 answers
446k views

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_$...
Jay LaCroix's user avatar
  • 2,531
243 votes
3 answers
59k views

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 ...
Saaru Lindestøkke's user avatar
223 votes
6 answers
278k views

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 ...
Lazer's user avatar
  • 17.7k
221 votes
18 answers
50k views

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: ...
MarcusJ's user avatar
  • 2,125
205 votes
17 answers
259k views

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 ...
Svish's user avatar
  • 39.4k
176 votes
7 answers
302k views

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 ...
morpheous's user avatar
  • 4,333
158 votes
2 answers
308k views

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. ...
user1492502's user avatar
  • 1,683
148 votes
1 answer
269k views

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 ...
alwbtc's user avatar
  • 2,945
140 votes
8 answers
262k views

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 ...
quickcel's user avatar
  • 4,819
132 votes
1 answer
118k views

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 ...
neubert's user avatar
  • 7,092
131 votes
10 answers
613k views

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 ...
Jonas's user avatar
  • 27.5k
118 votes
11 answers
62k views

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 ...
Dave Dopson's user avatar
  • 1,275
109 votes
2 answers
123k views

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 ...
sergserg's user avatar
  • 1,284
108 votes
8 answers
279k views

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,...
morpheous's user avatar
  • 4,333
107 votes
4 answers
228k views

How to obtain maximum compression with .tar.gz? [duplicate]

The way i understand the use of tar + gzip is that tar is normally used to consolidate a grouping of files into a single file, then gzip is used to compress that file. I recently learned that tar can ...
Mario Zigliotto's user avatar
92 votes
1 answer
57k views

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 ...
callum's user avatar
  • 1,843
91 votes
4 answers
58k views

Equivalent to tar's "--strip-components=1" in unzip?

I have a script that extracts a tar.gz-file to a specified subdirectory mysubfolder: mkdir mysubfolder; tar --extract --file=sourcefile.tar.gz --strip-components=1 --directory=mysubfolder; Is there ...
Fredrik's user avatar
  • 1,035
87 votes
2 answers
257k views

How to tar a directory preserving not only permissions, but ownership too

I have to compress a directory using tar.gz preserving not only permissions, but ownership/groups too. And, in this directory there are many files that belong to many users.
Paulo Coghi's user avatar
  • 1,214
85 votes
17 answers
103k views

Untar, ungz, gz, tar - how do you remember all the useful options?

I am pretty sure I am not the only one with the following problem: every time I need to uncompress a file in *nix I can't remember all the switches, and end up googling it, which is surprizing ...
81 votes
7 answers
135k views

Which is more efficient - tar or zip compression? What is the difference between tar and zip?

I'm working in Linux environment and want to know about tar and zip commands. Which is more efficient - tar or zip? I also need to know the differences between the tar and zip commands. Can anyone ...
rekha_sri's user avatar
  • 921
80 votes
6 answers
33k views

Why do I get files like ._foo in my tarball on OS X?

When I tar certain files in OS X: tar cvf foo.tar foo It produces an extra file ._foo in the tarball: ./._foo foo which only shows up if I extract it on a non-Mac operating system. But ._foo doesn'...
Jesse Beder's user avatar
  • 1,811
74 votes
6 answers
194k views

How do I password protect a .tgz file with tar in Unix?

I'm using the Unix tar command as follows to tar up a directory and its files: tar cvzf fileToTar.tgz directoryToTar Is there a way to password protect the .tgz file? I've created password-...
c12's user avatar
  • 841
73 votes
5 answers
34k views

gzip without tar? Why are they used together?

Why are tar and gzip almost always used together, and not just gzip? Is there any advantage to that method?
user541686's user avatar
  • 23.9k
71 votes
2 answers
91k views

What is the correct MIME type for a tar.gz file?

What is the correct MIME type for a tar.gz file? I've searched around and found several values being used, including: application/x-gzip application/x-gtar application/x-tgz But I could find no ...
Lily Finley's user avatar
57 votes
5 answers
217k views

How to tar directory and then remove originals including the directory?

I'm trying to tar a collection of files in a directory called 'my_directory' and remove the originals by using the command: tar -cvf files.tar my_directory --remove-files However it is only removing ...
Nicholas's user avatar
  • 1,123
56 votes
8 answers
75k views

.tar files without directory structure

I'm .taring some files with the path example/super_user/Output.*. The resulting .tar looks like this: + example + super_user - Output.zip - Output.xml - Output.txt ...
user avatar
50 votes
7 answers
208k views

Extract 7z files with standard linux tools?

I know that you can extract .7z files with 7-zip. Is there another standard linux program that can do this? Maybe one of these tar bzip2 xz gzip I will add that bsdtar can do this, but is not ...
Zombo's user avatar
  • 1
50 votes
3 answers
30k views

Get mac tar to stop putting ._* filenames in tar archives [duplicate]

Possible Duplicate: Why do I get files like ._foo in my tarball on OS X? I create autoconf scripts on a Mac. When tar runs, it puts all of these ._foobar names in the archive: libewf-20110312/...
vy32's user avatar
  • 3,361
50 votes
3 answers
39k views

Is it possible to mount a .tar file?

The only result of any import when I searched for this was from 2001. In the intervening decade, have any tools/methods for mounting a tar file as a filesystem (perhaps utilizing fuse) been created? ...
warren's user avatar
  • 10.1k
48 votes
6 answers
43k views

What is the difference between TAR vs CPIO archive file formats?

I am curious and did a bit of reading but still have questions. What makes CPIO different than TAR? I was told in another question that tar is for pulling together many files into 1 archive which ...
AtomicPorkchop's user avatar
45 votes
3 answers
46k views

Extract specific files in a tar archive using a wildcard

I'm trying to create a script to extract only jpeg pictures from an archive containing many kind of files. To do so, I tried to use: tar -xf MyTar.tar *.jpg but it failed (*.jpg not found) and ...
AdrieanKhisbe's user avatar
45 votes
3 answers
76k views

How do I tar ball a directory hierarchy with soft links in Linux?

How do I tar ball/compress a directory hierarchy with soft links in Linux?
michael's user avatar
  • 5,935
44 votes
5 answers
82k views

tar – extract discarding directory structure

unzip has a nifty option -j, whereby the directory structure of the archive is discarded, and all files are extracted into the same directory. Is there a way of making tar work in the same way? ...
Benji XVI's user avatar
  • 543
44 votes
3 answers
127k views

Howto pipe: cp | tar | gzip without creating intermediary files?

Can anyone tell me if it's possible to pipe | this without having to create a physical file anywhere between A and B.tar.gz? This is what I'm trying to do: File A Rename A to B Tar B.tar gzip -9 B....
user avatar
44 votes
1 answer
186k views

Extracting a tar.gz file returns, “This does not look like a tar archive.”

I have a tar.gz file and I want to extract it using terminal. I used following commands: tar tvzf ldtp_3.5.0.orig.tar.gz and tar -xvzf ldtp_3.5.0.orig.tar.gz. However, I get the same result for both ...
TheRookierLearner's user avatar
43 votes
2 answers
45k views

unpack 'tar' but change directory name to extract to

tar -tf filename.tar folder1/file folder1/name [...] I'd like to extract file and name to, folder2. Can this be done as a one-liner?
Felipe Alvarez's user avatar
43 votes
3 answers
78k views

How to tar/untar the output on the fly

What is the idiomatic way to do the following tar to stdout read this tar output from stdout and extract to some other folder. My solution is tar --to-stdout .. | tar -C somefolder -xvf - But ...
shabunc's user avatar
  • 820
43 votes
12 answers
535k views

How to extract a tar file (.tgz) in windows?

How to extract a tar file (.tgz) in windows? Is this possible, or do I have to get into a linux environment and extract it?
kiki's user avatar
  • 543
42 votes
3 answers
67k views

How do I use 7-Zip CLI for Windows to create .tar.gz archives?

How can I use the 7-Zip CLI (7za.exe) on Windows to create .tgz archives, as I use tar zcvf archive.tgz source_files on Linux?
f.ardelian's user avatar
41 votes
5 answers
20k views

Undo tar file extraction mess

I just untar'd an archive that produced a mess of files into my tidy directory. For example: user@comp:~/tidy$ tar xvf myarchive.tar file1 file2 dir1/ dir1/file1 dir1/subdir1/ dir1/subdir1/file1 dir2/...
Mike T's user avatar
  • 785
40 votes
4 answers
42k views

How to get an empty tar archive?

I am making an RPM in which everything is contained in the .spec file (don't ask :-). rpmbuild requires a "Source" file, so I was trying to create an empty tar file. However, if I don't give any ...
Sean Reifschneider's user avatar
39 votes
8 answers
154k views

Linux: what is a most convenient way to see the content of .jar file

What is a most convenient way to see the content of .jar file w/o using unzip/untar commands? What I'd like to do - is to browsing inside using cd command like it is the usual folder, seeing content, ...
javagirl's user avatar
  • 507
36 votes
2 answers
36k views

How can I force only relative paths in "find" output?

I am attempting to create a script that can compress files with a certain extension in a number of directories into a single tar-ball. Currently what I have in the script file is: find "$rootDir" -...
Shane's user avatar
  • 383
31 votes
7 answers
97k views

How to create tar archive split into, or spanning, multiple files?

According to this page, one can let tar create a tar archive "split" into 100 Mb files: tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz The problem is that this command will ...
Samuel Lampa's user avatar
29 votes
5 answers
36k views

Between xz, gzip, and bzip2, which compression algorithim is the most efficient?

Between xz, gzip, and bzip2, which compression algorithm gives the smallest file size and fastest speed when compressing fairly large tarballs?
Nathan2055's user avatar
  • 1,180
28 votes
6 answers
36k views

How can I create a zip / tgz in Linux such that Windows has proper filenames?

Currently, tar -zcf arch.tgz files/* encodes filenames in UTF, so Windows users see all characters spoiled in filenames which are not english, and can do nothing with it. zip -qq -r arch.zip files/* ...
kolypto's user avatar
  • 3,081
27 votes
2 answers
12k views

What does `tar: Cannot connect to …: resolve failed` mean?

I'm writing a practice bash script that saves a folder as a tar archive with a name date-foldername.bak The script fails when unformatted date is inserted as part of the filename, so 2022-05-09-work ...
user1143191's user avatar
27 votes
5 answers
56k views

tar -C with a wildcard file pattern

Can I use the tar command to change directories and use a wildcard file pattern? Here is what I am trying to do: tar -cf example.tar -C /path/to/file *.xml It works if I don't change directory (-C),...
Nick C.'s user avatar
  • 373
27 votes
6 answers
10k views

How do I create a tar file in alphabetical order?

I want to create a tar file where all of the directories and files are processed in alphabetical order. This is for the entire directory hierarchy that's being tarred up, so it would start by ...
Erick Robertson's user avatar
25 votes
3 answers
40k views

How can I create multipart tar file in Linux?

How can I create a multipart tar file in Linux?
hopeseekr's user avatar
  • 1,672

1
2 3 4 5
16