i'm trying to untar this file to the public_html folder the file is currently in /home/user/ ... the public_html is backed up inside so it should just dump the files into the public_html but nothing is happening

tar -xvzf backup.tar.gz /home/user/

tar: /user: Not found in archive tar: Error exit delayed from previous errors


cd /home/user; tar xvfz backup.tar.gz

You are asking tar to extract '/home/user' from the archive. Better to un-tars to the local dir.

  • this was the original backup line tar cvzf /home/user/user-temp/backup.tar.gz /home/user/public_html do i still cd /home/user tar xvfz backup.tar.gz ? – acctman Mar 17 '12 at 16:23
  • The tar was made with full paths (typically tar files do not contain full paths. I don't use that - but will check for you... – Art Swri Mar 17 '12 at 16:27
  • The tar was made with full paths (typically tar files do not contain full paths. Do you have write access to /home/user? (You'll need it). A simple way to handle this is to just let the tar un-tar back into /home/user/public_html; you can use just tar tvfz backup.tar.gz to do that. IMPORTANT tar will over-write any existing /home/user/public_html (and mix the existing and the tar contents, if that is the situation). If you want to save the existing /home/user/public_html, just rename it temporarily, do the un-tar, and then handle the 2 dirs as you see fit. – Art Swri Mar 17 '12 at 16:33
  • tar will not add the leading / into your archive unless you tell it to do so with the -P attribute. In your example you'll have to: cd /; tar xzvf path_of_your_tar.gz file. – dAm2K Mar 17 '12 at 16:35
  • Agree with dAm2K - if you did not use cvfzP (or --absolute-names option), your archive will contain home/user/public_html which you can untar into any dir where you have access; it should create ...yourdir.../home/user/public_html, which you can then move (mv), copy (cp), etc. – Art Swri Mar 17 '12 at 16:40

With the command (GNU tar release)

tar ztvf yourfile.tar.gz

you'll find what's inside your gzipped tarball archive file.

If you want to uncompress all stuff that are into your gzipped tar archive you have to fire:

tar zxvf yourfile.tar.gz

All files will be untared into the current path from where your are calling the previous command. If you just want to uncompress a given relative path from your archive into your current path you can use the command

tar xzvf yourfile.tar.gz path_inside_the_tarball_you_want_to_uncompress

It will untar only the files you want to uncompress. Those files will be released into your current working directory. If you want to release the files into another path you have to use the "-C" option followed by the path to the previous tar command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.