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

Symlinks


Some material is very old and may be incorrect today

© October 2005 Tony Lawrence

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".


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> Symlinks


Inexpensive and informative Apple related e-books:

Take control of Apple TV, Second Edition

Digital Sharing Crash Course

iOS 8: A Take Control Crash Course

Take Control of Apple Mail, Third Edition

Are Your Bits Flipped?





More Articles by © Tony Lawrence





Printer Friendly Version

Have you tried Searching this site?

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


Printer Friendly Version





[C has] the power of assembly language and the convenience of … assembly language. (Dennis Ritchie)




Linux posts

Troubleshooting posts


This post tagged:

Basics

Linux

Unix



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode