LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What are links, and how do I use them? (https://www.linuxquestions.org/questions/linux-newbie-8/what-are-links-and-how-do-i-use-them-147644/)

kid_unknown 02-18-2004 12:54 PM

What are links, and how do I use them?
 
Just starting out using linux and i'm attempting to learn the core basics of Linux and I do believe that symbolic and hard links come under that category. So I was hoping that someone could explain and/or post an URL to somewhere that does explain. :)

TIA

aaa 02-18-2004 01:03 PM

Symbolic links are kind of like shortcuts in Windows, except they are more 'real'. For example, you can cd (change directory) into a link like it's a real folder. To make symbolic links:
ln -s [file to be linked to] [link]
Remember, File first, Link last.
See this for more info: http://www.hmug.org/man/1/ln.html

lone_nut 02-18-2004 01:11 PM

And in case, the man page was not clear, ln can also create hard links. If you create a hard link, say from file /dev/null to /home/some-user/null using:
ln /dev/null /home/some-user/null
and then accidentally remove the file /dev/null, that one in your home directory would still work just the same. However:
1) you cant make hard links across different partitions, or harddiskes
2) you cant make hard links from directories.

kid_unknown 02-18-2004 01:12 PM

So i'm wondering, what do most people use symbolic links for? The only time i've used shortcuts in windows is on the desktop...

frieza 02-18-2004 01:40 PM

hmm, well, i use them for pointing libraries in /usr/local/lib to /usr/lib and /lib so the programs that need them work... you could aslo say link a mount such as /mnt/cdrom into /var/ftp/pub/ to give anonymous ftp users access to /mnt/cdrom

Thymox 02-18-2004 06:49 PM

I use them so that I can have the same files appear in different places. For instance, I am a habitual Window Manager tester, so I have a rather odd .xinitrc setup. Basically I have a subdirectory called ~/.xscripts. In that directory I have a load of basic scripts that all follow the same basic pattern:
Code:

exec gkrellm&
exec xmms&
exec xbindkeys &
exec Esetroot -stretch ~/files/images/backgrounds/BACKGROUND.IMAGE&
exec galeon -s&
exec root-tail -noinitial -f -g 228x90+5+5 -i 0.1 /var/log/explanations,white /var/log/cron/info,green /var/log/syslog,yellow /var/log/user.log,cyan &
exec cdde&
exec WINDOWMANAGER

Obviously I change the last line. I create a symlink from my current choice to ~/.xscripts/current, and I then create a symlink from that to ~/.xinitrc. So, in short, ~/.xinitrc is a symlink of ~/.xscripts/current is a symlink of ~/.xscripts/sawfish
This is a bit of an odd setup, but it works very well and serves me just the way I want.


All times are GMT -5. The time now is 12:18 AM.