Ten Important Linux Concepts For Beginners
Number 5, Inodes

Linux is a great alternative to Microsoft Windows. It's not hard to get started. This article gets you started with the concepts and commands you need to know to work with Linux inodes.

Linux Inodes

Many aspects of Linux functionality are found, perhaps in a somewhat different form in Windows. Inodes, the subject of this article, are truly absent from the Windows bag of tricks. Given the practicality of inodes, Windows now contains an imitation of this functionality. But really, 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 of the most important reasons is that a user may access a shared file by an intuitive name. Users from the accounting department could call a certain file with 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 having.


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 the very same file even though it has different names. People don’t have to know about these complications to be able to access the file. The extra processing is handled behind the scenes.


Linux inode diagram

You need not know inodes to take advantage of them.

Now let’s take a closer look at inodes. 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 such as whether or not 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. 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, in other words 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.