Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can you please tell me how can I tar ball/compress a directory hierarchy with soft links in linux?

Thank you.

share|improve this question
Do you want the final tarbal to have the soft-links or the target file of those links. It's unclear in your question. – slubman May 4 '10 at 6:51
Either cases are fine. Thank you. – michael May 4 '10 at 6:53

GNU tar normally includes symlinks in the tarball it generates. If you want it to include the file the symlink points to instead then pass it -h/--dereference when creating the tarball.

share|improve this answer

When used with standard arguments tar xvf the soft link are saved in the tar archive as soft-links. Then there is 2 cases

  • If your symlink is a full symlink, it might be broken when untarred.
  • If your symlink is a relative symlink, under the folder you are tarring it will work fine when extracted.

If you want to tar the file and not the symlink, you can use the -h / --dereference argument.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.