Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compress a symbolic link?

Tags:

With tar, I tried to compress a repository in a chroot environment with ssh, but it failed as it just compressed the symbolic link itself.

How can I compress its content?

-bash-3.00$ ls -ail 1263583 lrwxrwxrwx  1 root     root       18 Apr 18  2008 mainwebsite_html -> ../../var/www/html  -bash-3.00$ tar -cjvf archive.tar.bz2 mainwebsite_html  -bash-3.00$ ls -ail 7509101 -rw-r--r--  1 user1 user1  136 Feb 22 08:57 archive.tar.bz2 1263583 lrwxrwxrwx  1 root     root       18 Apr 18  2008 mainwebsite_html -> ../../var/www/html 
like image 973
krifur Avatar asked Feb 22 '11 09:02

krifur


People also ask

Can you zip a symlink?

Short answer: yes, if you do not specify the --symlinks option. By default, the zip command will dereference symbolic links. This means that symbolic links are replaced by the actual files or folders they link to.

How do I clean up a symbolic link?

To remove a symbolic link, use either the rm or unlink command followed by the name of the symlink as an argument. When removing a symbolic link that points to a directory do not append a trailing slash to the symlink name.

Do symlinks take up space?

Yes. They both take space as they both still have directory entries. A hardlink entry (really, a "normal entry" that [often] shares an inode) takes space, as does a symlink entry which must store the link path (the text itself) somehow.

How do I create a soft symbolic link?

Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to. Destination is the location to save the link – if this is left blank, the symlink is stored in the current working directory.


1 Answers

From the tar(1) man page:

  -h, --dereference           follow symlinks; archive and dump the files they point to 
like image 192
Ignacio Vazquez-Abrams Avatar answered Oct 12 '22 23:10

Ignacio Vazquez-Abrams