DEV Community

Cover image for πŸš€ File Descriptors in Linux β€” The Underrated Heroes of I/O
Ayoub Lahmami
Ayoub Lahmami

Posted on

πŸš€ File Descriptors in Linux β€” The Underrated Heroes of I/O

Most programs you use or write rely on File Descriptors (FDs) β€” even if you never think about them.
If a process reads input, writes output, opens a file, or sends data over a socket, it’s using FDs behind the scenes.

πŸ” What Exactly Is an FD?

A File Descriptor is simply a small integer the kernel gives to a process.
It’s not the file itself β€” it’s a handle the kernel uses to manage any I/O resource.

πŸ’‘ Why They’re So Important

Unified interface: files, pipes, sockets β€” all use open(), read(), write(), close().

Process isolation: each process has its own FD table.

State tracking: the kernel keeps the read/write offset and mode for each FD, even if multiple processes open the same file.

βš™οΈ Under the Hood

Linux manages I/O through three layers:

Per-Process FD Table β€” what your program sees (0, 1, 2, ...).

Open File Table β€” stores the state of each open resource.

Inode Table β€” contains the actual file metadata on disk.

This architecture is a big reason why Unix-like systems are so flexible, consistent, and developer-friendly.

Top comments (0)