Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

If I have a tar file, bob.tar, which contains real_file and link_to_real_file, in which the latter is a symlink, is there a way to extract the contents of bob.tar so that link_to_real_file will not be a symlink, but be a copy of real_file.

I know this is indeed possible on the creation side, if I use the -h flag.

The command tar -cvhf bob.tar real_file link_to_real_file will dereference link_to_real_file, but I want to do this on the extraction side regardless of how the tar file was created.

share|improve this question

Mount the archive as a directory, for example with AVFS, then use your favorite file copying tool.

cp -RLp ~/.avfs$PWD/bob.tar\# target-directory/
share|improve this answer

The given answer is complex and requires AVFS. Try this: extract the archive then recreate the archive using -h and then extract again. Works like a charm.

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.