Linux CLI 1 🐧 Introduction
The command line is a text-based interface for interacting with your computer. Instead of clicking icons, you type commands — and the shell interprets them and passes them to the Operating System.
What is a Shell?
A shell is a program that:
- Takes the commands you type
- Interprets them (parses the syntax)
- Forwards them to the Operating System
- Returns the output to your terminal
Almost all Linux distributions come with a shell called bash.
| Shell | Full Name | Notes |
|---|---|---|
| bash | Bourne Again SHell | Default on most Linux systems |
| zsh | Z Shell | Popular alternative, macOS default |
| fish | Friendly Interactive Shell | User-friendly, modern |
| sh | Bourne Shell | Original Unix shell |
Terminal Emulators
A terminal emulator is a program that helps you interact with the shell. It’s the window where you type commands.
| Desktop Environment | Terminal Emulator |
|---|---|
| KDE | konsole |
| GNOME | gnome-terminal |
| Cinnamon | gnome-terminal |
| XFCE | xfce4-terminal |
| LXDE | lxterminal |
| i3 / Minimal | xterm, alacritty |
Note: The terminal emulator is not the shell — it’s the window that runs the shell. You could run bash inside konsole, gnome-terminal, or any other terminal emulator.
Understanding the Prompt
When you open a terminal, you’ll see a prompt — something like:
kronos@olympos:~$
Let’s break it down:
| Part | Meaning |
|---|---|
kronos | The username (who you are) |
@ | Separator |
olympos | The machine name (hostname) |
: | Separator |
~ | Current directory (~ = home directory) |
$ | Prompt symbol ($ = regular user, # = root) |
Example prompts:
kronos@olympos:~$ ← regular user in home directory
kronos@olympos:/etc$ ← regular user in /etc
root@olympos:/# ← root user
user@laptop:~/Documents$ ← user in ~/Documents
First Commands
Let’s try a few basic commands:
date — Show the Current Date and Time
date
Example output:
Mon Jan 15 10:30:45 UTC 2024
Options:
date +"%Y-%m-%d" # 2024-01-15
date +"%H:%M:%S" # 10:30:45
date -u # UTC time
cal — Show a Calendar
cal
Example output:
January 2024
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Options:
cal 2024 # Full year calendar
cal 12 2024 # December 2024
cal -3 # Previous, current, next month
exit — Close the Shell
exit
Closes the current terminal session or shell.
Navigating the Command Line
The command line has keyboard shortcuts to make editing easier:
| Key | Action |
|---|---|
← / → | Move cursor left / right within the current line |
↑ / ↓ | Go back / forward through command history |
Ctrl + A | Move to beginning of line |
Ctrl + E | Move to end of line |
Ctrl + U | Delete from cursor to beginning of line |
Ctrl + K | Delete from cursor to end of line |
Ctrl + W | Delete the word before the cursor |
Ctrl + L | Clear the screen |
Tab | Auto-complete commands and filenames |
Ctrl + C | Cancel the current command |
Ctrl + D | Exit the shell (same as exit) |
Command History
The shell remembers the commands you’ve typed. You can use:
| Shortcut | Action |
|---|---|
↑ | Previous command |
↓ | Next command |
!! | Repeat the last command |
!n | Repeat command number n |
!string | Repeat the last command starting with string |
history | Show the full history list |
Example:
date
cal
!! # Repeats "cal"
!da # Repeats "date"
history # Shows list of all previous commands
Complete Example Session
Let’s walk through a typical first session:
# 1. Check the current date
kronos@olympos:~$ date
Mon Jan 15 10:30:45 UTC 2024
# 2. View the calendar
kronos@olympos:~$ cal
January 2024
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
# 3. Try the history feature
kronos@olympos:~$ !! # Repeats "cal"
January 2024
...
# 4. Check command history
kronos@olympos:~$ history
1 date
2 cal
3 cal
4 history
# 5. Exit the shell
kronos@olympos:~$ exit
Quick Reference
Basic Commands
| Command | Description | Example |
|---|---|---|
date | Show current date/time | date |
cal | Show calendar | cal 2024 |
exit | Close the shell | exit |
history | Show command history | history |
Prompt Breakdown
kronos@olympos:~$
│ │ ││
│ │ │└── Prompt symbol ($ = user, # = root)
│ │ └─── Current directory (~ = home)
│ └────────── Hostname (machine name)
└───────────────── Username
Keyboard Shortcuts
| Key | Action |
|---|---|
← / → | Move cursor |
↑ / ↓ | Navigate history |
Tab | Auto-complete |
Ctrl + C | Cancel command |
Ctrl + L | Clear screen |
Ctrl + A | Beginning of line |
Ctrl + E | End of line |
Ctrl + U | Delete to start |
Ctrl + K | Delete to end |
Ctrl + D | Exit shell |
Best Practices
✅ Do This:
# Use Tab for auto-completion
kronos@olympos:~$ da[Tab] # Completes to "date"
# Use ↑ to repeat recent commands
kronos@olympos:~$ [↑] # Shows "cal"
# Use history to review commands
kronos@olympos:~$ history | tail -10 # Last 10 commands
# Use Ctrl+L to clear the screen
kronos@olympos:~$ [Ctrl+L]
❌ Don’t Do This:
# Don't type long paths manually when Tab works
kronos@olympos:~$ cd /home/kronos/Documents/projects # Use Tab!
# Don't re-type a command you just ran
kronos@olympos:~$ date
kronos@olympos:~$ date # Use !! instead
# Don't panic if you make a mistake
kronos@olympos:~$ ls -la /nonexistent # Just read the error
Terminal Emulators vs Shells
┌─────────────────────────────────────┐
│ Terminal Emulator (konsole) │ ← The window
│ ┌───────────────────────────────┐ │
│ │ Shell (bash) │ │ ← Interprets commands
│ │ ┌─────────────────────────┐ │ │
│ │ │ Operating System │ │ │ ← Executes
│ │ └─────────────────────────┘ │ │
│ └───────────────────────────────┘ │
└─────────────────────────────────────┘
Key distinction: The terminal emulator is the application window. The shell is the program running inside it that interprets your commands.
Summary
| Concept | Description |
|---|---|
| Command Line | Text-based interface |
| Shell | Interprets commands (bash is most common) |
| Terminal Emulator | The window/program that runs the shell |
| Prompt | user@host:directory$ |
| History | Commands are remembered (↑/↓ to navigate) |
Remember: The shell is your interface to the OS. Type commands, use the arrows to navigate, and don’t be afraid to experiment — Ctrl+C cancels anything!
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!