📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Linux Command Line File Descriptors

File Descriptors

4 min read
File descriptor 0 is stdin, 1 is stdout, 2 is stderr. Redirect stderr with 2> and discard it with 2>/dev/null. Use 2>&1 to merge stderr into stdout. This lets you precisely control where output goes.

File Descriptors

# Standard streams
# 0 = stdin, 1 = stdout, 2 = stderr

# Redirect stderr only
command 2> errors.txt

# Redirect both stdout and stderr
command > output.txt 2>&1

# Discard errors
command 2>/dev/null

# Read from file
command < input.txt