Learn / Linux / Getting Started
Lesson 1 of 74

What is Linux?

What an operating system does, what Linux and a "distribution" really are, how the kernel and shell fit together, and why every DevOps engineer works with Linux every day.

15 min read Report a problem Hands-on lab included 5-question quiz

What an operating system does

Your laptop, your phone and a server in a data centre all have the same basic parts: a CPU that runs instructions, memory (RAM) for data being used right now, storage (disks) that keeps files, and a network card. Programs like a web browser, a database or nginx need all of these, but they don't talk to the hardware directly. Imagine every program trying to control the disk at the same time: chaos.

Between the programs and the hardware sits the operating system (OS). It shares the hardware fairly between programs, keeps them from interfering with each other, and gives them simple ways to do complicated things like "save this file" or "send this over the network". Windows, macOS, Android and Linux are all operating systems.

The layers of a computer

Applicationsnginx, MySQL, Python apps, Docker, your scripts
Shell & system toolsbash, ls, cp, systemctl, apt: how you give orders
Linux kernelmanages processes, memory, files, network, devices
HardwareCPU, RAM, disks, network card

Programs never touch the hardware directly. They ask the kernel, and the kernel does it for them.

Linux is a kernel

The heart of an operating system is the kernel: the program that starts first when the machine boots and stays in control until it shuts down. It decides which program gets the CPU and for how long, hands out memory, reads and writes the disks, and sends network traffic.

Linux is a kernel. It was started in 1991 by Linus Torvalds, a Finnish student, as a hobby project, and shared on the internet with its source code. Thousands of developers and companies have worked on it since. Today it is one of the largest open-source projects in the world.

Open source means the source code is public. Anyone can read it, use it for free, change it and share their changes. That's a big reason Linux spread everywhere: companies could adapt it to their needs without paying licence fees or waiting for a vendor.

A kernel alone isn't usable. You also need a shell to type commands into, basic tools to copy files and manage users, and a way to install software. Many of those tools come from the GNU project, which is why you'll sometimes hear "GNU/Linux". In everyday speech, "Linux" means the whole system.

Try it · Task 1 of 4

Which kernel?

Find the version of the Linux kernel running this machine.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

The kernel is the core of Linux: the program that controls the CPU, memory, disks and network, and runs every other program. uname (short for "Unix name") asks the kernel about itself.

1. Ask the kernel who it is

bash
uname
uname -r
uname -a
CommandPrints
unamethe kernel's name
uname -rthe kernel release (its version)
uname -aall of it: name, hostname, version, build, CPU architecture
text
Linux
6.18.44-fc-v819
Linux devopsshack 6.18.44-fc-v819 #1 SMP PREEMPT_DYNAMIC @0 x86_64 x86_64 x86_64 GNU/Linux

Your version may differ. In uname -a: devopsshack is the machine's hostname, 6.18.44-... the kernel version, and x86_64 the CPU architecture (64-bit Intel/AMD; ARM servers show aarch64). Kernel versions matter when software needs a minimum version, or a security advisory names affected kernels.

2 · Your task

Save the kernel release (the output of uname -r) to /root/kernel.txt.

Expected result: cat /root/kernel.txt shows the same version as uname -r.

Hint: the commands, explained
text
uname -r > /root/kernel.txt

What each part does

  • uname -r prints the kernel release (version).
  • > /root/kernel.txt sends that output into a file instead of the screen.
First start the lab machine in the terminal panel on the right.

Distributions: one kernel, many flavours

A distribution (or distro) is the Linux kernel packaged together with everything else you need:

  • the GNU tools and other basic commands,
  • a package manager, to install and update software with one command,
  • an init system (on almost all modern distros: systemd), which starts services at boot,
  • default settings, a release schedule, security updates and documentation.

Every distribution uses the same Linux kernel. That's why what you learn on Ubuntu works on Red Hat, with only small differences, mostly in the package manager.

Distributions you will meet at work

Distributions come in families. Learn one member of each family and you can work on all of them:

FamilyMembersPackage formatInstall software with
DebianDebian, Ubuntu, Linux Mint.debapt install nginx
Red HatRHEL, Rocky Linux, AlmaLinux, Fedora, CentOS Stream, Amazon Linux.rpmdnf install nginx (older: yum)
AlpineAlpine Linux.apkapk add nginx
SUSESUSE Linux Enterprise, openSUSE.rpmzypper install nginx

This course uses Ubuntu, the most common distribution on cloud servers. Whenever a command differs on Red Hat systems, the lesson tells you.

Ubuntu LTS versions (for example 22.04 and 24.04) are Long Term Support releases: they get security updates for at least five years, so they're the ones companies run on servers. The version number is the year and month of release: 24.04 came out in April 2024.

Try it · Task 2 of 4

Which distribution?

Find which Linux distribution and version this server runs.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

The kernel alone isn't a usable system. A distribution (Ubuntu, Debian, Red Hat Enterprise Linux, Amazon Linux...) packages the kernel with tools, a package manager and default settings. Which distribution you're on decides which commands install software (apt or dnf), where config files live and how long you get security updates. Every distribution describes itself in /etc/os-release.

1. Read /etc/os-release

bash
cat /etc/os-release

cat prints a file's contents.

text
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"

(The first lines.)

LineMeaning
PRETTY_NAMEthe human-friendly name
VERSION_IDthe version: 24.04 (released April 2024)
LTSLong Term Support: security updates for 5+ years, which is why servers use LTS releases
VERSION_CODENAMEUbuntu's nickname for this release; you'll see noble in package sources
ID_LIKE=debianUbuntu is built on Debian, so Debian instructions usually work too

2. Just the line you need

bash
grep PRETTY_NAME /etc/os-release

grep prints only the lines that contain a word. You'll learn it properly in Section 2.

text
PRETTY_NAME="Ubuntu 24.04 LTS"
2 · Your task

Save the PRETTY_NAME line of /etc/os-release to /root/distro.txt.

Expected result: /root/distro.txt contains PRETTY_NAME="Ubuntu 24.04 LTS" (or whatever this machine reports).

Hint: the commands, explained
text
grep PRETTY_NAME /etc/os-release > /root/distro.txt

What each part does

  • grep PRETTY_NAME /etc/os-release: print only the line of the file that contains PRETTY_NAME.
  • > saves that line into /root/distro.txt.
First start the lab machine in the terminal panel on the right.

Where Linux runs

You use Linux every day, mostly without knowing it:

WhereWhat runs Linux
Cloudmost virtual machines on AWS, Azure and Google Cloud, and the systems behind their managed services
Containersevery Docker container you run on a server uses the host's Linux kernel, and almost every image is a small Linux distribution
Kubernetesits nodes are Linux machines
Websitesmost web servers, including nginx and Apache
PhonesAndroid is built on the Linux kernel
Supercomputersall of the world's 500 fastest supercomputers run Linux
Devicesrouters, smart TVs, cars, cameras, Raspberry Pi

Why DevOps engineers live in Linux

DevOps is about building, shipping and running software reliably. Almost all of that happens on Linux:

A typical DevOps day, and where Linux is

Codepushed to Git
CI buildruns on a Linux runner
Container imagea small Linux system
ProductionLinux servers and nodes

From the build server to the production cluster, every box runs Linux.

So when a deployment fails, a container crashes or a server runs out of disk space, the fix almost always means opening a terminal on a Linux machine and typing commands. Interviewers know this, which is why Linux questions come up in nearly every DevOps interview.

Kernel, shell and terminal: who does what

Three words that beginners mix up, but that you need to keep apart:

WordWhat it isExample
Kernelthe core of the OS, talks to the hardwareLinux
Shella program that reads your commands and runs thembash (the default on most servers), zsh, sh
Terminalthe window that shows the shell and sends it your keystrokesWindows Terminal, the macOS Terminal, the black box in our labs

Here's what happens when you type ls and press Enter:

What happens when you run a command

1. You typels + Enter in the terminal
2. The shellfinds the program /usr/bin/ls and asks the kernel to start it
3. The kernelstarts ls, which asks it to read the folder from disk
4. Outputthe list of files appears in your terminal

You'll take that apart properly in the next lesson, where you run your first commands.

Try it · Task 3 of 4

Which shell?

Find the program that reads the commands you type.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

You never talk to the kernel directly. You type into a shell, a program that reads your command, finds the program you asked for and asks the kernel to run it. On almost every Linux server the shell is bash. The terminal is just the window that shows the shell's text.

1. Which shell is yours?

bash
echo $SHELL
echo $0
cat /etc/shells
CommandShows
echo $SHELLyour login shell, set in your user account
echo $0the name of the shell running right now
cat /etc/shellsevery shell installed and allowed for logins
text
/bin/bash
# /etc/shells: valid login shells
/bin/sh
/usr/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/usr/bin/dash

(echo $0 prints -bash or bash.) $SHELL is a variable: a named value the system keeps for you. echo prints it. Other shells exist (sh, dash, zsh), but bash is what you'll meet on servers, and what this whole course uses.

2 · Your task

Save the path of your login shell (the value of $SHELL) to /root/shell.txt.

Expected result: /root/shell.txt contains /bin/bash.

Hint: the commands, explained
text
echo $SHELL > /root/shell.txt

What each part does

  • $SHELL is a variable holding your login shell's path; echo prints its value.
  • > saves it into /root/shell.txt.
First start the lab machine in the terminal panel on the right.

How you reach a Linux server

A server in the cloud has no screen, keyboard or mouse. It sits in a data centre, possibly on another continent. You work on it remotely: from your own computer, you open a terminal and connect with SSH (Secure Shell), an encrypted connection that gives you a shell on the server.

Working on a remote server

Your laptopWindows, macOS or Linux, with a terminal
SSH, encrypted
Server in the cloudno screen; you type commands into its shell
text
ssh [email protected]

From that moment, every command you type runs on the server, not on your laptop. The SSH lesson in the networking module covers it in depth. In our labs, the terminal on the right of the page is already connected to your own Linux machine, so you can skip that part for now.

Ideas that make Linux "Linux"

A few principles explain why Linux works the way it does. You'll see them again and again in this course:

  1. Everything is a file. Settings are text files in /etc. Logs are text files in /var/log. Even disks (/dev/sda) and running processes (/proc) appear as files. If you can read and edit files, you can configure almost anything.
  2. Small tools that do one thing well. ls lists, grep searches, sort sorts, wc counts. You combine them with pipes (|) to answer complicated questions in one line.
  3. Text in, text out. Commands read and write plain text, which is why they combine so easily and why scripts can automate them.
  4. Silence is golden. A command that worked usually prints nothing. Output is for results and errors.
  5. Users and permissions. Every file and process belongs to a user. The all-powerful administrator is called root. Everyone else has limited rights, which protects the system from mistakes and attacks.

Thinking Linux is "hard" because there's no mouse. The command line looks unfamiliar at first, but it's built from a small number of consistent ideas. After a few lessons you'll find it faster than clicking, and it's the only way to automate work, which is the whole point of DevOps.

"What is the difference between Linux and Unix?" Unix is an older operating system from Bell Labs (1970s). Linux was written from scratch to work like Unix, but it contains no Unix code. macOS is a certified Unix, which is why its terminal feels similar.

"What is a kernel?" The core of the operating system. It manages processes, memory, files, devices and the network, and every program goes through it to use the hardware.

"Which distributions have you worked with?" Name one from each family, for example Ubuntu (apt) and Amazon Linux or RHEL (dnf/yum), and mention that the core commands are the same.

Try it · Task 4 of 4

Everything is a file

Count the CPUs by reading a file the kernel creates.

1 · See how it's done Read this, then run the commands in your terminal (or press ▶ Run)

One of the core ideas of Linux: everything is a file. The kernel even shows information about itself as files in /proc: there's no real file on disk, the kernel writes the content the moment you read it. Tools like top, free and nproc just read these files.

1. Look inside /proc

bash
ls /proc | head -12
cat /proc/version
grep "model name" /proc/cpuinfo | head -1
head -3 /proc/meminfo
CommandShows
ls /procnumbered folders (one per running program) and info files
/proc/versionthe kernel version, as text
/proc/cpuinfoone block per CPU core
/proc/meminfomemory figures
head -3 / head -12only the first 3 / 12 lines
text
1
16
39
40
41
8
acpi
buddyinfo
bus
cgroups
cmdline
config.gz
Linux version 6.18.44-fc-v819 (builder@sandboxing) (gcc (GCC) 15.3.0, GNU ld (GNU Binutils) 2.46) #1 SMP PREEMPT_DYNAMIC @0
model name	: Intel(R) Xeon(R) Processor @ 2.10GHz
MemTotal:        8216208 kB
MemFree:         6908320 kB
MemAvailable:    7706256 kB

The numbers at the top of /proc are process IDs: each running program has a folder. You'll explore them in Section 4.

2. Count the CPUs

bash
grep -c ^processor /proc/cpuinfo
nproc

grep -c counts matching lines; ^processor means lines that start with "processor" (one per CPU). nproc does the same job as a ready-made command.

text
2
2
2 · Your task

Count the CPU cores by reading /proc/cpuinfo, and save the number to /root/cpus.txt.

Expected result: /root/cpus.txt contains just a number, the count of processor lines in /proc/cpuinfo.

Hint: the commands, explained
text
grep -c ^processor /proc/cpuinfo > /root/cpus.txt

What each part does

  • grep -c: count matching lines instead of printing them.
  • ^processor: lines that start with "processor"; /proc/cpuinfo has one per CPU core.
First start the lab machine in the terminal panel on the right.

What's next

You now know what Linux is and why it matters. Time to get your hands on it: in the next lesson you'll open a terminal on a real Linux machine, read the prompt and run your first commands.

Check your understanding

Quick quiz

Feedback