[Solved] How to extract archive to original path?

New to Debian (Or Linux in general)? Ask your questions here!

[Solved] How to extract archive to original path?

Postby johnywhy » 2018-09-04 18:26

How to extract an archive to its original path?

When i create a tar file, it doesn't seem to include paths.
When i extract it, it doesn't go to its original path, it just goes to the current directory.

Code: Select all
# tar -cf here.tar here
# tar -tvf here.tar
-rw-r--r-- root/root         0 2018-09-04 12:05 here
Last edited by johnywhy on 2018-09-11 13:07, edited 1 time in total.
johnywhy
 
Posts: 21
Joined: 2011-11-24 00:17

Re: How to extract archive to original path?

Postby GarryRicketson » 2018-09-05 01:24

Code: Select all
man tar

-C directory
This is a positional argument which sets the working directory
for the following files. When extracting, files will be
extracted into the specified directory; when creating, the
specified files will be matched from the directory.

Code: Select all
tar -xf archive.tar -C /target/directory

If the target directory does not exist, it must be created first.

Or, for detailed explanations, and examples , do this:
How to extract a tar archive to original path?
User avatar
GarryRicketson
 
Posts: 5056
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: [Solved] How to extract archive to original path?

Postby johnywhy » 2018-09-11 13:08

Thx, Garry!
johnywhy
 
Posts: 21
Joined: 2011-11-24 00:17


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable