How to Preserve Symbolic Links in Tar Command

Last updated: November 5, 2022

How to preserve symbolic links (symlinks) especially when you tar the files is explained below. We all know how to use tar command. The below option shows the way to preserve links when you archive.


tar -cvhf archive.tar /backupfolder

Note: What you need to remember is that when tar archives a symbolic link, it writes a record to the archive naming the target of the link. When you use -h with -c, it causes tar to archive the files symbolic links point to, instead of the linking themselves. When this option is used, when tar encounters a symbolic link, it will archive the linked-to file, instead of simply recording the presence of a symbolic link.

About The Author

Bobbin Zachariah

Bobbin Zachariah

Bobbin started his career in IT in the year 2000 as a computer science instructor and worked as a Linux system engineer and senior analyst roles. Currently working in DevOps environments to increase efficiency and improve delivery time in AWS Cloud infrastructure. He is certified in RHEL, CCNA, and MCP and holds a Masters's in computer science. When in his free time love playing cricket, blogging, and listening to music.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment