home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 1.21 Making Pathnames Chapter 1
Introduction
Next: 1.23 File Access Permissions
 

1.22 How UNIX Keeps Track of Files: Inodes

The ability to mumble about inodes is the key to social success at a UNIX gurus' cocktail party. This may not seem attractive to you, but sooner or later you will need to know what an inode is.

Seriously, inodes are an important part of the UNIX filesystem. You don't need to worry about them most of the time, but it does help to know what they are.

An inode is a data structure on the disk that describes a file. It holds most of the important information about the file, including the on-disk address of the file's data blocks (the part of the file that you care about). Each inode has its own identifying number, called an i-number . You really don't care about where a file is physically located on a disk. You usually don't care about the i-number - unless you're trying to find the links ( 18.3 , 17.22 ) to a file. But you do care about the following information, all of which is stored in a file's inode:

  • The file's ownership: the user and the group ( 22.13 ) that own the file

  • The file's access mode ( 1.23 , 22.2 ) : whether or not various users and groups are allowed to read, write, or execute the file

  • The file's timestamp ( 21.5 , 21.6 ) : when the file itself was last modified, when the file was last accessed, and when the inode was last modified

  • The file's type: whether the file is a regular file, a special file, or some other kind of abstraction masquerading ( 1.29 ) as a file

Each filesystem has a set number of inodes that are created when the filesystem is first created (usually when the disk is first initialized). This number is therefore the maximum number of files that the filesystem can hold. It cannot be changed without reinitializing the filesystem, which destroys all the data that the filesystem holds. It is possible, though rare, for a filesystem to run out of inodes, just like it is possible to run out of storage space - this can happen on filesystems with many, many small files.

The ls -l ( 22.2 ) command shows much of this information. The ls -i option ( 18.4 ) shows a file's i-number. The stat ( 21.13 ) command lists almost everything in an inode.

- ML


Previous: 1.21 Making Pathnames UNIX Power Tools Next: 1.23 File Access Permissions
1.21 Making Pathnames Book Index 1.23 File Access Permissions

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System