How do I find the inode of any directory?
Yes, the argument -i will print the inode number of each file or directory the ls command is listing. As you want to print the inode number of a directory, I would suggest using the argument -d to only list directories. For printing the inode number the directory /path/to/dir, use the following command line:
ls -id /path/to/dir
From man ls
:
-d, --directory
list directory entries instead of contents, and do not derefer‐
ence symbolic links
-i, --inode
print the index number of each file
This works also with stat:
DIR=/
stat -c '%i' $DIR
From man stat
:
-c --format=FORMAT
use the specified FORMAT instead of the default; output a new‐
line after each use of FORMAT
[...]
The valid format sequences for files:
%i inode number
You can find inode of file and directory with -i
option
ls -id /home/user/dir
You can get information of consumed inode of your system
df -hi