I sometimes get confused by the varying command line options I need to run common Unix archiving and compression software (e.g. gzip, bzip2, zip, tar).

Is there a program out there that can just Do What I Mean for common cases? For example:

program --compress --gzip foobar
program --extract foobar.tar.bz2
program --extract foo.zip

closed as off-topic by fixer1234, Kamil Maciorowski, Pimp Juice IT, djsmiley2k, nerdwaller Jan 22 at 6:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking product, service, or learning material recommendations are off-topic because they become outdated quickly and attract opinion-based answers. Instead, describe your situation and the specific problem you're trying to solve. Share your research. Here are a few suggestions on how to properly ask this type of question." – fixer1234, Kamil Maciorowski, Pimp Juice IT, djsmiley2k, nerdwaller
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

atool is designed for this job. A copy of the man page is available here.

To compress files use


and to decompress them use

aunpack ARCHIVE

(alternatively you can use atool -a and atool -x respectively).

It works with pretty much any archive format you can think of including gzip, bzip, lzip, 7z, rar, ar, deb, rpm, jar[1] and most combinations of tar and a compression method.

The advantage of this over 7zip is that 7zip removes executable permissions. So, for example, 7zip makes it much more difficult to install software from archived sources because you need to manually chmod +x the appropriate files before running any make or any install scripts.

[1] The online man page linked is for an older version that doesn't handle jar files.

As example 7z.

7z a -tgzip foobar.gz foobar
7z e foobar.gz

Where a - add files to archive, -t{Type} - Set type of archive (7z, zip, gzip, bzip2 or tar), e - extract files from archive. More information man 7z.

  • You shouldn't need the -t option most of the time -- 7-zip will guess archive type from common file extensions if possible. – afrazier Jun 22 '11 at 23:01
  • There's a major problem with 7zip: it will remove file permissions even when extracting archives that should preserve this information! This greatly complicates the installation of software from archives. Use atool instead (see my answer below). – dshepherd Jan 23 '15 at 10:20

tar, when configured correctly, can do this all (except the unzip maybe) easily.

tar --create --gzip --file out.tar.gz in in2 in3
# same thing
tar -czf out.tar.gz in in2 in3

tar --extract --file in.tar
tar -xf in.tar

This will work for gzipped and bzip2ed files as well. (Assuming you actually have such programs installed.)

Edit: Oh yeah, forgot about the unzip. That's not included in tar presumably because of patent reasons or such. Simply use the unzip application to extract those:

unzip in.zip

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