How To Count Inodes For Each Directory on Linux March 24, 2011Posted 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)
- 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 .
#!/bin/bash # count inodes for each directory LIST=`ls` for i in $LIST; do echo $i find $i -printf "%i\n" | sort -u | wc -l done
Also this line seems good for figuring out which directory is using up the most space .
du – ks ./* | sort -n