4

Each file has an inode. Is there an inode for every directory ? If not, how does Linux manage directories.

2 Answers 2

11

Directories are special files, hence they have inodes.

You can test that with ls:

ls -li

or using stat:

stat -c '%F : %i : %n' *

Example:

% stat -c '%F : %i : %n' *
regular file : 670637 : bar.csv
regular file : 656301 : file.txt
directory : 729178 : foobar

The number in the middle is the inode number.

4
  • 5
    It's Unix(like) - Everything is a file! - en.wikipedia.org/wiki/Everything_is_a_file Commented Jan 13, 2016 at 11:32
  • ls -lid maybe?
    – Jeff Schaller
    Commented Jan 13, 2016 at 12:12
  • @JeffSchaller Yeah..mentioned that already (just not with -d)..
    – heemayl
    Commented Jan 13, 2016 at 13:01
  • 1
    Most filesystems do implement directories using a special file for each directory (and thus, an inode), but some don't; HFS+ puts the entire name hierarchy in one big B-tree, for instance.
    – zwol
    Commented Jan 13, 2016 at 18:18
2

Yes, it is.
Use stat *directory name* in order to obtain inode number

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .