Posted: . At: 9:26 AM. This was 2 years ago. Post ID: 16306
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



How to list the inodes of directories on a Linux machine.


It is possible with ls to list only directories on a Linux system, but you can also list the inode values of the directories on a Linux system.

The example below shows how this is done. The -i parameter shows the đź“‚ inodes value.

┌──(john㉿DESKTOP-PF01IEE)-[~]
└─$ ls -ldi -- */
  150 drwxr-xr-x 2 john john 4096 May 12 10:50 Documents/
43846 drwxr-xr-x 3 john john 4096 Apr 19 10:24 Downloads/

This is how to print what filesystem type a folder is housed on.

┌──(john㉿DESKTOP-PF01IEE)-[~]
└─$ df -PTh Documents/ | awk ' NR==2 {print $2}'
ext4

That could also be very useful indeed.

This is another way to print the inode value of a directory on a Linux system.

┌──(john㉿DESKTOP-PF01IEE)-[~]
└─$ stat Downloads/ | awk 'NR==3 {printf $4}'
43846

And yet another way to print the filesystem type a directory is located on.

┌──(john㉿DESKTOP-PF01IEE)-[~]
└─$ df -T | awk 'NR==2 {printf $2}'
ext4

This shows how flexible Linux is, you can get almost any information you desire from your Linux machine.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.