Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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 '.
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.
Distribution: Slackware 10, Fedora Core 3, Mac OS X
Posts: 617
Rep:
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.