Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this 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.

share|improve this answer

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.

share|improve this answer
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:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .