I must have deleted it, but at one point, after my discussion of Unix filesystems, you said you had a couple of questions about inodes. You never got around to asking me those questions, so instead I will just give a more thorough explanation of inodes. In a DOS FAT filesystem, information about a file is kept in the directory. Every directory entry contains the file name and extension, the size (in bytes) of the file, the file's datestamp, the location of the first disk block (cluster) of the file, and four flags: hidden, system, read-only, and archive. A Unix filesystem carries more information about a file than that. There is the file's mode, which includes the file type and the file's permissions. There is the link count (the number of names the file has, explained below). There is the (numeric) user and group id's that own the file. There is the size of the file. There are three dates, often kept to the nanosecond, which give the last access time, the last modification time, and the last time the inode was changed. There is the number of disk blocks used, and the status flags (man chflags). All of this information is kept in a record on the disk known as the inode. When a filesystem is formatted, it is built with a fixed number of inodes (you can see how many by using the "df -i" command and looking at the iused, ifree, and %iused columns). These are generally used in sequential order, and they are numbered sequentially starting with 0. Note that an inode does NOT store the NAME of the file. The name is stored in the directory. A directory is really just a special kind of file, that contains a list of filenames and inode numbers. When Unix accesses a file, it searches the directory for that name and retrieves the inode number. This tells the system which inode on the disk to look at. That inode is retrieved, and all the other information about the file is stored in the inode. You can see the inode number of a file by using the -i option of the ls command: fury.coreth.com:/bin 1098> ls -i /bin/stty 128 /bin/stty You can find files with a given inode number by using the -inum option of the file command: fury.coreth.com:/bin 1100> find /bin -inum 128 -print /bin/stty The purpose for keeping the filename and the other information about a file seperate is that this allows a file to have multiple filenames. I will give two examples ... The vi full screen text editor was originally an extension of the ex line editor (which in turn was an extension of the ed line editor). vi can do anything that ex does, but it also displays it in a full screen mode. In reality, vi and ex are the same program. The vi functionality is only available when the program is executed using the name vi. Since they are the same program, there could simply be two copies in the /usr/bin directory. But if they are the same file, why waste all that disk space? Why not give one file two names? As it happens, it has six names: nvi, nex, nview, vi, ex, and view. In the /usr/bin directory, there are directory entries for all of these, and they all reference the same inode number: fury.coreth.com:/usr/bin 1108> ls -i nvi nex nview vi ex view 173331 ex 173331 nvi 173331 vi 173331 nex 173331 nview 173331 view Everything about these files is identical, because they are the same file and the same information is pulled from the same inode: fury.coreth.com:/usr/bin 1109> ls -l nvi nex nview vi ex view -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 ex -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 nex -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 nvi -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 nview -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 vi -r-xr-xr-x 6 root wheel 280272 Jan 28 2002 view When the program is executed, it looks at the command-line to see which name was used to execute it, and it decides from that which behavior to exhibit. Another example, which I will have to create because I can't find any "naturally" occuring examples of, is the same name appearing in multiple directories. I will even show you how I create it. In my home directory, I have a file called "plasma.txt": fury.coreth.com:/home/mpearce 1128> ls -l plasma.txt -rw-r--r-- 1 mpearce staff 466 Sep 4 16:45 plasma.txt Also in my home directory, I have a subdirectory called "tmp". I want to create a link to that same file in the tmp subdirectory: fury.coreth.com:/home/mpearce 1129> ln plasma.txt tmp fury.coreth.com:/home/mpearce 1130> ls -l plasma.txt tmp/plasma.txt -rw-r--r-- 2 mpearce staff 466 Sep 4 16:45 plasma.txt -rw-r--r-- 2 mpearce staff 466 Sep 4 16:45 tmp/plasma.txt So, now there is one file, that has the name "/home/mpearce/plasma.txt" and also the name "/home/mpearce/tmp/plasma.txt". The "plasma.txt" name is the same but in two different directories. It is the same file, with the same inode, occupying the same disk space. Now, take a look at the second column of the "ls -l" output in the examples above. The number appearing after the permission bits. This is the number of links or filenames that the file has. In other words, this is the number of directory entries that reference this inode. When I created the link for plasma.txt, this value increased from 1 to 2. All of the filenames for vi show that there are a total of 6 names. Normally, files do not have multiple names (or links). However, all directories have at least two names. This is because of the special names "." and ".." for directories, which signify the current directory and the parent directory, respectively. If I create a directory: fury.coreth.com:/home/mpearce 1132> mkdir foobar fury.coreth.com:/home/mpearce 1133> ls -ld foobar drwxr-xr-x 2 mpearce staff 512 Sep 12 14:55 foobar fury.coreth.com:/home/mpearce 1134> ls -la foobar total 9 drwxr-xr-x 2 mpearce staff 512 Sep 12 14:55 . drwxr-xr-x 86 mpearce staff 7680 Sep 12 14:55 .. You can see that the name of the directory ("foobar") has two names. The other name is "." (a single dot) inside that directory. Also inside that directory is a special directory entry named ".." (two dots). That references the parent directory, which happens to be my home directory. The reason that there are 86 links for my home directory is that my home directory has 84 subdirectories, each with a "..", plus the "mpearce" entry in /home, plus the "." entry within my home directory. There is a restriction to the use of multiple filenames for the same file. This is often refered to as a "link" or a "hard link". The restriction is that all of the names must be in the same filesystem, because they reference an inode of a particular filesystem. If I have two different filesystems, say /usr and /home, I cannot have filenames in /usr and in /home for the same file. That file (and its inode) must exist on one filesystem or the other. Yet, links that span filesystems would still be useful. This is why the symbolic link was invented. This operates on a very different principle. Instead of sharing an inode, a symbolic link is a special type of file that stores the other name of the file. An example of this is /etc/termcap, which is really a symbolic link to /usr/share/misc/termcap: fury.coreth.com:/etc 1176> ls -l /etc/termcap lrwxrwxrwx 1 root wheel 23 May 7 07:53 /etc/termcap -> /usr/share/mi sc/termcap Symbolic links incurr a performance hit. To open the file, the operating system must traverse the filesystem tree to find the first filename, then it must start over and look for the next filename. Generally speaking, you should use a hard link when you know it will work. Interestingly, even though this performance degredation is well known, many System V versions of Unix (including Solaris, SCO, and to some extent HP-UX) make extensive use of symlinks for the files installed with the operating system. In my opinion, this makes things messy and complicated for the admin, and needlessly slows the system down. Symbolic links are created with the -s option of the ln command. Further Reading: man inode man ln man ls # (see the -i option) man find # (see the -inum option) man df # (see the -i option)