Jump to content
xisto Community
Sign in to follow this  
rob86

Symbolic Links: Super Shortcuts For Linux

Recommended Posts

This might be basic stuff and common knowledge, but I sure found it useful once I tried it.

 

Most people know what a shortcut is, in Windows. You can have a shortcut on your Desktop and you can click on it to launch a program. It's a link to the program.

 

Linux has an even better alternative. Links.

 

There are hard links and symbolic links. I won't go into details about the difference because to be honest, it's more complicated than you'd think. They are pretty similar.

 

For more detailed information, I've found these links useful:

 

http://linuxgazette.net/105/pitcher.html

https://ubuntuforums.org/showthread.php?t=310834


For my basic tutorial, I'll tell you how to use symbolic links. It's as simple as typing this command.

 

ln -s PATH.TO.FILE.OR.DIR LINKNAME

Here is an example of it's usage, that I personally use. I have a LaCie external hard drive. On Linux, to access it I have to type in /media/lacie/. This can get annoying, so I made a symbolic link in the root directory, /

 

ln -s /media/lacie /lacie

You will most likely get a "Permission Denied" trying to create a symlink in your root directory. You need root access or to use sudo. I purposely left that out of the example because if you don't know what you are doing you could screw things up (you could overwrite something important if you choose your link name wrong!).

 

Now I can simply type refer to it as /lacie instead of /media/lacie. That's the beauty of symlinks. You can even link to directories! Symlinks to files would be done the same way of course. Useful!

Share this post


Link to post
Share on other sites

Did you know it took up to Windows Vista to introduce symbolic links on Windows? I said to myself, "About time," when i read it. Can't remember where i read it, though; but it was probably on the Microsoft website. I normally use symbolic links for GTK styles (to link the ones in my ~/.themes directory to /usr/share/themes so my themes will get picked up by programs with root privileges and so the themes won't get deleted when reinstalling the system) and custom libraries (so my custom programs can execute without having to "install" the libraries).

Share this post


Link to post
Share on other sites

I'm surprised that Windows introduced them at all. Doesn't matter to me much, though, I have my doubts I'll ever be using Windows much any more unless it's for gaming or some important windows-only software.Are they still called Symbolic links or do they have another name? Symbolic shortcuts, maybe?

Share this post


Link to post
Share on other sites

yes very true ... symbolic links are cool in linux and linux very much uses these links.

For e.g: when it switches run-levels i.e :
1. when it goes from text mode to graphical mode
2. when it goes from single user mode to multi-user mode.
3. when it is shutting down or restarting.

When it needs to start a new service or kill a running service while switching runlevels; it uses symbolic links to actual services(program) to do it. To know more on how it is done, take a look at: http://tldp.org/LDP/intro-linux/html/sect_04_02.html

Also, it is used to upgrade a part of system without affecting other parts of systems. For e.g you have library xyz-1.0.so. You can create a symbolic link xyz.so to this lib xyz-1.0.so i.e :

xyz.so -> xyz-1.0.so.

Other programs can use this symbolic link to access this library, later when you need to upgrade your library to version 2.0, you will just need to update symbolic link to this library and other programs will start to use your new library. :)

These are few of many cases when linux itself uses symbolic links.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.