Yes, there is: it's called ls
…
The size reported by ls
for a directory is the size of the directory contents. It isn't metadata of the directory, it's metadata of the files in the directory. Most of that is listed with ls -la
.
On some Unix variants, you can display the binary form of that data by calling cat
(or od
, etc.) on the directory. This is not the case on Linux, and on systems where it's possible, the interpretation of that data may depend on the filesystem type or may be normalized (to be compatible with historical filesystem types). See When did directories stop being readable as files? and octal dump of directory
The size reported by ls
is more than what it takes to store the data you see with ls
for several reasons:
- There may be metadata that
ls
doesn't display, such as block lists for the file contents.
- There may be padding, e.g. unused bits here and there, alignment to machine word boundaries, file names stored in fixed-size fields, etc.
- There's metadata to organize the list of file names, e.g. a B-tree or search tree structure.
- Typically files are organized in blocks, and a file uses a whole number of blocks, with the last block being only partially filled unless the file size is exactly a multiple of the block size.
- On some filesystems, such as ext4, directories don't give back unused blocks after they've grown a lot (because they contained a lot of files) then shrunk a lot (because a lot of files were deleted).
If you want to know about things that ls
won't show you, you need to go and look directly at the directory contents. Either run od
or similar on the directory, if your Unix variant allows it, or use a low-level tool such as a hex viewer on the partition or a filesystem debugger such as debugfs
for ext2/ext3/ext4. The information you'll see in this way doesn't qualify as “human-readable” except to the very few people who are intimately familiar with the filesystem format.
ls
? That would depend on the type of file-system, and likely only used for debugging purposes by developers of device-drivers, etc. – Thomas Dickey Jun 22 '16 at 22:59