Inspecting File Types & Metadata (file & stat)
Concept & Overview
In Linux, file extensions (like .txt or .png) are merely hints for humans—the operating system does not rely on them. To identify what a file truly contains, the file command reads the file's binary header (magic bytes) and determines its actual format (ASCII text, ELF executable, gzip archive, etc.).
To inspect deep filesystem metadata beyond what ls -l shows, the stat command displays the file's exact size in bytes, allocated blocks, filesystem inode number, octal access permissions (e.g. 0644), and exact timestamps: Access (atime), Modify (mtime), and Change (ctime).
/home/learner/notes.txt. First run file notes.txt to detect its file format, then run stat notes.txt to view its inode, size, octal permissions, and timestamps.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
file notes.txt | Detect file format and MIME encoding |
stat notes.txt | Display inode, octal permissions, and timestamps |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Run the "file" command on notes.txt
- ○Run the "stat" command on notes.txt
Ready to complete Quest 8?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.