# How to learn Linux from scratch

Linux runs most servers, containers and countless devices, so developers, testers, analysts and system administrators all need the command line. The easiest way to learn it is not by reading lists of commands but by working in the terminal every day and solving small practical tasks. Below is a sequence of topics for two to three months.

## Where to get Linux without breaking anything

You do not need to reinstall your main system. Safe options:

* a virtual machine (VirtualBox, or UTM on a Mac) with Ubuntu or Debian;
* WSL on Windows — a Linux environment right inside the system;
* a cheap cloud server — the closest to real work, and you learn to log in over
  SSH along the way.

Any popular distribution is fine to start: Ubuntu, Debian, Fedora. For a
beginner the difference is mostly the package manager (`apt` or `dnf`).

## The first two weeks: the file system and navigation

The directory tree starting at the root `/`: where settings live (`/etc`), logs
(`/var/log`), home directories (`/home`). Basic commands:

```bash
pwd                  # where am I
ls -la               # what is here, including hidden files
cd /var/log          # go to a directory
mkdir -p notes/linux # create directories
cp, mv, rm           # copy, move, delete
less /etc/os-release # read a file page by page
```

The built-in help is `man command` and `command --help`. Make them the first
place you look. Be careful with `rm -r`: the terminal has no trash can.

## Weeks 3–4: permissions, users, sudo

Owner, group, others; read, write and execute permissions. The notation
`rwxr-xr--` and its numeric form 754: each group of three turns into a number
(r = 4, w = 2, x = 1). Commands: `chmod`, `chown`, `sudo`, `id`, `useradd`.
Exercise: create a user and a shared directory for a group, then check who can
do what in it.

## Weeks 5–6: text, streams, searching

The power of the command line is in combining small programs. Redirection with
`>` and `>>`, the `|` pipe, and the commands `grep`, `sort`, `uniq`, `wc`, `head`,
`tail`, `find`, `cut`. A sample task: find the ten IP addresses that appear most
often in a web server log. For a terminal text editor, start with `nano` and
learn the basics of `vim` later.

## Weeks 7–8: packages, processes, services, networking

Installing software with the package manager, viewing processes (`ps`, `top` or
`htop`), signals and `kill`. Services under systemd: `systemctl status`, `start`,
`enable`, and logs through `journalctl`. Networking: `ip a`, `ping`, `curl`, `ss`,
and logging in to a server with an SSH key instead of a password.

## Weeks 9–10: bash scripts

Variables, conditions, loops, script arguments, exit codes. Useful first
scripts: back up a directory into an archive with the date in its name, clean up
old files, check free disk space and warn when it runs low. Run them on a
schedule with `cron` or systemd timers. Keep your scripts in a Git repository and
check them with the ShellCheck analyser.

## A practice project

On a virtual machine or a cloud server, set up the nginx web server with your own
page, configure a firewall, key-only login, a daily backup script and log
rotation. Describe every step in a README so that anyone could repeat the setup
on a clean system — a good sign that you understand the commands rather than
copy them.

## How to check yourself

* Delete the virtual machine and set it up again from your own notes.
* Solve tasks like "find a file larger than 100 MB changed in the last week"
  without searching the internet.
* Explain the `ls -l` output for any file: type, permissions, owner, size.
* Play terminal wargames such as OverTheWire Bandit, where each level is unlocked
  by a password you have to find.

## Step-by-step plan

1. **Week 1 — setup** — A virtual machine, WSL or a cloud server with Ubuntu or Debian.
2. **Weeks 2–4 — files and permissions** — Navigation, working with files, man, permissions, users and sudo.
3. **Weeks 5–6 — text and pipelines** — grep, sort, find, redirection; analysing a web server log.
4. **Weeks 7–8 — the system** — Packages, processes, systemd, networking and SSH with a key.
5. **Weeks 9–12 — scripts and a project** — Bash scripts, cron, your own server with nginx and backups, described in a README.

## Check yourself

1. Which command prints the path of the current directory?
   - pwd
   - cd
   - ls
2. What is the numeric form of the permissions rw-r--r--?
   - 644
   - 755
   - 600
3. The permissions rwxr-xr-x are written as a number. Which one?

## Sources

- [LinuxCommand.org](https://linuxcommand.org/) — The free book The Linux Command Line and lessons on the shell
- [Ubuntu tutorials](https://ubuntu.com/tutorials) — Official step-by-step tutorials for the distribution
- [OverTheWire: Bandit](https://overthewire.org/wargames/bandit/) — A terminal game where each level teaches a command-line skill
- [ShellCheck](https://www.shellcheck.net/) — Finds bugs in shell scripts

---

https://skillok.org/articles/en/learn-linux-from-scratch
