What is the exit status of a command?

Answer

Every command returns an exit status (return code) between 0 and 255. 0 indicates success; non-zero indicates failure. The exit status of the last command is stored in $?. Common conventions: 1 = general error, 2 = misuse of shell builtin, 126 = command not executable, 127 = command not found, 128+N = killed by signal N (e.g., 130 = Ctrl+C which is SIGINT = signal 2, so 128+2=130). Scripts can return a custom exit code with exit N. Functions return status with return N. Always check exit statuses in production scripts. Tools like grep return 0 if match found, 1 if no match, 2 on error.