Table of Contents
Understanding the Terminal
The terminal is a text-based interface that lets you interact with your Linux system by typing commands instead of (or in addition to) using windows, icons, and buttons.
At a practical level, you need to know:
- How to open a terminal
- What you’re looking at when it opens
- How to type, edit, and run commands
- How to manage multiple terminal sessions
Opening a Terminal
How you open a terminal depends on your desktop environment and distribution, but common methods include:
- Keyboard shortcuts:
- GNOME (e.g. Ubuntu):
Ctrl+Alt+T - Many desktops: Search for “Terminal” in the application menu
- From a run dialog:
Alt+F2then typegnome-terminal,konsole,xfce4-terminal, etc.- From a TTY (text-only console):
- Press
Ctrl+Alt+F3(or F2–F6) to switch to a text console - Press
Ctrl+Alt+F1orCtrl+Alt+F7(varies by distro) to return to the graphical session
You don’t need to memorize all of these; learn one way that works on your system.
The Terminal vs the Shell
These two words are often used together:
- Terminal: The program window that displays text and lets you type (e.g. GNOME Terminal, Konsole, xterm).
- Shell: The program that runs inside the terminal and interprets what you type (e.g.
bash,zsh,fish).
You can think of:
- Terminal = “the screen and keyboard”
- Shell = “the command interpreter”
You can run different shells inside the same terminal program.
Terminal Prompt Basics
When you open a terminal, you usually see something like:
user@hostname:~$Common parts of a prompt:
user— your usernamehostname— the name of the computer~— your current directory (~means your home directory)$— symbol indicating a normal (non-root) user#— symbol indicating the root user (administrator)
The exact look varies by distribution and shell theme, but the last character ($ or #) is especially important: it tells you whether you’re running as a normal user or root.
You type your commands after the prompt and press Enter to run them.
Basic Command Workflow
The general workflow in a terminal is:
- Terminal shows a prompt.
- You type a command line.
- The shell interprets it and runs the command program.
- The command prints output (or errors).
- Control returns to the shell, and you see a new prompt.
You will learn command structure in another chapter; here we focus on how to use the terminal around that structure.
Command Line Editing Essentials
You rarely type a command perfectly first try. The shell provides basic editing features.
Try these inside a terminal (they don’t produce visible characters):
Left Arrow/Right Arrow— move the cursor within the lineHome— jump to the start of the lineEnd— jump to the end of the lineBackspace— delete the character to the left of the cursorCtrl+U— clear from cursor back to the start of the lineCtrl+K— clear from cursor to the end of the lineCtrl+L— clear the screen (similar to runningclear)Ctrl+A— move cursor to start of line (works in most shells)Ctrl+E— move cursor to end of line
These shortcuts work in most Linux shells (especially Bash). They make editing commands much faster than repeatedly pressing Backspace.
Running Commands and Getting Output
A few basic experiments:
- Run a simple built-in command:
echo hello- See your current directory:
pwd- List files:
ls
After each command, you’ll see any output printed, followed by a new prompt.
If a command seems to “do nothing” and returns to a prompt, it likely just completed successfully with no message. Many Unix tools are quiet unless there’s something specific to say.
Interrupting and Stopping Commands
Sometimes a command runs for a long time or gets “stuck.” You can usually interrupt it:
Ctrl+C— send an interrupt signal; most commands will stopCtrl+Z— suspend a foreground process (puts it in the background, stopped)
If Ctrl+C doesn’t work, the program might be ignoring it, or it might be waiting for something else (e.g. network, disk). How to fully manage and kill processes is covered in a later chapter; for now memorize:
Ctrl+C= “Stop what’s running now.”
Clearing and Scrolling
Two common tasks:
- Clear the visible screen:
- Run the command
clear, or - Press
Ctrl+L - Scroll to review earlier output:
- Use your mouse wheel or trackpad scroll
- Use
Shift+PageUp/Shift+PageDownin some terminals
Clearing the screen doesn’t erase history; it just moves the prompt to the top and hides earlier output. You can still scroll back.
Basic Command History
The shell keeps a history of commands you’ve typed, even across sessions.
Simple usage:
↑(Up Arrow) — go to the previous command↓(Down Arrow) — go forward againhistory— show a numbered list of recent commands
You’ll learn more advanced history usage in a dedicated chapter; for now, remember that Up Arrow is the fastest way to rerun or edit previous commands.
Autocomplete Basics
Most shells support tab completion:
- Start typing a command or filename, then press
Tab.
Examples:
- Type
ecthenTab: - Shell will complete to
echo(if it’s unique). - Type
cd DocthenTab: - May complete to
cd Documents/if that directory exists.
If there are multiple possibilities, pressing Tab twice often shows a list of options.
This dramatically reduces typing and typos; get into the habit of pressing Tab often.
Exit and Close Behavior
To leave the shell:
- Type
exitand pressEnter, or - Press
Ctrl+Don an empty prompt (end-of-file signal)
What happens next:
- In a graphical terminal window:
- Closing the shell usually closes the terminal window.
- In a text console (TTY):
- Exiting the shell may log you out and return you to a login prompt.
If you accidentally close a terminal window while a command is running, that command usually stops (unless you’ve explicitly detached it; that’s covered elsewhere).
Multiple Terminals and Tabs
Modern terminal emulators support:
- Multiple tabs in one window
- Multiple windows
Look for:
- Menu entries like “New Tab”, “New Window”
- Keyboard shortcuts (for example, in GNOME Terminal):
Ctrl+Shift+T— new tabCtrl+Shift+N— new windowCtrl+PageUp/Ctrl+PageDown— switch between tabs
Each tab/window runs its own shell session. This is useful to:
- Run one long command in one tab while doing other work in another
- Separate tasks (e.g. editing files vs monitoring logs)
Common Terminal Programs
The exact terminal emulator program may differ:
- GNOME-based desktops:
gnome-terminal - KDE Plasma:
konsole - XFCE:
xfce4-terminal - Lightweight environments:
xterm,lxterminal,mate-terminal, etc.
You can usually find which one you’re using via the window title or from the “About” menu. For everyday use, you can just think of all of them as “the terminal.”
Text-Only Consoles (Virtual Terminals/TTYS)
Linux systems also provide virtual consoles (text-only login screens) independent of the graphical desktop.
- Access them with
Ctrl+Alt+F2throughCtrl+Alt+F6(varies). - Log in with your username and password.
- You will see a shell prompt without any graphical environment.
- Return to the graphical desktop:
Ctrl+Alt+F1orCtrl+Alt+F7(depends on distro).
These are useful if:
- Your graphical session freezes
- You want a clean environment separate from your desktop
From a learning perspective, they behave just like a terminal window, but full-screen and purely text.
Basic Safety Tips in the Terminal
As you get comfortable, keep these simple rules in mind:
- If you don’t understand a command, don’t run it, especially if:
- It uses
sudo - It includes
rm,dd,mkfs, or>redirections - Always read what you type before pressing
Enter. - Prefer copying commands from trustworthy sources (documentation, manuals) and understanding each part before running them.
You’ll learn more about sudo, permissions, and system commands later, but these habits help avoid accidental damage while practicing in the terminal.
This chapter focused on the environment where you type commands: the terminal and basic shell interaction. Other chapters in this part will build on this by explaining shell types, command structure, getting help, and using history and completion more effectively.