Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 90 down vote accepted

You have two choices:

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

or

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
1  
@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

Your Answer

 
discard

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.