The Terminal & the Shell
The command line is where you will spend this whole course. It looks plain: a blinking cursor after a short line of text. But behind it are two separate programs working together, and knowing which one does what will save you a lot of confusion.
In this lesson you will learn the difference between the terminal and the shell, how to read the prompt, how every command is built, and how to get help without leaving the keyboard.
Terminal, shell and prompt
The terminal (or terminal emulator) is the window: it shows text and sends your key presses onward. On the Ubuntu 26.04 desktop the default terminal app is Ptyxis (it replaced GNOME Terminal); on Windows you use Windows Terminal for WSL; on a server you reach the terminal through SSH.
The shell is the program running inside the terminal. It reads the line you type, works out what you mean, runs the right program and shows you the result. The default shell on Ubuntu, Debian and most servers is Bash (the Bourne Again SHell), and this course teaches Bash 5.3, the version in Ubuntu 26.04. Other shells exist: zsh is the default on macOS and Kali Linux, and fish is popular for its friendly suggestions. Most everyday commands work the same in all of them.
When the shell is ready for a command, it prints a prompt. On Ubuntu it looks like this:
priya@laptop:~$| Part | Meaning |
|---|---|
priya | The user you are logged in as |
laptop | The computer's name (the hostname) |
~ | The current folder; ~ is short for your home folder |
$ | You are a normal user. A # means you are root, the all-powerful administrator |
In this course, code blocks show only the command, without the prompt, so you can copy them easily. Output appears in a separate block below.
You can ask which shell you are using:
echo $SHELL
bash --version | head -n 1/bin/bash GNU bash, version 5.3.0(1)-release (x86_64-pc-linux-gnu)
The shape of a command
Almost every command follows the same pattern:
command -options arguments- The command is the program to run, such as
ls(list files). - Options (also called flags) change how it behaves. Short options are one letter after one dash (
-l); long options are words after two dashes (--all). Short options can be combined:-l -a -his the same as-lah. - Arguments tell the command what to work on, usually file or folder names.
ls
ls -l
ls -la /etc/ssh
ls --all --human-readable -l DocumentsThe first line lists the current folder. The second adds details (permissions, size, date). The third lists a different folder, including hidden files. The fourth mixes long options with a short one; spacing between parts matters, but the order of options usually does not.
Getting help
You will never memorise every option, and nobody expects you to. Linux has help built in:
man lsopens the manual page forls. Scroll with the arrow keys or Space, search with/word, and pressqto quit.ls --helpprints a shorter summary straight into the terminal. Most commands support it.help cdexplains Bash's builtins, commands that are part of the shell itself and have no separate program or man page of their own.typetells you what kind of command a word is.
type cd
type ls
type man
help pwd | head -n 2cd is a shell builtin
ls is aliased to `ls --color=auto'
man is /usr/bin/man
pwd: pwd [-LP]
Print the name of the current working directory.cd is built into Bash. ls is an alias, a short name that expands to a longer command (here it adds colours); Ubuntu sets it up for you. man is a normal program stored in the file /usr/bin/man. If you are not sure what to search for, apropos copy lists every man page whose description mentions "copy".
Keyboard shortcuts that save hours
Learn these early; they work in Bash on every Linux system:
| Keys | What it does |
|---|---|
Tab | Complete a command or file name; press twice to see all choices |
Up / Down | Step through previous commands |
Ctrl+R | Search your command history as you type |
Ctrl+C | Stop the running command |
Ctrl+L | Clear the screen (same as the clear command) |
Ctrl+A / Ctrl+E | Jump to the start / end of the line |
Ctrl+D | End input; at an empty prompt it closes the shell |
Ctrl+Shift+C / Ctrl+Shift+V | Copy / paste in most Linux terminals |
Tab completion is the most important habit. Type cd Doc and press Tab, and Bash fills in Documents/. It is faster and it prevents typing mistakes.
Command history
Bash remembers what you type. history lists past commands with numbers, and a few shortcuts reuse them:
history | tail -n 3
!!
sudo !!498 cd projects 499 ls -la 500 history | tail -n 3
!! repeats the last command. sudo !! repeats it with sudo in front, which is handy when you get "Permission denied" because you forgot sudo. History is saved in the file ~/.bash_history when the shell exits.
Common mistakes
- Missing spaces.
ls-lis read as one unknown command. Put a space between the command, each option and each argument. - Pasting with
Ctrl+V. In a Linux terminalCtrl+Vdoes something else; useCtrl+Shift+Vor right-click, Paste. - Panicking inside
manorless. You are in a viewer, not stuck. Pressq. - Working as root by habit. A
#prompt means every typo has full power over the system. Use a normal user andsudofor single commands.
Key points
- The terminal is the window; the shell (Bash on Ubuntu) reads and runs your commands.
- The prompt shows user, hostname and current folder;
$is a normal user and#is root. - Commands follow the pattern
command -options arguments, and everything is case-sensitive. - Use
man,--help,helpandtypeto learn about any command. - Tab completion, the Up arrow,
Ctrl+RandCtrl+Care the shortcuts you will use most.
Exercise
Open a terminal and find out: which shell you are using, whether echo and history are builtins or separate programs, and what the -h option of df does (use the man page or --help). Finally, use Ctrl+R to find and re-run your echo $SHELL command without retyping it.
Show solution
echo $SHELL
type echo history
man df
df -h //bin/bash echo is a shell builtin history is a shell builtin Filesystem Size Used Avail Use% Mounted on /dev/sda2 25G 6.1G 18G 26% /
Both echo and history are Bash builtins. The man page explains that -h means "human-readable": df shows sizes such as 25G instead of long block counts. To re-run the first command, press Ctrl+R, type SHELL, and press Enter when the match appears.
Quick Quiz
1. What does the shell do?
The terminal is the window; the shell interprets your commands.
2. In the prompt root@server:/etc#, what does the # tell you?
A # prompt means the root user; a normal user sees $.
3. Which pair of commands is the same?
Short options can be combined after one dash, but case always matters.
4. How do you leave a man page?
Man pages open in a pager, and q quits it.
Learn Linux with a mentor
Free lessons get you started. Our Ethical Hacking & Cyber Security training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
