|

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:

  1. Takes the commands you type
  2. Interprets them (parses the syntax)
  3. Forwards them to the Operating System
  4. Returns the output to your terminal

Almost all Linux distributions come with a shell called bash.

ShellFull NameNotes
bashBourne Again SHellDefault on most Linux systems
zshZ ShellPopular alternative, macOS default
fishFriendly Interactive ShellUser-friendly, modern
shBourne ShellOriginal 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 EnvironmentTerminal Emulator
KDEkonsole
GNOMEgnome-terminal
Cinnamongnome-terminal
XFCExfce4-terminal
LXDElxterminal
i3 / Minimalxterm, 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:

PartMeaning
kronosThe username (who you are)
@Separator
olymposThe 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:

KeyAction
/ Move cursor left / right within the current line
/ Go back / forward through command history
Ctrl + AMove to beginning of line
Ctrl + EMove to end of line
Ctrl + UDelete from cursor to beginning of line
Ctrl + KDelete from cursor to end of line
Ctrl + WDelete the word before the cursor
Ctrl + LClear the screen
TabAuto-complete commands and filenames
Ctrl + CCancel the current command
Ctrl + DExit the shell (same as exit)

Command History

The shell remembers the commands you’ve typed. You can use:

ShortcutAction
Previous command
Next command
!!Repeat the last command
!nRepeat command number n
!stringRepeat the last command starting with string
historyShow 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

CommandDescriptionExample
dateShow current date/timedate
calShow calendarcal 2024
exitClose the shellexit
historyShow command historyhistory

Prompt Breakdown

kronos@olympos:~$
  │      │      ││
  │      │      │└── Prompt symbol ($ = user, # = root)
  │      │      └─── Current directory (~ = home)
  │      └────────── Hostname (machine name)
  └───────────────── Username

Keyboard Shortcuts

KeyAction
/ Move cursor
/ Navigate history
TabAuto-complete
Ctrl + CCancel command
Ctrl + LClear screen
Ctrl + ABeginning of line
Ctrl + EEnd of line
Ctrl + UDelete to start
Ctrl + KDelete to end
Ctrl + DExit 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

ConceptDescription
Command LineText-based interface
ShellInterprets commands (bash is most common)
Terminal EmulatorThe window/program that runs the shell
Promptuser@host:directory$
HistoryCommands 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!