145

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.

Hennes
  • 64,768
  • 7
  • 111
  • 168
alwbtc
  • 2,885
  • 11
  • 33
  • 40

1 Answers1

232

You have two choices:

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

or

tar xf file.tar.gz -C /root/Desktop/folder
Patches
  • 16,136
  • 3
  • 55
  • 61