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.
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
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.
Which kernel?
Find the version of the Linux kernel running this machine.
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
uname
uname -r
uname -a| Command | Prints |
|---|---|
uname | the kernel's name |
uname -r | the kernel release (its version) |
uname -a | all of it: name, hostname, version, build, CPU architecture |
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/LinuxYour 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.
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
uname -r > /root/kernel.txtWhat each part does
uname -rprints the kernel release (version).> /root/kernel.txtsends that output into a file instead of the screen.
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:
| Family | Members | Package format | Install software with |
|---|---|---|---|
| Debian | Debian, Ubuntu, Linux Mint | .deb | apt install nginx |
| Red Hat | RHEL, Rocky Linux, AlmaLinux, Fedora, CentOS Stream, Amazon Linux | .rpm | dnf install nginx (older: yum) |
| Alpine | Alpine Linux | .apk | apk add nginx |
| SUSE | SUSE Linux Enterprise, openSUSE | .rpm | zypper 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.
Which distribution?
Find which Linux distribution and version this server runs.
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
cat /etc/os-releasecat prints a file's contents.
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.)
| Line | Meaning |
|---|---|
PRETTY_NAME | the human-friendly name |
VERSION_ID | the version: 24.04 (released April 2024) |
LTS | Long Term Support: security updates for 5+ years, which is why servers use LTS releases |
VERSION_CODENAME | Ubuntu's nickname for this release; you'll see noble in package sources |
ID_LIKE=debian | Ubuntu is built on Debian, so Debian instructions usually work too |
2. Just the line you need
grep PRETTY_NAME /etc/os-releasegrep prints only the lines that contain a word. You'll learn it properly in Section 2.
PRETTY_NAME="Ubuntu 24.04 LTS"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
grep PRETTY_NAME /etc/os-release > /root/distro.txtWhat each part does
grep PRETTY_NAME /etc/os-release: print only the line of the file that containsPRETTY_NAME.>saves that line into/root/distro.txt.
Where Linux runs
You use Linux every day, mostly without knowing it:
| Where | What runs Linux |
|---|---|
| Cloud | most virtual machines on AWS, Azure and Google Cloud, and the systems behind their managed services |
| Containers | every Docker container you run on a server uses the host's Linux kernel, and almost every image is a small Linux distribution |
| Kubernetes | its nodes are Linux machines |
| Websites | most web servers, including nginx and Apache |
| Phones | Android is built on the Linux kernel |
| Supercomputers | all of the world's 500 fastest supercomputers run Linux |
| Devices | routers, 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
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:
| Word | What it is | Example |
|---|---|---|
| Kernel | the core of the OS, talks to the hardware | Linux |
| Shell | a program that reads your commands and runs them | bash (the default on most servers), zsh, sh |
| Terminal | the window that shows the shell and sends it your keystrokes | Windows 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
ls + Enter in the terminal/usr/bin/ls and asks the kernel to start itls, which asks it to read the folder from diskYou'll take that apart properly in the next lesson, where you run your first commands.
Which shell?
Find the program that reads the commands you type.
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?
echo $SHELL
echo $0
cat /etc/shells| Command | Shows |
|---|---|
echo $SHELL | your login shell, set in your user account |
echo $0 | the name of the shell running right now |
cat /etc/shells | every shell installed and allowed for logins |
/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.
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
echo $SHELL > /root/shell.txtWhat each part does
$SHELLis a variable holding your login shell's path;echoprints its value.>saves it into/root/shell.txt.
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
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:
- 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. - Small tools that do one thing well.
lslists,grepsearches,sortsorts,wccounts. You combine them with pipes (|) to answer complicated questions in one line. - Text in, text out. Commands read and write plain text, which is why they combine so easily and why scripts can automate them.
- Silence is golden. A command that worked usually prints nothing. Output is for results and errors.
- 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.
Everything is a file
Count the CPUs by reading a file the kernel creates.
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
ls /proc | head -12
cat /proc/version
grep "model name" /proc/cpuinfo | head -1
head -3 /proc/meminfo| Command | Shows |
|---|---|
ls /proc | numbered folders (one per running program) and info files |
/proc/version | the kernel version, as text |
/proc/cpuinfo | one block per CPU core |
/proc/meminfo | memory figures |
head -3 / head -12 | only the first 3 / 12 lines |
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 kBThe 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
grep -c ^processor /proc/cpuinfo
nprocgrep -c counts matching lines; ^processor means lines that start with "processor" (one per CPU). nproc does the same job as a ready-made command.
2
2Count 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
grep -c ^processor /proc/cpuinfo > /root/cpus.txtWhat each part does
grep -c: count matching lines instead of printing them.^processor: lines that start with "processor";/proc/cpuinfohas one per CPU core.
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.
Quick quiz
You've practised everything in this lesson
Every task was checked on your own machine. You can end the lab, or keep experimenting in the terminal.