13

There is literally nothing on google that I can find that will help me answer this question. I presume it is passing some other parameter to ls -i?

23

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
17

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
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.