How do you redirect standard error (stderr) to a file?
Use 2> — the 2 names stderr (FD 2), so cmd 2> errors.txt captures only error messages.
cat myfile.txt 2> errors.txt # if myfile.txt is missing...
cat errors.txt
cat: myfile.txt: No such file or directory
The leading 2 is the whole point: it tells the shell which stream to redirect. Without a number, > would grab stdout (FD 1) and leave the error on screen. With 2>, the reverse happens — the error goes to the file and any normal output still flows to the terminal.
Why split them out? Capturing just the errors lets you review failures after a long-running job without sifting through tons of normal output. Conversely, 2> /dev/null silences errors entirely (handy for find / flooding you with "Permission denied").
2>overwrites the error file each run.2>>appends, so a growing error log survives across runs.
Tip: The number hugs the operator with no space: it's 2>, never 2 > (which would be the argument 2 plus a plain stdout redirect).