Course contentsShow
← Computer Science
Lesson 1388 of 2,87232. File SystemsFree lesson

File Attributes and Metadata

Explore file metadata including size, timestamps, permissions, ownership, and how to query them.

File Attributes and Metadata

What you'll learn: You'll discover what information the operating system tracks about each file beyond just its contents, and how to retrieve that data.

What is File Metadata?

When you create a file, the operating system doesn't just store the data you write—it also maintains a collection of metadata (data about the data). Think of it like a library card catalog: the book itself is the file content, but the catalog card contains details like the author, publication date, and shelf location.

File metadata answers questions like: Who owns this file? When was it last modified? How big is it? Who can read or write it?

Common File Attributes

Most operating systems track these key attributes:

  • Size: The number of bytes the file occupies
  • Timestamps: Creation time, last modification time, last access time
  • Ownership: User ID and group ID of the file's owner
  • Permissions: Read, write, and execute permissions for owner/group/others
  • File type: Regular file, directory, symbolic link, etc.
  • Link count: How many directory entries point to this file

Querying Metadata

You interact with file metadata through system calls. For example, using a file descriptor obtained earlier, you can request the operating system to fill a structure with all the file's attributes. This operation is fast because the metadata is stored separately from the file content itself—usually in an inode or similar structure on disk.

The OS maintains this information in the file table and updates it automatically when you modify files (e.g., updating the modification timestamp when you write).

Key Takeaway: File metadata is the operating system's bookkeeping about files—storing ownership, timestamps, size, and permissions separately from content—and can be queried efficiently through system calls to make informed decisions about file operations.