Symbolic links
Can someone tell me what symbolic links are and how to create them? What are symbolic links are used for?
Thanks! Val |
Symbolic links, or symlinks are created with the ln -s command. It's quite simple: ln -s originalfile symlinkname
They are pretty damn useful, in some circumstances. Take this, for example: I have lots of Linux stuff on my Windows partition, which would be mounted as: /mnt/win_e/To Be Burned To CD/Linux Stuff/ Now, some RPM programs (like the ol' Package Manager) seems not too happy about installing RPMs from a directory with spaces in it. So what do I do: ln -s /mnt/win_e/To Be Burned To CD/Linux Stuff/ ~/stuff Now, all I have to do is install the RPM files that appear to be under ~/stuff. Simple. I think, though, for a more technical answe: They create a file with the same inode as another, but with either a different name or in a different place. Anyone care for a follow up? |
From "man ln",
Quote:
|
Hard links have the same inode number.
Symbolic links are small files that contain information as to where the target file or directory is located. They have an inode number that is different then the file or directory they point to. Also, doing an ' ls -l ', will always give the permissions for a symbolic link as ' lrwxrwxrwx '. |
Thanks, everyone! Your instructions were perfect and it worked like a charm.
Take care! Valerie |
You're welcome. :)
|
Quote:
|
So what about when you're using software RAID? Could you have hardlinks between files that appear to be on the same partition, but are actually on different disks?
|
Yes... hard links are a function of the filesystem, not the physical disk. Every file on a filesystem is assigned a unique inode number. When you create a hard link, the filesystem associates it with the same inode number as the origional file. It's kind of like making a copy of the file only the two never get out of sync. If either is deleted, the other stays intact.
|
What is the use of hard links? as far as I can tell, symbolic links do everything hard links do and more.
|
hard links point to a particular file that will follow that file where ever it goes. it allows you to move the file that has been hardlinked and it will still work. it basically allows you to use several names for one file
its vaguely similar to a pointer in C where you can use it to give an alternate name to a variable HTH ALex |
The only advantage to using hard links is if the origional file gets deleted accidently, you don't lose it, yet it doesn't take up any more space on the hard drive like a backup would. With a soft link, you're screwed if the file gets deleted. It's nice for making a mirror of files you want to be sure not to lose. Be aware though, that it's NOT a backup... it's just a pointer to the same spot on the disk as the origional file, so editing either will affect both.
|
One more advantage to using hard links is that you don't use up another inode. Believe or not you have a limited number of inodes. In theory if you made a bunch of symbolic links, you could use up all the inodes. This won't happen with hard links.
The main difference between the two is that a hard link won't work across filesystems and a soft link will. Ryan |
All times are GMT -5. The time now is 02:15 AM. |