How to count INODE usage in Linux

What is INODE ?

Each and every files and folders/directory called INODE, which includes all files like (text, image, pdf, xls, word, emails, programming file .php, .html, .perl, etc..) and folders/directory.Most of the hosting provider’s offering Shared UNLIMITED hosting that’s not true because in real world there is no UNLIMITED hard disk then how can its possible? Every hosters were provide some Terms & condition for INODE limits so before you decide to buy hosting just read the terms and services once whether its suitable for your requirements or not. If no, you can alternatively try Virtual Private Server (VPS) or Dedicated Server (DS) for this kind of servers by letting more money and can shape it as you wish.

How to count the INODE ?

1) Login to SSH
2) Go to corresponding user account home directory
3) To get the total number of INODE counts, use the below command.

# find . | wc -l
13987

Note: In your account having large number of files and directories, it will take little bit time to complete the process.
4) If you want to print split-of of inode usage in the current directory, use the below two commands.

Command-1:

This will print the output without grand total

# find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
  13846 ./public_html
     79 ./tmp
     20 ./.cpanel
     19 .
     15 ./mail
      5 ./ssl
      2 ./public_ftp
      1 ./etc

Command-2:

This will print the output with grand total

# echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
Detailed Inode usage for: /home/2daygeek
21              - .cpanel
2               - etc
1               - .htpasswds
16              - mail
3               - public_ftp
13847           - public_html
6               - ssl
80              - tmp
1               - .trash
Total:          13987

How to Reducing the inode count ?

Simply delete any files or emails you no longer need to reducing inodes on your account.

Leave a Reply

Your email address will not be published. Required fields are marked *

*