1. Interactive Shell
- Shell where you directly type commands and receive output.
- Used when working manually in the terminal.
Example:
Loading...Check:
Loading...- If output contains
i→ Interactive shell
2. Non-Interactive Shell
- Shell that runs commands without direct user interaction.
- Commonly used for scripts, cron jobs, automation, etc.
Example:
Loading...Check:
Loading...- If output does not contain
i→ Non-interactive shell
3. Interactive Login Shell
- Interactive shell started as a login session.
- Example:
Loading...4. Non-Interactive Login Shell
- Rare in normal usage.
- A shell can be non-interactive but still have the login attribute.
5. Check if Shell is Interactive
Loading...Key Difference
Interactive | Non-Interactive |
User types commands | Commands come from script/automation |
Used in terminal | Used in scripts/cron |
Provides interactive prompt | Usually no prompt |
i present in $- | i absent from $- |
Easy way to remember:
Interactive = You type the commands.
Non-interactive = Something else provides the commands.
.jpg?table=block&id=29d76b1d-f1a8-8072-a9bf-cc78d1c7d881&cache=v2)