What is I/O redirection in Linux?

Answer

Redirection changes the source or destination of standard streams. command > file redirects stdout to a file (overwrites). command >> file appends stdout to a file. command < file redirects a file to stdin. command 2> error.log redirects stderr (FD 2) to a file. command > all.log 2>&1 redirects both stdout and stderr to the same file (2>&1 merges stderr into stdout). command &> file is shorthand for the above in bash. command 2>/dev/null discards errors. /dev/null is the null device — anything written to it is discarded.