The Top Ten Concepts for Linux Beginners – Number 5, Inodes

linux95 The Top Ten Concepts for Linux Beginners   Number 5, Inodes
Levi Reiss asked:

ctionality is often found, albeit in a different form in Windows. Inodes, the subject of this article, are an exception to this rule. Because of their practicality, Windows now includes an imitation of this functionality. But if you want to take full advantage of this somewhat complicated concept, you’ll have to go to Linux or Unix.

So what are inodes and why would anyone want to use them? Inodes are the internal description of a file. As we will see below, the specific inode contents for a given file are different in memory and on disk. But the key to the inode is that a single file may have different names. Why would anybody want to do that? One very important reason is that a user may access a shared file by an intuitive name. Accounting department users could give a certain file an accounting-style name, while users from the marketing department could access this same file by a name that makes sense to them. This functionality alone makes inodes worth while.

Furthermore, let’s say that by accident the “accounting” file was deleted. Accounting users could still access that file if they knew the “marketing” name. Remember, we are talking about one single file that has different names. People don’t have to know about these complications to be able to access the file. The extra processing is carried out behind the scenes.
Now let’s examine inodes more closely. The inode on disk contains the following information: file owner identifier, file type, file access permissions, file access information, number of links, list of data addresses, and file size. The file owner identifier specifies the file owner and the group owner as discussed in our article on permissions and groups. The file type indicates whether we are talking about a regular file, a directory, or something else. The file access permissions denote the permissions, also discussed in a previous article. A given file may have different permissions for different users, for example accounting users may have permission to read and modify the file while marketing users only have permission to read it.

File access information specifies when the file was last accessed, last modified, and when the associated inode was last modified. The number of links indicates the number of names that the file has. In our example, the file has two links. If either accounting or marketing delete the file (assuming that they have such permission) the number of links is reduced to 1. But the file is still there and the number of links could be increased.

The inode on disk provides a list of data addresses; the single file may be scattered across the disk. The final value is the size of the file in bytes.

The inode in memory contains all of the above information plus additional information, for example, whether the file is available for processing (someone else may be using it) and whether someone is waiting to process the file. Remember, several people may be using Unix or Linux simultaneously. If there were no file usage control two different people in accounting could pay a bill at the same time. Windows doesn’t have this problem; it’s not a multi-user system.

The ln command is used to create a link to a given file. For example, ln acct1 mark1 links the mark1 file to the acct1 file; it makes the name mark1 available for the acct1 file. It’s the same file, but with a new name. The ls ‘i command provides information about the file including the number of links (the number of names for the file.)

The next article in this series discusses the Linux kernel and processes.

Related Posts

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment