jump to navigation

How To Count Inodes For Each Directory on Linux March 24, 2011

Posted by Tournas Dimitrios in Uncategorized.

Inode stores basic information about a regular file, directory, or other file system object. The inode number is a unique integer assigned to the device upon which it is stored. All files are hard links to inodes. Whenever a program refers to a file by name, the system conceptually uses the filename to search for the corresponding inode. Many computer programs often give i-node numbers to designate a file. Popular disk integrity checking utilities fsck or pfiles command may serve here as examples. The following  information is stored in an inode.

  • File type (executable, block special etc)
  • Permissions (read, write etc)
  • Owner
  • Group
  • File Size
  • File access, change and modification time
  • File deletion time
  • Number of links (soft/hard)
  • Access Control List (ACLs)

Each file has an inode associated with it and an unique number called inode number. This number is used to look up an entry in the inode table. Many web hosting companies limits you to a maximum inodes per account (example 50000) , so it is not unlimited . Here is a script that I use which helps me count each inodes in a directory .

# count inodes for each directory
for i in $LIST; do
echo $i
find $i -printf "%i\n" | sort -u | wc -l

Also this line seems good for figuring out which directory is using up the most space .
du – ks ./* | sort -n


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s