Chapter 2: Command-line essentials

Linux and the shell

Before you type your first command, it helps to know what you are talking to. This lesson explains what Linux and Red Hat Enterprise Linux are, what the shell does, how to read its prompt, and how to log in to another machine and back out again.

What Linux is

Strictly, Linux is a kernel: the program that starts first when a computer boots, and from then on shares out the processor, memory, disks and network between every other program. On its own a kernel can't do anything you would recognise. Add the tools around it (a shell, commands to manage files and users, a package manager, services such as a web server) and you have a complete operating system. People usually call the whole thing Linux.

Linux runs most of the internet's servers, almost every public cloud instance, the world's fastest supercomputers, phones (Android uses the Linux kernel), cars and televisions. If you work in IT, you will meet it.

Open source

Linux and nearly all the tools around it are open source: their source code is published under a licence that lets anyone use the software, study how it works, change it, and share their changes. Some licences (such as the GPL that the kernel uses) also require that anyone who distributes a changed version publishes the change under the same terms, so improvements flow back to everyone.

Open source does not mean "no company involved". Thousands of companies, Red Hat among the largest, employ developers to work on open source projects and sell support, certification and services around them.

Distributions

Nobody installs the kernel and a few thousand separate projects by hand. A distribution collects them, builds them to work together, and ships them with an installer, updates and a package manager. Debian, Ubuntu, Fedora and Red Hat Enterprise Linux are all distributions. They share the same kernel and most of the same tools, so what you learn here mostly carries over; the differences are in packaging, defaults and release schedules.

Where RHEL comes from: New work lands in Fedora first, is shaped in CentOS Stream into the next RHEL minor release, and ships as RHEL. Rebuilds such as Rocky Linux compile the same published RHEL source.

Red Hat Enterprise Linux (RHEL) is the distribution this path teaches. Companies choose it because each major version is supported for ten years, minor releases (9.1, 9.2 …) arrive every six months without breaking things, and it is certified to run a long list of commercial software and hardware. Using it needs a subscription; developers can get one free.

Your practice lab runs Rocky Linux 9, a free rebuild of RHEL 9 from the same published source. Commands, packages, file locations and services are the same, which is exactly why it makes a good practice system.

Terminals, consoles and the shell

You give Linux instructions by typing commands. Three pieces sit between your keyboard and the kernel:

From your keyboard to the kernel: The terminal carries your keystrokes to the shell; the shell runs the programs you name; programs ask the kernel for everything they need.

TermWhat it is
TerminalAnything that shows text output and takes keyboard input: a terminal window on a desktop, an SSH session, or a real screen and keyboard.
ConsoleThe machine's own screen and keyboard (the physical console). Linux gives it several virtual consoles, each an independent login: on a server, press Ctrl+Alt+F2 to F6 to switch between them. A server without a screen offers a serial console instead, reachable over the network in a data centre.
ShellThe program that reads what you type, works out what you mean, runs the right programs and shows you their output. On RHEL it is Bash, the GNU Bourne-Again Shell.
PromptThe text the shell prints when it is ready for your next command.

Most servers have no desktop at all: a graphical environment uses memory and processor time the server's real work could use. You log in over the network, with SSH, and work at a shell prompt. That is how you will work in this path.

Read the prompt

The prompt tells you who you are, where you are and how careful you need to be. Select each part:

The parts of the prompt: Select a part of the prompt to see what it tells you.

The last character matters most. A $ means an ordinary user: you can only change your own files, and a mistake affects only you. A # means you are root, the superuser, who can change anything on the system, including deleting it. When you see #, slow down.

[student@servera ~]$ sudo -i
[sudo] password for student:
[root@servera ~]# whoami
root
[root@servera ~]# exit
logout
[student@servera ~]$

sudo -i starts a root shell after asking for your password; exit leaves it. Chapter 6 explains sudo properly. Until then, you only need to recognise the #.

The shape of a command

Every command line has up to three kinds of part, separated by spaces. Select each part of this example, which prints the first three lines of a file:

The parts of a command: Select each part of the command to see its role.

Not every command needs all three: date on its own is a complete command, and so is whoami.

Log in to another machine with SSH

SSH (Secure Shell) gives you a shell on another computer over the network, with everything you type and see encrypted. The ssh command takes the account and the machine as user@host:

[student@workstation ~]$ ssh student@servera
The authenticity of host 'servera (172.25.250.10)' can't be established.
ED25519 key fingerprint is SHA256:FiQsZBEl3IPrcGlIbHS4VrVteB5aT0PVAD5VNj91+Hk.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'servera' (ED25519) to the list of known hosts.
student@servera's password:
Last login: Sat Oct  3 09:30:04 2026 from 172.25.250.9
[student@servera ~]$

The warning appears the first time you connect to a machine. Every SSH server has a host key that identifies it, and your account keeps a list of the keys it has seen (in ~/.ssh/known_hosts). The first time, there is nothing to compare against, so SSH shows you the key's fingerprint and asks. Answering yes saves it. From then on, SSH checks it silently on every connection, and refuses to connect if the key ever changes. That protects you from a machine on the network pretending to be servera to collect your password.

In your lab, the key you set up in chapter 1 logs you in without a password. That is key-based authentication, which chapter 10 covers in full.

To leave the remote shell, type exit or press Ctrl+D. The prompt shows you are back where you started:

[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$

Check your understanding