LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2018, 12:33 AM   #1
unclejed613
Member
 
Registered: Mar 2009
Posts: 352

Rep: Reputation: 32
extract tar.gz to absolute path


i'm helping somebody build a web page, and want to have a tar.gz archive of the whole file tree extract into /var/www/html/weblog. the file tree has been archived by adding /home/user/var to the archive, so that the top folder in the archive is /var. how do i insure the file tree in the archive drops into /var on the web server when it's extracted? the actual file tree inside the archive is /var/www/html/weblog with several subdirectories included below weblog. i see plenty of people ask online how to extract into a relative path, because the search terms "extract tar.gz to absolute path" brings up scads of questions on how to avoid extraction to absolute paths.
 
Old 08-05-2018, 04:25 AM   #2
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Use the -C switch when extracting always pointing to the top of the tree from your archive.
https://superuser.com/questions/3638...oes-tar-c-mean
Code:
cd /home/user/
tar -czpf /yourpath/weblog.tar.gz var/www/html/weblog/
tar -xzpf /yourpath/weblog.tar.gz -C /home/user/
#or
cd /
tar -czpf /yourpath/weblog.tar.gz home/user/var/www/html/weblog/
tar -xzpf /yourpath/weblog.tar.gz -C /
 
Old 08-05-2018, 10:59 AM   #3
jostber
Member
 
Registered: Jul 2001
Location: Skien, Norway
Distribution: Slackware Current 64-bit
Posts: 543

Rep: Reputation: 178Reputation: 178
https://www.linuxquestions.org/quest...th-4175421197/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar files without absolute path anandg111 Linux - Newbie 2 11-18-2014 10:02 PM
[SOLVED] tar with or without absolute path steinz Linux - Server 3 01-29-2013 03:27 PM
[SOLVED] tar absolute and relative path mmhs Linux - Newbie 13 08-09-2012 08:09 PM
bash: how to tar without absolute path? xushi Programming 1 05-20-2007 09:13 AM
tar saves absolute path warshke Linux - Software 2 03-27-2006 07:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration