Find a course

Module 1: Getting Started in the TerminalLesson 1 of 139 min

What the Command Line Is and Why It Matters

Understand the difference between the terminal, the shell and the kernel, read a shell prompt, and see why admins and developers still type commands.

Step 1 of 12Learn

Two ways to rename 400 photos

Jordan has 400 vacation photos named IMG_0001.jpg to IMG_0400.jpg and wants each one to start with italy-. In a graphical file manager that means 400 right-clicks, 400 "Rename" menus and 400 chances to make a typo. His coworker Lena does the same job by typing one line into a terminal and pressing Enter. It finishes in under a second.

That gap is why the command line is still everywhere. Most web servers, cloud machines, network devices, routers and even Android phones run Linux, and many of them have no screen or mouse at all. When you connect to them, all you get is a text prompt waiting for a command.

The command line is not harder than clicking; it is different. Instead of looking for a button, you tell the computer exactly what you want in a short sentence. The payoff is speed, precision and the ability to repeat and automate work: a command you typed once can be saved in a script and run every night without you.

By the end of this course you will move around the file system, manage files, search through logs, chain small tools into pipelines, control permissions and processes, and write your first shell script.

Step 2 of 12Learn

Terminal, shell and kernel

Three words get mixed up constantly, so let's separate them.

  • The kernel is the core of the operating system. It talks to the hardware, schedules programs and manages memory and files. You never type to the kernel directly. "Linux" strictly means this kernel.
  • The shell is a program that reads the commands you type, figures out what you mean and asks the kernel to run programs. The most common shell on Linux is Bash (the Bourne Again SHell). macOS now defaults to zsh, which behaves almost identically for everything in this course.
  • The terminal (or terminal emulator) is the window that shows text and sends your keystrokes to the shell. GNOME Terminal, Windows Terminal and the macOS Terminal app are all terminals.

An analogy: the terminal is the phone, the shell is the interpreter on the line, and the kernel is the person who actually does the work. You can swap phones without changing the interpreter, and you can change interpreters (Bash to zsh) without changing the kernel.

Where to practice: a Linux machine, a virtual machine, Windows Subsystem for Linux (WSL) on Windows, the Terminal app on macOS, or a free cloud shell from a major provider. Any of these works for this course.

Step 3 of 12Practice · Diagram

From your keyboard to the hardware

Each layer talks only to its neighbors. Tap a layer to see its job.

Which layer schedules programs and manages memory?

Tap the shape that answers the question, then press Check.

From your keyboard to the hardwareLayer diagram: You, typing, Terminal (the window), Shell (Bash), Kernel, Hardware.You, typingTerminal (the window)Shell (Bash)KernelHardware
You, typing

You type a line of text and press Enter.

Terminal (the window)

Shows text and passes your keystrokes on. GNOME Terminal, Windows Terminal and iTerm2 are terminals.

Shell (Bash)

Reads your line, expands wildcards and variables, finds the program and starts it.

Kernel

The core of the operating system: schedules programs, manages memory, files and devices.

Hardware

CPU, memory, disks and network cards.

Step 4 of 12Practice · Match the pairs

Match each layer to what it does.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. Terminal
  2. Shell
  3. Kernel
  4. Command

Step 5 of 12Learn

Reading the prompt

When a terminal opens you see a prompt, a short line that ends just before your cursor. A typical Bash prompt looks like this:

lena@webserver:~/projects$

It packs four facts into one line:

  • lena is the user you are logged in as.
  • webserver is the hostname, the name of the machine. This matters when you have windows open to five servers and need to know which one you are about to restart.
  • ~/projects is your current directory. The tilde ~ is shorthand for your home directory, so this means /home/lena/projects.
  • $ means you are a regular user. If the prompt ends in #, you are root, the all-powerful administrator account, and every command can change or delete anything on the system.

Prompts can be customized, so yours may look different, but the user, host and directory are almost always there. Get in the habit of glancing at the prompt before you press Enter. Many outages started with someone running the right command on the wrong machine.

In this course, examples show the $ prompt before a command. You type only what comes after it.

Step 6 of 12Diagram

Reading lena@webserver:~/projects$

Four facts in one line. Tap each part.

Reading lena@webserver:~/projects$Parts diagram: lena@webserver:~/projects$, lena, webserver, ~/projects, $.lena@webserver:~/projects$lenawebserver~/projects$

Tap a shape with to see more.

lena@webserver:~/projects$
lena

The user you are logged in as.

webserver

The hostname: which machine you are about to change.

~/projects

The current directory. ~ is your home, so this is /home/lena/projects.

$

$ means a regular user. # means root: be careful.

Step 7 of 12Practice · Fill in the blanks

Fill in the blanks

In the prompt admin@db01:/var/log#, the logged-in user is , the machine is called , and the # at the end means the user is .

Step 8 of 12Compare

Command line vs. graphical interface

AspectCommand lineGraphical interface
Learning curveSteeper at first: you need to know command namesGentle: menus show you the options
Repetitive tasksOne command or script handles 1 or 10,000 filesEach file usually needs its own clicks
Remote serversWorks over a slow SSH connection with no screenOften unavailable or slow on servers
AutomationCommands can be saved in scripts and scheduledHard to record and replay clicks reliably
DiscoverabilityYou must look up options with help pagesOptions are visible on screen

Step 9 of 12Practice · Select all that apply

Which of these are good reasons to learn the Linux command line? Select all that apply.

Select all that apply.

Step 10 of 12Tap to reveal

Linux, distributions and where you will meet them

  1. A distribution

    The Linux kernel alone is not a usable system. A distribution (distro) bundles the kernel with a shell, core tools, a package manager and often a desktop. Ubuntu, Debian, Fedora, Rocky Linux and Arch are popular examples. The commands in this course work on all of them.

  2. Servers and the cloud

    Most web servers and cloud virtual machines run a Linux distribution without any graphical desktop. You connect over SSH and work entirely at the prompt, which is the main reason this skill matters for anyone in IT.

  3. Devices you already own

    Android phones, many home routers, smart TVs and network storage boxes run the Linux kernel. macOS is not Linux, but it is Unix-like, so its Terminal accepts nearly the same commands.

Step 11 of 12Practice · True or false

Bash and the terminal are two names for the same program.

Step 12 of 12Practice · Choose one

Your prompt reads deploy@prod-web-03:~$. What does the ~ tell you?