- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about tar
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 06:09 PM
тАО02-26-2002 06:09 PM
For example: tar xvf usr1.tar,the current directory is /test, the extracted files are created under /usr1, not under /test/usr1.
why?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 06:15 PM
тАО02-26-2002 06:15 PM
SolutionFor example:
tar cvf /dev/rmt/0m /u01
All the files will be tar'ed with an absolute path /u01/* and restoring to another directory is difficult.
If instead you first cd to /u01 and then do a
tar xcf /dev/rmt/0m . then all the files will be tar'ed as ./* and can be easily restored anywhere.
Whenever possible, avoid the absolute pathnames when making tars.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 06:15 PM
тАО02-26-2002 06:15 PM
Re: Question about tar
As far as I am aware, if you create the tar file (cvf) in a directory, ie /usr1 when you extract (xvf) the file will be extracted in the location that it was tarred, not the directory you reside when perform the xvf
If this ok?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 06:27 PM
тАО02-26-2002 06:27 PM
Re: Question about tar
This is from the tar man page:
/quote/
There is no way to restore an absolute path name to a relative position.
/unquote/
1) If you want absolute path:
Creating the archive:
# tar cvf usr1.tar /usr1
Extracting the archive:
# tar xvf usr1.tar
2) If you want relative path:
Creating the archive:
# cd /usr1
# tar cvf usr1.tar *
Extracting the archive:
# mkdir -p /test/usr1
# cd /test/usr1
# tar xvf /usr1/usr1.tar
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 07:20 PM
тАО02-26-2002 07:20 PM
Re: Question about tar
It depends on how the file was backed up. If it was backed up using absolute path name. It will be extracted using absolute path no matter where you are trying to extract upto. If this was backed up without using absolute path, they can be extracted to the current directory.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2002 07:37 PM
тАО02-26-2002 07:37 PM
Re: Question about tar
Before extracting a tar file, you should verify how files were added to it. Use tar tvf and look to see if absolute pathnames were used to create the tar file.
If you created the tar file using relative pathnames for the input files, tar will extract the files to locations relative to your current directory.
If you created the tar file using absolute pathnames for the input files, tar will extract the files to that absolute path.
An alternative for changing the extract destination for a tar file created with absolute pathnames is to use pax. An example is:
tar cvf /tmp/users.tar /home/users
tar xvf /tmp/users.tar
will extract files back to their original locations because the input file/dir was specified with an absolute pathname (/home/users)
pax -r -s,/home/users,/home/users2, -f /tmp/users.tar
will extract files changing /home/users to /home/users2
See the man page for more info.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:08 AM
тАО02-27-2002 12:08 AM