Post

Introduction to Linux

Introduction to Linux and how to navigate it

Introduction to Linux
Pre-test
Answer all 5 questions, then press Check answers.
1. What is Linux, strictly speaking?
2. Which of these is NOT a job of the kernel?
3. Which pair of distributions belongs to the Debian family?
4. Which command refreshes the list of available packages on Debian/Ubuntu?
5. Which is the first user-space process started during boot (PID 1)?
0 of 5 answered

What is Linux?

Linux is an open source Operating Systems (OS) kernel. it is basically a program that talks to the hardware and shares the information between all the other programs.

An Operating System (OS) is the software that manages hardware resources (CPU, memory, disks, and network) and provides services so that applications can run.

Linux was created by Linus Torvalds in 1991 and is developed in the open by many contributors and companies.


Why Does Linux Matter?

There are a couple of reasons why Linux matters, and learning about them is important:

Open source

The source code is public and people can inspect, modify, and redistribute it under licenses. Free here means no cost and freedom to change it. Companies still sell paid support (such as RHEL and Ubuntu Pro).

Runs almost anywhere

Linux can be used on cloud virtual machines, web servers, containers, Android phones, routers, and smart TVs.

Automation friendly

Nearly everything is configured with text files and commands, so it can be scripted, versioned in Git, and automated.

Stable and transparent

Linux can run for months without rebooting, and its logs and tools let you see what the system is doing.

The foundation of modern infrastructure

Most importantly, Linux is the foundation for understanding modern infrastructure such as containers, Kubernetes, CI/CD, and most DevOps tools run on Linux.


What is Kernel?

Kernel is the core program of an OS. It sits between your hardware (CPU, memory, disks, network) and the programs. It basically the manager that other programs need.

What does it do?

Process Management

Decides which program run on CPU and for how long.

Memory Management

Gives each program its own memory space and keeps them separate.

Device Drivers

Talks to hardware so program don’t have to know the details of each device.

File Systems

Organizes how data is stored and read.

Networking

Handles sending and receiving data over network.

Security

Enforces permissions, so programs can’t freely access things it shouldn’t


Distributions (Distros)

Distributions is a complete, ready to use operating system built around the Linux kernel. Think of the kernel as the coffee bean, the essential ingredient and the distro is the finished cup of coffee.

What does a distribution provide?

  • A tested kernel build.
  • A package manager and its repositories with ready made software.
  • An installer with default configuration.
  • A release policy.
  • A community or company that supports it.

Main Families

Check out the entire family tree Distrowatch

FamilyExamplesPackage Format/ToolTypical Use
DebianDebian, Ubuntu, Linux Mint, Raspberry Pi OS.deb / apt, dpkgServers, cloud images, desktops, container base images
Red Hat (RHEL)RHEL, Rocky Linux, Fedora, CentOS.rpm / dnf, rpmEnterprise server
SUSESLES, openSUSE.rpm / zypperEnterprise, SAP
ArchArch Linux, Manjaro.pkg.tar.zst / pacmanEnthusiast, DIY

Release Models

ModelHow It WorksExample
Fixed/LTSNew major version roughly every 2 years, each supported for 5 years security fixes, Predictable and stableUbuntu LTS, Linux Mint LTS, Debian stable
RollingNo versions, packages always up to dateArch, openSUSE Tumbleweed
Fast Cycle/upstreamNew release about every 6 months (Fedora), tests features for enterprise distrosFedora, CentOS Stream

Terminal, Shell, and Command Line

Words that are often mixed up:

TermMeaning
TerminalThe window where you type and read text.
ShellThe program inside the terminal that reads the commands and runs them (such as bash, zsh, fish)
Command Line (CLI)The interface style, simply controlling the computer by typing commands instead of clicking
Desktop EnvironmentOptional graphical layer (such ash GNOME, KDE, XFCE)

Anatomy of a Commands

1
2
3
4
5
6
7
$ ls -l /etc
  |  |  |
  |  |  +-- argument : what to act on (a file, directory, name...)
  |  +------ option   : changes behaviour (short -l, long --long)
  +--------- command  : the program to run

user@server:~$    <- '$' = normal user        root@server:~#    <- '#' = root (administrator)

Note:

  • Linux is case sensitive: test.txt and Test.txt are different
  • Spaces separate words: File with spaces, must be quoted "this test.txt"
  • Suprise output: most commands output nothing when they succeed
  • Getting help: man (manual), cd --help (Option help) is your best friend.

Stages of Linux Boot Process

flowchart LR
    A["Firmware<br/>(BIOS / UEFI)"] --> B["Bootloader<br/>(GRUB)"]
    B --> C["Kernel +<br/>initramfs"]
    C --> D["systemd<br/>(PID 1)"]
    D --> E["Services<br/>and target"]
    E --> F["Login<br/>prompt"]

    classDef step fill:#2e6db4,stroke:#1f4e8c,color:#fff;
    class A,B,C,D,E,F step;
StageWhat Happens
FirmwareTests the hardware and finds the boot disk
BootloaderGRUB loads the kernel and initramfs (temporary filesystem with drivers needed to reach the real disk) into memory
KernelInitializes hardware, mounts the root filesystem, and starts first process
systemdThe first user-space process. It starts everything else
Servicessystemd starts services until it reaches the target
LoginConsole login appears

Why this matters: Understanding the boot flow helps when a server does not boot, because it gives you a clue about where to look.


Repositories

Repository its a place of centralized storage location used to organize, store, and host packages. Systems read its list from /etc/apt/sources.list and /etc/apt/sources.list.d/ (Debian family) or /etc/yum.repos.d/.

Each repo has a GNU Privacy Guard Key (GPG Key) which are used to encrypt, decrypt, and digitally sign data so package manager can verify the packages.

Other ways software is delivered

MethodWhat it isGuidance
Vendor RepositoryThe software vendor’s own apt/dnf repo (Docker, nginx, PostgreSQL)For up to date releaases
Snap/Flatpak/AppImageBundled apps with their own librariesConvenient for desktop apps
Container ImageRun with Docker or KubernetesPreferred for deploying applications

Installing, Updating, and Removing Packages

The day to day commands for updating, searching, inspecting, and installing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# refresh local package index
$ sudo apt update

# find packages by keyword
$ apt search nginx

# description, version, dependencies, size
$ apt show nginx

# installed vs candidate version and which repo it comes from
$ apt-cache policy nginx

# install package
$ sudo apt install nginx

Packages Command Cheatsheet

TaskDebian/UbuntuRHEL/Rocky
Refresh Package Indexapt updatednf makecache
Searchapt search <package>dnf search <package>
Show Detailsapt show <package>dnf info <package>
Installapt install <package>dnf install <package>
Instal Multipleapt install <package1> <package2>dnf install <package1> <package2>
Install from Localapt install ./<package>.debdnf install ./<package>.rpm
Upgrade Packagesapt upgradednf upgrade
Remove Package (Keep Config)apt remove <package>dnf remove <package>
Remove Package (Including Config)apt purge <package>Auto purge on remove (if not modified)
Remove Unused Dependenciesapt autoremovednf autoremove
List Installed Packagesapt list --installeddnf list installed
Clean Download Cacheapt cleandnf clean all

How to Start Practicing Linux?

There are a several ways you can start practicing Linux right now, shown below:

OptionHow?Limits
Local VM (Recommended)VirtualBox, VMware Workstation, QEMU+VMMNeeds some spare resources
WSL (Windows)wsl --install -d ubuntuSome kernel/network features differ
Cloud VMAWS, Azure, GCPCosts money if left unchecked
Containerdocker run -it ubuntu:24.04 bashShares host kernel
Bootable USB/Dual BootDistro desktop installer, Portable ImagesRisky if partitioning goes wrong

First Minutes on Linux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# which user am I?
$ whoami

# what machine is this?
$ hostname

# which distribution and version?
$ cat /etc/os-release
$ lsb_release -a

# which kernel version?
$ uname -r

# how long up, and the load average
$ uptime

# memory
$ free -h

# disk space
$ df -h

# IP addresses
$ ip -br addr

# some running processes
$ ps aux | head

# what is in my home directory?
$ ls -la ~

# what was recently typed here?
$ history | tail

Practice

Practice: package commands
Type the Debian/Ubuntu command for each task, then press Check answers. Adding sudo is fine.
TaskCommand (Debian/Ubuntu)Result
Refresh the package index
Install the package nginx
Remove nginx but keep its configuration files
Remove nginx including its configuration files
List all installed packages
Clear the downloaded package cache
0 of 6 filled in

Glossary

TermDetail
KernelCore of the OS, manages CPU, memory, devices, filesystems, networking
Distribution (Distro)Kernel, package manager and defaults that are packaged as a usable OS
ShellProgram that interprets typed commands (bash, zsh)
PackageArchive with software files, metadata, scripts, and dependencies
Daemon/serviceBackground program, usually started at boot
rootAdministrator account (UID 0)
sudoRuns command with elevated privileges
Mount PointDirectory where filesystem is attached to the tree
LTSLong Term Support, a release with security updates for years
Open SourceSource code is available
ContainerIsolated process group sharing the host kernel

Hands-On Cases

Scenario: You’ve just been given access to a Linux machine. Your job is to create a small project workspace, add some files, and organize them using only the terminal.

Try each step yourself first, then open the solution to check.

Step 1: Find out where you are

Print your current directory and list what’s in it.

Show solution
1
2
3
4
5
# print the current working directory
pwd

# list the files here
ls

pwd means “print working directory”. Right after login you are normally in your home directory (/home/yourname).

Step 2: Create the workspace

Create a directory called linux-lab in your home folder, with three subdirectories inside it: docs, backup and scripts. Then move into linux-lab.

Show solution
1
2
3
4
5
6
7
8
9
10
11
12
13
# create the folder and its subfolders in one command
mkdir -p ~/linux-lab/{docs,backup,scripts}

# alternatively doing it one by one
mkdir -p ~/linux-lab/docs
mkdir -p ~/linux-lab/backup
mkdir -p ~/linux-lab/scripts

# move into the workspace
cd ~/linux-lab

# check the result
ls

-p creates parent directories as needed and doesn’t complain if they already exist. The {docs,backup,scripts} part is shell brace expansion, which produces three paths from one expression.

Step 3: Create empty files

Create three empty files in linux-lab: notes.txt, todo.txt and draft.txt.

Show solution
1
2
3
4
5
# create empty files
touch notes.txt todo.txt draft.txt

# list with details to confirm they exist (size 0)
ls -l

touch creates an empty file if it doesn’t exist. If it does exist, it only updates the modification time.

Step 4: Put content in a file

Write the line Hello Linux into notes.txt, then add a second line My first workspace. Display the file to verify.

Show solution
1
2
3
4
5
6
7
8
# > overwrites the file with this text
echo "Hello Linux" > notes.txt

# >> appends to the end of the file
echo "My first workspace" >> notes.txt

# show the file contents
cat notes.txt

Be careful with >. It replaces everything in the file, while >> keeps the existing content and adds to it.

Step 5: Copy a file

Copy notes.txt into the backup directory. Keep the original where it is.

Show solution
1
2
3
4
5
# copy the file into backup/
cp notes.txt backup/

# confirm both copies exist
ls notes.txt backup/

cp source destination leaves the original untouched.

Step 6: Rename and move a file

Rename draft.txt to report.txt, then move it into the docs directory.

Show solution
1
2
3
4
5
6
7
8
# rename: mv with a new name in the same directory
mv draft.txt report.txt

# move into docs/
mv report.txt docs/

# confirm
ls docs/

mv is used for both renaming and moving. It just changes the file’s name or location, and doesn’t leave a copy behind.

Step 7: Copy a whole directory

Copy the entire docs directory into backup.

Show solution
1
2
3
4
5
# -r means recursive: needed to copy directories
cp -r docs backup/

# check what is inside backup
ls -R backup

Without -r, cp refuses to copy a directory.

Step 8: Clean up

Delete todo.txt, because you no longer need it.

Show solution
1
2
3
4
5
# delete the file
rm todo.txt

# confirm it is gone
ls

rm is permanent. There is no trash bin in the terminal, so double-check the filename before you press Enter. To be asked first, use rm -i todo.txt.

Step 9: Check your final result

Show the whole workspace as a recursive listing.

Show solution
1
2
# list everything under the current directory
ls -R

Your workspace should look roughly like this:

1
2
3
4
5
6
7
8
9
linux-lab/
├── backup/
│   ├── docs/
│   │   └── report.txt
│   └── notes.txt
├── docs/
│   └── report.txt
├── scripts/
└── notes.txt

Finish

Thank you for reading or following until the end!


Post-test
Answer all 5 questions, then press Check answers.
1. In the command ls -l /etc, what is -l?
2. What is the correct order of the Linux boot stages?
3. Which release model ships a new major version every 1 to 2 years, with about 5 years of security fixes?
4. Which command removes a package AND its configuration files on Debian/Ubuntu?
5. What is the GPG key of a repository used for?
0 of 5 answered
This post is licensed under CC BY 4.0 by the author.