Server Fault is a question and answer site for system and network administrators. 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

This is one of those things I don't quite do often enough to memorize. I thought it would be nice to have the answer here so I (and maybe others with as poor a memory as me) can star it.

What command-line options to I use to un-tar a tar.gz file into a specific directory, on Linux?

share|improve this question
You can't even memorise "man tar"? – John Gardeniers May 21 '10 at 22:21
@John, as an infrequent *nix user, I despise the man pages on the occasions when I'm forced to read them. Most of them read like you already have a comp-sci degree, or you already know the intracacies of their software (in which case you're just after a refresher, not a learning experience) – Mark Henderson May 21 '10 at 22:38
@Farseeker, I won't argue what you said about man pages (I probably use *nix less that you do) but given the choice of using man or remembering a URL to a page with the same info I know where I'll turn first. – John Gardeniers May 22 '10 at 6:36
I've found that every time I ask a question here (no matter how easy it is to look up the answer somewhere else) I learn something. This time, so far, I learned about the multiple v method for specifying "verbosity". – Daryl Spitzer May 23 '10 at 13:08
John, now we've created a web page that may show up on a Google search for *nix newbies who wouldn't necessarily even know to try man tar. – Daryl Spitzer May 23 '10 at 13:10
up vote 3 down vote accepted
tar xzf file.tgz -C directory

But directory must be created before you can fill it If you don't define -C, it is extract in the current directory

share|improve this answer

From man tar:

   tar -xvvzf foo.tar.gz
          extract gzipped foo.tar.gz
share|improve this answer
I don't understand why -v is specified twice. Is that a typo? – Daryl Spitzer May 21 '10 at 19:17
-v : just the names of the files -vv : names + informations like size, owner, rights... – Dom May 21 '10 at 19:43
many commands use the multiple v method for defining just how verbose you want to be, the more vs, the more detail is displayed. the upper limit depends on each program though. – ManiacZX May 21 '10 at 19:52

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.