how to create symlink?

August 12th, 2006 mysurface Posted in Admin, ln | Hits: 331520 | 17 Comments »

First of all symlink stand for symbolic link, which is a very useful files like shortcuts in windows. Let me make few scenario why you need symlink.

Sometime, we want to goes to a directory which is very long and difficult to remember, for example /var/www/html/BLOG/Image/Archive/_icon. And you have to access to that directory oftenly after you login as root. What do you do to make your life easy? You can create a symlink in root home directory which is /root, like:

ln -s  /var/www/html/BLOG/Image/Archive/_icon /root/icon

You are creating a symlink call icon at /root which links you to /var/…._icon. Now you can easily go to _icon directory by

#assume you now at /root

cd icon

 

The second scenario where I create a symlink to my bash script where I store my symlink to /usr/local/bin.

I have write a sort of bash scripts to help me manipulate my work and I store them into a directory call sh. So everytime I want to run my script i have to go to sh directory and ./something.sh, which is very inefficient. so I create symlink and store at /usr/local/bin

ln -s /home/myname/sh/runme.sh /usr/local/bin/runme

So that when I want to run that script, I can just run it like other commands without specified ./ Another good thing is I can edit my scripts without relink or recreate the symlink, the changes will be reflects to the symlink automatically.

17 Responses to “how to create symlink?”

  1. [...] If you have directory symbolic link to lead you to certain directory, you may notice that when you change directory to symlink directory, the path will be symlink by default. [...]

  2. [...] Check out more about symlink at here. [...]

  3. Great explanation really helped me create a symlink for a ruby on rails installation on my web host. Don’t have access to my apache_conf so needed away to relink my public folder and my knowledge of sys-admin is intermediate

  4. thanks for this tip, you saved my hour…

    Eliena Andrews
    http://www.visitformoney.blogspot.com

  5. [...] this file in /usr/lib, /usr/share/lib or /lib. Bare in mind, libncurses.so.5 probably is just a symbolic link, you need to copy the real .so instead of its [...]

  6. Is there a way to move a directory and leave a symlink to it in the original spot?

  7. @Olin,
    Symlink s just literally point linked file( or directory). deleting/moving the directory is unknown to the literally pointing link file.

    So the link will be pointing to orignial location even after moving. Even more, if you delete / move the direcotry and create a file (say simple text file or whatever) with the deleted/moved name , the original link can become active and used to view the file with linked name.

  8. Can I create a symlink for a windows drive in my linux box?

  9. Cool! thanks ^^

  10. Tutto il materiale contenuto su questo sito è considerato freeware, cioè gratuito e per questo liberamente usabile. Se qualcuno volesse contribuire, a sostegno del sito, potrà farlo donando una qualsiasi cifra tramite il pulsante PayPal qui sotto, è sicuro, facile e veloce… ed io apprezzerò molto. Grazie

  11. Superowo, winszuj? stronki, buziaki!!!!!!!!

  12. Fajny blog, zrobi? sobie subskrypcj? rss :)

  13. Cool blog. Greetings from Poland

  14. Very useful site :)

  15. SteveP1975 Says:

    Hi, I have wordp ress hosted on home server,located at /dir/sub/sub .I want to allow visitors access to files on /dir2/sub/ .These files are to large to upload these files to the /dir/sub/sub/wp-content/uploads . So i want to link /wp-content to /dir2/sub . Is this as simple as cd /wp-content/uploads , ls -s /dir2/sub /uploads ? Or am I missing something else? Whatabout ownership? /wp-content/ is owned by www-data ,where as /dir2/ is owned by root?Any advice is nice. I’m a noob, been working on this as a learning project, have samba,cups,apache2 working of same machine. This isn’t production, it’s a personal project. But I plan to have it web accessable when done. Thanks again. P.s I’m sorry if this isn’t posted in the proper place.

  16. Excellent post. I was checking constantly this blog and I am impressed!
    Very useful info specially the last part
    :) I care for such information a lot. I was seeking this certain info for a very long time.

    Thank you and good luck.

  17. [...] like you want symlinks http://linux.byexamples.com/archives…reate-symlink/ [...]

Leave a Reply