In the past, I learned that in Linux/UNIX file systems, directories are just files, which contain the filenames and inode numbers of the files inside the directory.
Is there a simple way to see the content of a directory? I mean the way the files names and inodes are stored/organized.
I'm not looking for ls
, find
or something similiar. I also don't want to see the content of the files inside a directory. I want to see the implementation of the directories. If every directory is just a text file with some content, maybe a simple way exists to see the content of this text file.
In the bash in Linux it is not possible to do a cat folder
. The output is just Is a directory
.
Update The question How does one inspect the directory structure information of a unix/linux file? addresses the same issue but it has no helpful solution like the one from mjturner.
Best Answer
The tool to display inode detail for a filesystem will be filesystem specific. For the
ext2
,ext3
,ext4
filesystems (the most common Linux filesystems), you can usedebugfs
, for XFSxfs_db
, for ZFSzdb
. Forbtrfs
some information is available using thebtrfs
command.For example, to explore a directory on an
ext4
filesystem (in this case/
isdev/sda1
):In the above, we start by finding the inode of directory
src
(664488
) and then dump its contents into filesrc.out
and then display that usingod
. As you can see, the contents of all of the files in that directory (Animation.js
, etc.) are visible in the dump.This is just a start - see the
debugfs
manual page or typehelp
withindebugfs
for more information.If you're using
ext4
, you can find more information about the structure and layout of directory entries in the kernel documentation.