TExcelTAD
Home › Terminal & Command Line › The Terminal on Linux

The Terminal on Linux

On Linux the terminal isn't an extra: it is the native way to manage the system. Servers usually have no graphical interface at all, and even on a desktop, installing software, reading logs and fixing problems are often fastest from the command line. The good news: the commands are almost the same on every distribution, because they share the Linux kernel, the GNU tools and, usually, the bash shell.

This lesson is the orientation tour. The Linux & Bash course teaches each command and bash scripting in depth.

Distributions

A distribution (distro) is the Linux kernel plus a package manager, a default desktop and a selection of software. The shell commands in this course work on all of them; what differs most is how you install software.

Family Popular distros Package manager Package format
Debian Ubuntu, Debian, Linux Mint, Pop!_OS apt .deb
Red Hat Fedora, RHEL, Rocky Linux, AlmaLinux dnf .rpm
Arch Arch Linux, Manjaro, EndeavourOS pacman .pkg.tar.zst
SUSE openSUSE, SLES zypper .rpm
Alpine Alpine (common in Docker images) apk .apk

Scripts find out which distro they run on by reading /etc/os-release, a file of KEY=value lines that is written in shell syntax on purpose, so it can be loaded with . (source). Here is a sample from an Ubuntu system:

bash · try it yourself
cat > os-release << 'EOF'
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
ID=ubuntu
ID_LIKE=debian
EOF
. ./os-release
echo "Running on $PRETTY_NAME (id=$ID, family=$ID_LIKE)"
case "$ID $ID_LIKE" in
  *debian*) echo "install with: sudo apt install <package>" ;;
  *fedora*|*rhel*) echo "install with: sudo dnf install <package>" ;;
  *arch*) echo "install with: sudo pacman -S <package>" ;;
esac
Running on Ubuntu 24.04.3 LTS (id=ubuntu, family=debian)
install with: sudo apt install <package>

On a real system, . /etc/os-release does the same, and uname -s prints Linux everywhere.

Terminal emulators

Desktop / app Terminal Open it with
GNOME (Ubuntu, Fedora) Ptyxis (Ubuntu 25.10+, Fedora 41+) or GNOME Terminal / Console Ctrl+Alt+T
KDE Plasma Konsole Ctrl+Alt+T or the app menu
Xfce xfce4-terminal app menu
any Alacritty, kitty, WezTerm, Ghostty, Tilix install separately
no desktop the virtual consoles Ctrl+Alt+F3…F6 (back: usually F1 or F2)

Copy and paste inside Linux terminals use Ctrl+Shift+C / Ctrl+Shift+V, because Ctrl+C stops the running program. Selecting text with the mouse and middle-clicking also pastes it.

Your shell and prompt

Almost every distro's default shell is bash. The prompt ada@ubuntu:~$ shows user, host and folder (~ is your home, /home/ada), and the $ turns into # when you are root.

bash · try it yourself
echo "I am $(whoami), my shell is $(basename "$BASH")"
echo "kernel family: $(uname -s)"
cd /etc && pwd
cd ~ && pwd
type cd ls
I am learner, my shell is bash
kernel family: Linux
/etc
/home/learner
cd is a shell builtin
ls is /bin/ls

type tells you whether a name is a shell builtin (cd), an alias, a function or a program on disk (ls). To switch your login shell to zsh or fish, install it and run chsh -s /usr/bin/zsh.

sudo: acting as administrator

Normal users can't change system files or install software. sudo runs one command as root after asking for your own password (not root's), and only if you belong to the admin group (sudo on Ubuntu/Debian, wheel on Fedora/Arch).

bash
ada@ubuntu:~$ apt install htop
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock, are you root?
ada@ubuntu:~$ sudo apt install htop
[sudo] password for ada:
Reading package lists... Done
...
ada@ubuntu:~$ sudo -i            # a root shell; the prompt ends in #
root@ubuntu:~# exit

Nothing appears while you type the password, not even asterisks; that is normal. sudo remembers it for a few minutes. Use it only for the commands that need it, never "just in case" for everything. Admin Rights & Permissions compares it with Windows UAC.

Installing software

Task Ubuntu / Debian Fedora Arch
Refresh the package list sudo apt update (automatic) sudo pacman -Sy
Install sudo apt install git sudo dnf install git sudo pacman -S git
Remove sudo apt remove git sudo dnf remove git sudo pacman -R git
Upgrade everything sudo apt upgrade sudo dnf upgrade sudo pacman -Syu
Search apt search editor dnf search editor pacman -Ss editor

Distro-independent options are Flatpak and Snap for desktop apps. See Package Managers.

Getting help on Linux

Command Shows
man ls the full manual page (/ searches, q quits)
ls --help a short summary of options (GNU tools)
help cd help for bash builtins
apropos copy / man -k copy manual pages whose description mentions "copy"
tldr tar community examples (install the tldr package)
bash
ada@ubuntu:~$ man -k "copy files"
cp (1)               - copy files and directories
cpio (1)             - copy files to and from archives
install (1)          - copy files and set attributes

Builtins have their own help inside bash:

bash · try it yourself
help pwd | head -n 3
pwd: pwd [-LP]
    Print the name of the current working directory.

Where things live

Path Contains
/home/ada (~) your files and dotfiles (.bashrc)
/etc system configuration (text files)
/usr/bin installed programs
/var/log logs (also journalctl on systemd systems)
/tmp temporary files, cleared at reboot
/mnt, /media mounted drives and USB sticks

The Linux Directory Tree lesson explains the full layout.

Learn more: Linux & Bash course, WSL: Linux on Windows, Linux Packages.

Test yourself

Which package manager do Ubuntu and Debian use?

  1. dnf
  2. pacman
  3. apt
  4. brew

Whose password does sudo ask for on Ubuntu?

  1. root's
  2. your own
  3. none
  4. the computer's BIOS password

How do you copy selected text in most Linux terminal apps?

  1. Ctrl+C
  2. Ctrl+Shift+C
  3. Cmd+C
  4. Alt+C