What is an “inode”?
An inode is a record in a disk table, which contains information about a file or folder such as its size, owner, device node, socket, pipe, etc., except data content and file name. The number of inodes on your account equals the number of files and folders you have on it.
# df -i (check inode usage)
- Find out the large files for inode usage:
for i in /*; do echo $i; find $i |wc -l | sort ; done
(/* = specified directory)
- Look for biggest directories in the current working directory:
du -a | sort -n -r | head -n 5
du -hsx * | sort -rh | head -10 (Best)
du -a /var | sort -n -r | head -n 10 (in /var folder)
Let us break down the command and see what says each parameter.
ducommand: Estimate file space usage.
a: Displays all files and folders.
sortcommand : Sort lines of text files.
-n: Compare according to string numerical value.
-r: Reverse the result of comparisons.
head: Output the first part of files.
-n: Print the first ‘n’ lines. (In our case, We displayed first 5 lines).
- List top 10 Inodes files/folders:
for i in `ls -1A | grep -v “\.\./” | grep -v “\./”`; do echo “`find $i | sort -u | wc -l` $i”; done | sort -rn | head -10
- Remove all files from a folder:
rm -rf folder/*