The Terminal & the Shell

Linux · Lesson 3 of 32 7 min read Updated

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:

Text
priya@laptop:~$
PartMeaning
priyaThe user you are logged in as
laptopThe 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:

Terminal
echo $SHELL
bash --version | head -n 1
Output
/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:

Text
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 -h is the same as -lah.
  • Arguments tell the command what to work on, usually file or folder names.
Terminal
ls
ls -l
ls -la /etc/ssh
ls --all --human-readable -l Documents

The 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 ls opens the manual page for ls. Scroll with the arrow keys or Space, search with /word, and press q to quit.
  • ls --help prints a shorter summary straight into the terminal. Most commands support it.
  • help cd explains Bash's builtins, commands that are part of the shell itself and have no separate program or man page of their own.
  • type tells you what kind of command a word is.
Terminal
type cd
type ls
type man
help pwd | head -n 2
Output
cd 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:

KeysWhat it does
TabComplete a command or file name; press twice to see all choices
Up / DownStep through previous commands
Ctrl+RSearch your command history as you type
Ctrl+CStop the running command
Ctrl+LClear the screen (same as the clear command)
Ctrl+A / Ctrl+EJump to the start / end of the line
Ctrl+DEnd input; at an empty prompt it closes the shell
Ctrl+Shift+C / Ctrl+Shift+VCopy / 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:

Terminal
history | tail -n 3
!!
sudo !!
Output
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-l is read as one unknown command. Put a space between the command, each option and each argument.
  • Pasting with Ctrl+V. In a Linux terminal Ctrl+V does something else; use Ctrl+Shift+V or right-click, Paste.
  • Panicking inside man or less. You are in a viewer, not stuck. Press q.
  • Working as root by habit. A # prompt means every typo has full power over the system. Use a normal user and sudo for 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, help and type to learn about any command.
  • Tab completion, the Up arrow, Ctrl+R and Ctrl+C are 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
Terminal
echo $SHELL
type echo history
man df
df -h /
Output
/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?

2. In the prompt root@server:/etc#, what does the # tell you?

3. Which pair of commands is the same?

4. How do you leave a man page?

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