Skip to Content
This project is a work in progress. If you have any questions or suggestions, feel free to contact me.

Getting Detailed Metadata

The stat command provides complete metadata including access, modify, change times, and inode.

Syntax:

stat [filename]

Example

$ stat myfile.txt

Output:

File: myfile.txt Size: 1024 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 131080 Links: 1 Access: 2025-07-22 10:12:05.000000000 +0530 Modify: 2025-07-22 10:10:01.000000000 +0530 Change: 2025-07-22 10:11:00.000000000 +0530 Birth: -

Explanation:

FieldMeaning
SizeFile size in bytes
BlocksNumber of 512-byte blocks allocated
IO BlockOptimal block size for I/O
DeviceDevice ID of filesystem
InodeInode number
LinksNumber of hard links
AccessLast time file was read
ModifyLast time file was content-modified
ChangeLast time metadata (permissions, ownership) was changed

Determining File Type Using file Command

The file command is used to identify the type of a file by examining its content, not its extension.

Syntax

file [filename]

Example

$ file myfile.txt

Output:

myfile.txt: ASCII text

Examples

$ file /bin/ls /bin/ls: ELF 64-bit LSB executable, x86-64, dynamically linked, ... $ file image.png image.png: PNG image data, 800 x 600, 8-bit/color RGB, non-interlaced

Explanation:

  • Text files show as ASCII text, UTF-8 Unicode text, etc.
  • Executables show ELF format, architecture.
  • Images display format (e.g., PNG, JPEG), dimensions, encoding.

Using ls -i to See Inode Number

Inodes store all metadata (except filename and content). To view the inode:

$ ls -i myfile.txt 131080 myfile.txt
  • 131080 is the inode number — useful when tracking hard links.

Summary Table

CommandPurposeExample
ls -lList metadata like permissions, sizels -l file.txt
statDetailed metadata including timestampsstat file.txt
fileDetermine file typefile file.txt
ls -iShow inode numberls -i file.txt
Last updated on