Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

The Situation

I am extracting a CMS from drupal-7.15.tar.gz to /var/www.

When extracted normally (with tar -xvzf filename.tar.gz) the files end up in /var/www/drupal-7.15/

The Goal

I want the contents from the archived drupal-7.15/ directory to extract directly into /var/www

share|improve this question
up vote 6 down vote accepted


 tar -xvzf filename.tar.gz --strip-components=1

--strip-components=1 tells tar to strip the first path component (the drupal-7.15/ in your case) from each file when unpacking.

share|improve this answer
Absolutely brilliant. Thanks, Florian. – bitfed Sep 20 '12 at 8:14

The simplest and more user-friendly solution is to open nautilus using:

gksudo nautilus

Then head to your archive, double click it, wiat for it to open with the archive manager, double click into the directory (inside the archive manager, hit Ctrl+A so as to select all the files inside the directory, click on the "Extract" button, and then select /var/www/

Alternatively, you can just

sudo mv /var/www/drupal-7.15/* /var/www/
sudo rm -r /var/www/drupal-7.15
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.