What you see as a filename in a directory is just that: 1 to whatevernumber of characters and a number. That number points to the Unix inode table where everything else about the file is kept: it's owner info, permissions, size, poinetrs to the actual data blocks- in other words everything EXCEPT the name is in the inode table and NOTHING but the name is in the directory. You can see the number by using "ls -i"
So, we have /bin/ls and the /bin direcory contains (on my machine) the characters "ls" and the number 92983. The 92983 is what points to the inode table for the filesystem; in a very real sense the only important piece of information is that number, and the name is really unimportant. So, if I had another entry in the directory (or anywhere on the same filesystem) of say "sl", but it had that same number, it would be equivalent to "ls"- it has the same owner, the same perms, the same dates, the same data- it is the same file because it is the same inode. That's a hard link.
The only problem with this scheme is that inode numbers start over on each filesystem. So there are (for example) a lot of files on my system with inode number 2, and a lot with inode number 100 and so on because each filesystem has its own inode table. So if I wanted to hard link across filesystems, I can't.
Therefore, we have a special bit that is set (in the inode table, not in the directory) that says effectively "pay no attention to the other stuff here, go get the information for this path". That's a soft link. You might notice that when you create a soft link, the size that shows up in "ls -l" deoends on what it is linked to: that's because the actual path name is being counted for its length. That's also why you can make a symbolic (soft) link to something that doesn't exist.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.