What is a file descriptor? What are 0, 1 and 2?
BeginnerConceptProcesses, Signals & systemd
Answer
A file descriptor is an integer index into a process's table of open files, sockets and pipes. 0 is stdin, 1 is stdout, 2 is stderr. New opens get the lowest free number.
cmd > out.log 2>&1 # both streams to file
cmd 2>/dev/null # drop errors
cmd &> out.log # bash shorthand
Order matters: 2>&1 > file sends stderr to the terminal.
More on Processes, Signals & systemd
What is the difference between a program, a process and a thread?BeginnerHow are new processes created in Linux?IntermediateWhat is a zombie process, and how do you get rid of it?IntermediateWhat is an orphan process?BeginnerExplain the process states shown in ps (R, S, D, T, Z).IntermediateWhy can't you kill a process in D state?Advanced