How to check inode usage on linux for a specific cpanel user account or directory
If you’re a linux system administrator you’re probably already familiar with the term “inode”. For those of you who are not, an inode is basically a way to measure the amount of files a user has. This includes every email, cache file, image, and so on. If it has a filename it is considered an inode. Normally hosts will use this as a way to determine clients that need to be removed from backups because of the IO load they put on the server from the amount of inodes they have.
A few ways to measure this are…
Using the script I created and posted on GitHub:
https://github.com/tripflex/inodes
Or …
Current Directory
Navigate to the users directory you want the inode count for
| 1 | cd /home/theuser | 
Now use this echo code below and you should get something similar to the output you see right below it.
| 1 | echo "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" | 
Here’s what it should like like after executing it:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | echo "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" Inode usage for: /home/theuser 26              - attachments 2               - .cpaddons 64              - .cpanel 1               - downloads 20              - etc 1               - .htpasswds 2               - .HttpRequest 25084           - mail 2               - .matplotlib 9               - .MirrorSearch 1               - perl5 6               - public_ftp 7466            - public_html 4               - .softaculous 1               - .sqmailattach 2               - .sqmaildata 11              - ssl 959             - templates_c 682             - tmp 1               - .trash Total:          34379 | 
In the example above we have 34,379 inodes under theuser’s account.
Coming Soon
I’ll write a script soon to incorporate something similar to this to automatically remove users from backups and send an email when it goes over specified limit.
Wikipedia
- 
        Fahad










