# Command Line Interface (CLI)
A Command Line Interface (CLI) is a text-based interface where users interact with software by typing commands. The program processes the command and returns text output. CLIs are the oldest and most fundamental way to interact with computers.
Despite graphical interfaces dominating consumer software, CLIs remain essential for developers, system administrators, and power users. They offer precision, automation capabilities, and efficiency that GUIs often lack.
## Key Characteristics
- **Text input/output**: Commands typed, results printed as text
- **Scriptable**: Commands can be combined and automated
- **Precise control**: Fine-grained options via flags and arguments
- **Low overhead**: Minimal resource usage
- **Remote-friendly**: Works over SSH and in headless environments
## Anatomy of a CLI Command
```
command [subcommand] [options/flags] [arguments]
```
Example: `git commit -m "Initial commit"`
- `git`: The program
- `commit`: Subcommand
- `-m`: Flag/option
- `"Initial commit"`: Argument
## Common Patterns
- **Flags**: `-v` (short), `--verbose` (long)
- **Arguments**: Positional values the command operates on
- **Piping**: `command1 | command2` chains output to input
- **Redirection**: `>` writes output to file, `<` reads input from file
- **Environment variables**: Configuration via `$VAR_NAME`
## CLI vs TUI vs GUI
| Aspect | CLI | [[Terminal User Interface (TUI)]] | GUI |
|--------|-----|-----|-----|
| Input | Text commands | Keyboard navigation | Mouse + keyboard |
| Output | Text stream | Interactive text display | Graphics |
| Automation | Excellent | Limited | Poor |
| Learning curve | Steeper | Moderate | Gentle |
| Resource usage | Minimal | Low | Higher |
## Popular CLI Tools
- **[[Git]]**: Version control
- **curl/wget**: HTTP requests
- **grep/ripgrep**: Text search
- **jq**: JSON processing
- **ffmpeg**: Media processing
## References
- https://en.wikipedia.org/wiki/Command-line_interface
## Related
- [[Terminal User Interface (TUI)]]
- [[Graphical User Interface (GUI)]]
- [[Shell]]
- [[Bash]]
- [[Zsh (Z Shell)]]
- [[Git Bash]]
- [[jq]]