The Top Ten Concepts For Linux Beginners - Number 5, Inodes

Many aspects of Linux functionality are found,something else. The file access permissions
perhaps in a somewhat different form indenote the permissions, also discussed in a
Windows. Inodes, the subject of this article, areprevious article. A given file may have different
truly absent from the Windows bag of tricks.permissions for different users, for example
Given the practicality of inodes, Windows nowaccounting users may have permission to read
contains an imitation of this functionality. But really,and modify the file while marketing users only
to take full advantage of this somewhathave permission to read it.
complicated concept, you'll have to go to Linux orFile access information specifies when the file was
Unix.last accessed, last modified, and when the
So what are inodes and why would anyone wantassociated inode was last modified. The number
to use them? Inodes are the internal descriptionof links indicates the number of names that the
of a file. As we will see below, the specific inodefile has. In our example, the file has two links. If
contents for a given file are different in memoryeither accounting or marketing delete the file
and on disk. But the key to the inode is that a(assuming that they have such permission) the
single file may have different names. Why wouldnumber of links is reduced to 1. But the file is still
anybody want to do that? One of the mostthere and the number of links could be increased.
important reasons is that a user may access aThe inode on disk provides a list of data
shared file by an intuitive name. Users from theaddresses; the single file may be scattered across
accounting department could call a certain file withthe disk. The final value is the size of the file in
an accounting-style name, while users from thebytes.
marketing department could access this same fileThe inode in memory contains all of the above
by a name that makes sense to them. Thisinformation plus additional information such as
functionality alone makes inodes worth having.whether or not the file is available for processing
Furthermore, let's say that by accident the(someone else may be using it) and whether
"accounting" file was deleted. Accounting userssomeone is waiting to process the file.
could still access that file if they knew theRemember, several people may be using Unix or
"marketing" name. Remember, we are talkingLinux. If there were no file usage control two
about the very same file even though it hasdifferent people in accounting could pay a bill at
different names. People don't have to know aboutthe same time. Windows doesn't have this
these complications to be able to access the file.problem; it's not a multi-user system.
The extra processing is handled behind theThe ln command is used to create a link to a
scenes.given file. For example, ln acct1 mark1 links the
Now let's take a closer look at inodes. The inodemark1 file to the acct1 file, in other words makes
on disk contains the following information: filethe name mark1 available for the acct1 file. It's
owner identifier, file type, file access permissions,the same file, but with a new name. The ls -i
file access information, number of links, list ofcommand provides information about the file
data addresses, and file size. The file ownerincluding the number of links (the number of
identifier specifies the file owner and the groupnames for the file.)
owner as discussed in our article on permissionsThe next article in this series discusses the Linux
and groups. The file type indicates whether wekernel and processes.
are talking about a regular file, a directory, or