# Did It Work? Exit Codes, && and ||

Every command ends with an exit code, 0 when it worked and another number when it didn't, which $? shows; && runs the next command only if the last one worked, || only if it failed, and ; either way.

![Cheat sheet for the lesson Did It Work? Exit Codes, && and ||: Every command ends with an exit code, 0 when it worked and another number when it didn't, which $? shows; && runs the next command only if the last one worked, || only if it failed, and ; either way.](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/921e1cf850bc494c96403b7177b85864.webp)

- Category: Bash
- Level: Apprentice
- Tags: command-chaining, exit-code, linux, unix
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/bash-exit-codes-cheat-sheet
