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.
should untar all the files and subdirectories to your current directory, so be aware of where you are when you untar the file. Any symbolic links should be created as they were saved, but could point to non-existant locations if the tar file is extracted on a different box or in a different location. It depends partly on whether the links used absolute paths or relative paths, and whether they were pointing to something that was also in the tar file.
Yeah, but it can be a bit confusing. The basic syntax is just like a copy command, that is:
ln -s <target> <link>
So, for instance, if I want a link called media in my homedir that points at /download/media, it will be like this:
ln -s /download/media ~alan/media
This will create a link to an absolute path, /download/media.
But if I want to make a link to my brother's media stuff in his homedir that is parallel to mine (that is, mine may be /home/alan and his is /home/marty), then I can make it relative like this:
ln -s ../marty/media ~alan/media
Bear in mind that this relative path must be with respect to MY HOMEDIR, that is, with respect to where the link is created, rather than where I am when I create the link.
In other words, I can be at /root (or anywhere at all) and issue that 'ln -s' command just above, and it will point to the right place, ~marty/media, because it is how to get there from *where the link gets put*.
So if I were to tar up only my homedir, but not my brother's, when I untar it somewhere else, that link will be pointing to a non-existant directory, but if I tar the /home directory, it will still find my brother's media directory, no matter where it gets untarred.
Some people get confused because they specify the target relative to where they are when they issue the link command, which works OK if you are in the directory where the link will be created, but doesn't work if you are in a directory above or below, or elsewhere.
The easy way is to be in the directory where the link will be and specify the link relative to where you are.
The less-intuitive way is to specify the target relative to where the link will be. This actually would allow you to create a link that points at a non-existant directory when you create the tar file, but will point at a real directory when it gets untarred in its intended destination. Obscure, even weird, but doable.
You may want to use the -l (local) option, so that you don't back up files from your cdrom. If you have several partitions mounted, such as separate /home and /usr partitions, then doing this you will need to include each one separately.
There is a fairly lengthy manual, that you can produce from the source package/tarball. It isn't included in the "make" default target, but if you use "make pdf" or "make dvi" or "make ps", you will produce the manual.
Also, consider how you will select the files to be backed up in the future. You may want to use the file command to produce a list of files changed after the last date. Another thing to consider is using kar or kdar to produce the backups instead. Tar was written with tape backups in mind, while dar was written to make cdrom and dvd backups easier.
Originally posted by trickykid man tar gives you all available options but file permissions should be preserved by default... but the -p option is for preserve.
tar -cpvf root/ root.tar
But it doesn't preserve the ownership.
I had a bunch of files owned by user A
user B tar A's files. When B untar it, file permissions are preserved, but the owner now is B, instead of A.
I think it does preserve it, from what I just read and the subscequant experiment... however, if you change system altogether, and the user ID are different, I experienced that the username gets mixed...
The -p option should preserve the permissions, and I believe, ownership. When extracting, you also need to use the -p. If the ID doesn't exist on the box when extracting, it will probably show the UID of the previous owner.
(I tried to look up this info in man pages, but they are incomplete and say to read the info pages, but I have to go back and relearn how to use info - not at all intuitive!)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.