# File Descriptors: Part 1 File descriptors are one of the basic ideas you need to understand before Linux I/O starts to make sense. In Unix-like systems, many I/O endpoints are exposed through a file-like interface: regular files, pipes, sockets, terminals, and devices. A process does not usually operate on these objects directly. It operates through small integer handles called file descriptors. ## What Is a File Descriptor? A file descriptor is a non-negative integer used by a process to refer to an open I/O resource. When a process calls `open`, the kernel creates an entry in that process's file descriptor table and returns the lowest available integer. From that point on, the process can use that integer with calls like `read`, `write`, `dup`, and `close`. ## The Standard File Descriptors Every process normally starts with three important file descriptors: | FD | Name | Meaning | | --- | --- | --- | | `0` | stdin | Standard input | | `1` | stdout | Standard output | | `2` | stderr | Standard error | These are often connected to your terminal, but they can also point to files, pipes, or sockets through shell redirection. ## How Many File Descriptors Can A Process Open? There are limits at multiple levels: - Per-process limit: `ulimit -n` - System-wide limit: `/proc/sys/fs/file-max` These limits matter in production systems. A service that leaks file descriptors can eventually fail to accept connections, write logs, or open files. ## Why File Descriptors Matter File descriptors let the kernel track what a process has opened and how it is allowed to interact with those resources. They are the foundation behind many familiar operations: - Reading from files. - Writing logs. - Accepting network connections. - Redirecting command output. - Connecting processes with pipes. ## Next In [[File Descriptors Part 2]], we look at the process file descriptor table, open file descriptions, dentries, and inodes. ## Related - [[Field Notes/File Descriptor]] - [[Topics/Linux & Systems]] - [[Learning Paths/Linux Internals for Backend Engineers]]