Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between symbolic and static links.

Status
Not open for further replies.

123jk

Programmer
Mar 22, 2001
7
0
0
IN

Hello,

I need to know the difference between static and symbolic links.

Thanks,
jaya
 
run the man command: -
man ln

ln - makes hard or symbolic links to files

contains a good description

a symboic link is created with the -s option
 
To understand that, you need to know a little bit about Unix filesystems. I have a longer article at but quickly:

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.




Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top