Using du to count number of files in Linux

Though du is useful in counting the file and directory as well as seeing how much space is occupied by a directory in a Linux system. It can be also used to count number of files in a system by executing the du command with inodes option which will display what we needed (We can also find command to do the same)

To find the files, we can use inodes option du as shown below

#This will display summary of all the files
du --inodes -s
du


To display all the inodes we can use something like this

#This will display all the files inside the directories inside a specific folder
du --inodes

To display all the files at a particular depth we can execute inodes all with depth command

du --inodes -d 2


And these are the different ways in which inodes can be executed so as to find the list of files within a particular directory

du

You may also like...