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 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 in the destination directory.

share|improve this question
up vote 92 down vote accepted

You have two choices:

cd /root/Desktop/folder
tar zxf /root/Documents/file.tar.gz


tar zxf file.tar.gz -C /root/Desktop/folder
share|improve this answer
thanks, how about gzip -dc archive.tar.gz | tar -xf - -C /destination ? – alwbtc Oct 19 '11 at 13:12
what -C stands for? – AlikElzin-kilaka Jan 28 '15 at 15:56
@AlikElzin-kilaka From man tar -C, --directory DIR change to directory DIR – tachomi Jan 28 '15 at 16:31
tar -xvjf foo.tar.bz2 for those who are looking for bz2 like me – vladkras Jan 26 at 7:09

You must log in to answer this question.

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