stdin / stdout / stderr
Cheat sheet · https://pcornel.dk/topic.php?topic=2686
Answer
Every process starts with three file descriptors: 0 stdin (input), 1 stdout (normal output) and 2 stderr (errors and diagnostics). By default all three are the terminal.
Remember
Programs should write data to stdout and messages to stderr, so pipes and redirects keep them apart. /dev/null discards output. ls -l /proc/<pid>/fd shows where a running process's descriptors point.
First checks
bash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
Commands
journalctl -u
Verify in this order
process inherits fd 0, 1, 2 → shell redirections change them → program reads 0 and writes 1 and 2
Where it usually breaks
First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2686