APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Symlinks

Linux "symlinks" is a handy utility for managing symbolic links. It can clean up the sort of problems that come from carelesness when creating symbolic links. For purposes of illustration, I created some legal but structurally incorrect symbolic links. With the exeption of the "dangling" sl3 (a dangling symlink points somewhere that does not exist), these all work, but they have problems, and "symlinks -v" will show us:



$ symlinks -v -s .
messy:    /home/tony/varwwwmess -> /var//www
dangling: /home/tony/sl2 -> ../incoming
lengthy:  /home/tony/sl3 -> ../tony/incoming
other_fs: /home/tony/varwww -> /var/www
absolute: /home/tony/vhosts -> /home/httpd/vhosts/
relative: /home/tony/webby -> vhosts/webby.com
 

That's helpful. Even more helpful is that symlinks can clean this stuff up in a flash:

$ symlinks -c -s .
messy:    /home/tony/varwwwmess -> /var//www
changed:  /home/tony/varwwwmess -> /var/www
dangling: /home/tony/sl2 -> ../incoming
lengthy:  /home/tony/sl3 -> ../tony/incoming
changed:  /home/tony/sl3 -> incoming
other_fs: /home/tony/varwww -> /var/www
absolute: /home/tony/vhosts -> /home/httpd/vhosts/
changed:  /home/tony/vhosts -> ../httpd/vhosts
$ symlinks -v -s .
other_fs: /home/tony/varwwwmess -> /var/www
relative: /home/tony/sl3 -> incoming
dangling: /home/tony/sl2 -> ../incoming
other_fs: /home/tony/varwww -> /var/www
relative: /home/tony/vhosts -> ../httpd/vhosts
relative: /home/tony/webby -> vhosts/webby.com
 

The -c fixes all problems, but does leave the dangling link. To remove it:

$ symlinks -d .
other_fs: /home/tony/varwwwmess -> /var/www
dangling: /home/tony/sl2 -> ../incoming
deleted:  /home/tony/sl2 -> ../incoming
other_fs: /home/tony/varwww -> /var/www
 

"symlinks" can operate recursively with "-r" and can show you its actions with "-t".



Got something to add? Send me email.





Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





What happens then? Is there a ticker tape parade and heartfelt thanks from the computer it has reached? No, my friends, there is not. The poor packet is immediately gutted, stripped of its protective layers and tossed into the hungry maw of whatever application (mail, a webserver, whatever) it belongs to. (Tony Lawrence)

Show me your flowchart and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowchart; it'll be obvious. (Fred Brooks, The Mythical Man Month)







This post tagged: