Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
1 - Suppose that i've a directory that has several symbolic links that points to different places of the filesystem. If i want to do a tarball to the respective directory, how do i set the option to also include in the tarball the filesystem structure where the links points to?
In the GNU version of tar it is done by default (no options needed). The soft links are preserved, even if the file they link to has been removed (in this case you get a broken link). On the other hand, there is an option to dereference links:
Quote:
-h, --dereference
don’t dump symlinks; dump the files they point to
If i've the a link, let's call "ln_test" in /home/user/ directory, that points to /opt/test.txt. If i do, tar -cvf zipped.tar ln_test, i want that /opt/test.txt also be included in the tarball, together with the link.
If i do, tar -cvf zipped.tar ln_test, i want that /opt/test.txt also be included in the tarball, together with the link
I think I did not understood the problem! I am afraid it is not possible. Indeed, to spread some files all over the system is a task for a kind of installer.
Sorry, my previous post was not really true, in the sense you can do something like
Code:
tar cvf file.tar dir_one dir_two
to archive multiple directory in one tarball. Anyway, I think there is no option to automatically follow links to include the files they point to (with their absolute path, I mean). Furthermore you will face another problem: in absolute paths (those beginning with /) the leading / is stripped out to minimize the risk of overwriting system files!
Dereferencing the links makes the pointed to location copied to the tar file as well. Thats what I got from the statement above.
Quote:
In the GNU version of tar it is done by default (no options needed). The soft links are preserved, even if the file they link to has been removed (in this case you get a broken link). On the other hand, there is an option to dereference links:
Quote:
-h, --dereference
don’t dump symlinks; dump the files they point to
The hard links are copied as is.
Yes, but not in the way the OP expected! Option -h copies the file in place of the link, assigning the name of the link itself to the copied file. For example, if I have the following link
Code:
my_link -> /usr/local/testfile.txt
The file testfile.txt will be copied into the archive in place of the symbolic link and will be named my_link (the path and name of the file the link pointed to, will be lost).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.