Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 am totally new to linux. I have gzipped a war file like this gzip mytest.war. I try to ungzip it like it --ungzip mytest.war.gz, it said command can't be found. How can I ungzip it?

Moreover, how can gzip and ungzip a particular folder?

share|improve this question
up vote 1 down vote accepted

Mat covered the answer in its entirety, but here are some more verbose self-help explanations.

Generally speaking, the way to get help on Unix (and, of course, Linux) is the man (manual) command. man gzip would have answered your question. The answer's already there in the ‘Synopsis’ section (this may be the reason for the negative vote your question got). You can even say man man to learn how the Unix online manual is organised.

In terms of compression tools, Unix separates the notion of an archiver and a compressor. Tools like ZIP came from the MS-DOS ecosystem where applications had to be all-inclusive (do everything, do it as well as you can) because it was difficult to combine the results of programs. On Unix, where it's very easy (nay, required) to pipe data from one command to another, the mentality is ‘do one thing, do it well’. You archive files together in an archive file using tools like tar, then gzip the result to compress it. Modern versions of the standard archivers can do this for you (tar can automatically gzip or bzip2 its resulting files, and it can uncompress automatically too).

To archive and compress a folder all at once, this is standard practice:

tar czvf file.tar.gz some-folder

The man page for tar explains the arguments bunched up in the second ‘word’. Briefly, c=create, z=gzip, v=verbose, f=the resultant filename follows. This is equivalent to this:

tar cvf file.tar some-folder
gzip file.tar


tar cv some-folder | gzip file.tar

The last two forms give you more flexibility in case you want to use something else to compress. (or to adjust the compression level of gzip, for instance)

share|improve this answer
Stdout is the default, so -f - is redundant. tar c folder (or cv if you prefer) is quite enough. – Kevin May 28 '12 at 20:57
Thanks! (you learn something new every day) Answer updated. – Alexios May 28 '12 at 21:44

There is no ungzip. You might have a gunzip, and if you don't you should be able to gzip -d. Read man gzip for details.

gzip handles single files only. If you want to archive whole directories, use zip, or tar, or cpio (or ...); or jar since you seem to be handling Java archives.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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