$linuxjunkies
>

file descriptor

also: FD, file handle

A non-negative integer that represents an open file or I/O resource in a process. It acts as a reference handle that the kernel uses to track and manage access to files, sockets, pipes, and devices.

A file descriptor (FD) is an abstract indicator maintained by the kernel for each process to identify open files and I/O streams. When a process opens a file, the kernel returns a file descriptor number that the process uses in subsequent system calls to read, write, or close that file.

By convention, every process starts with three standard file descriptors: 0 for standard input (stdin), 1 for standard output (stdout), and 2 for standard error (stderr). Additional files opened by the process receive descriptors 3, 4, and so on.

File descriptors are not file paths—they're ephemeral references that exist only while the process runs. For example, a shell command like cat myfile.txt > output.txt internally opens myfile.txt (getting FD 3) and output.txt (getting FD 4), then redirects stdout to FD 4. You can inspect a process's file descriptors in /proc/[pid]/fd/.

Related terms