$ linux-basics · fundamentals

Introduction
To Linux

Understanding the operating system behind almost every server, security tool, and hacking lab you will ever touch, all the way from the kernel up to your first bash script.

# Instructor: Abderrahmane Yahiaoui
Module 0: Welcome
bash · 72x16
yahiaoui@linux:~$ whoami abderrahmane yahiaoui, instructor yahiaoui@linux:~$ cat notes.md # Introduction To Linux Linux Fundamentals yahiaoui@linux:~$
$ cat agenda.md

What We'll Cover Today

Four modules, starting from "what even is Linux" and ending with you writing a working script.

01

Foundations

What Linux is, where it came from, and why it matters for security work.

02

Filesystem & Commands

Navigating, managing files, permissions, processes, networking, and packages.

03

Bash Scripting

Variables, conditionals, loops, and your first real automation script.

04

Wrap-up

Key takeaways and how this connects to the rest of the guide.

$ cd 01-foundations

What Is Linux, Exactly?

  • Linux is, technically, just a kernel: the core program that talks directly to your hardware. It is not a full operating system on its own.
  • A Linux distribution ("distro") bundles that kernel with a shell, system tools, and a package manager into something you can actually install and use, for example Ubuntu, Debian, or Kali.
  • It's free and open-source: the entire source code is public, so anyone can read it, audit it, or modify it.
  • It quietly runs most of the internet: servers, cloud infrastructure, Android phones, routers, and nearly every security tool you'll use.

Kernel to Distribution

The Kernel

Talks to hardware, manages processes & memory

+ shell + tools + package manager

= A Distribution

Ubuntu, Debian, Kali, Fedora…

$ cd 01-foundations

Where Linux Came From

A short timeline, because knowing where a tool's philosophy comes from helps you reason about how it behaves.

1969
Unix is born at Bell LabsSets the philosophy Linux later inherits: small tools, plain text, "everything is a file."
1983
The GNU Project launchesRichard Stallman starts building a free, Unix-compatible set of tools and a license to keep them free.
1991
Linus Torvalds releases the Linux kernelA Finnish university student shares his hobby kernel project with the world, for free.
Today
Linux + GNU tools run the modern worldServers, supercomputers, cloud platforms, and almost every security distro, including Kali.
$ cd 01-foundations

Why You Need Linux as a Security Professional

  • Most servers you'll be defending or testing run Linux. You can't secure what you don't understand.
  • Nearly every offensive-security distro is Linux-based: Kali, Parrot, BlackArch.
  • Open-source code means transparency: vulnerabilities get found, discussed, and patched in the open.
  • The command line is the fastest way to automate recon, parse logs, and chain tools together, which is exactly where bash scripting (Module 03) comes in.
Kali LinuxNmapWiresharkMetasploittcpdump
auth.log
root@server:~# tail -f /var/log/auth.log sshd: Failed password for root sshd: Failed password for root sshd: Failed password for admin # this looks like a brute-force attempt
$ cd 01-foundations

Choosing a Distribution

Distros are families. Once you know one well, the others feel familiar.

Debian family

Debian · Ubuntu · Kali · Parrot

Uses apt. Huge community, beginner-friendly, the default choice for most security tooling.

Red Hat family

RHEL · Fedora · Rocky Linux

Uses dnf/yum. Common in enterprise servers and corporate environments.

Independent

Arch · Alpine

Uses pacman/apk. Minimal, fast, popular for containers and advanced users.

For this guide: everything we show today works identically on Ubuntu, Debian, and Kali. Only the package manager changes; the commands stay the same.
$ cd 01-foundations

How Linux Is Put Together

Applications

Firefox, Nmap, VS Code, your own scripts…

Shell

bash, zsh. Interprets the commands you type

Kernel

Processes, memory, drivers, system calls

Hardware

CPU, RAM, disk, network card

Every layer only talks to its direct neighbor. Your browser never touches the CPU directly. It asks the kernel, which asks the hardware. That separation is what keeps the system stable and secure.

$ cd 01-foundations

The Kernel: Linux's Engine Room

  • Process management: decides which program gets CPU time, and when.
  • Memory management: allocates and protects RAM for every running program.
  • Device drivers: translates between hardware (disks, network cards, USB) and software.
  • System calls: the controlled "front door" applications use to ask the kernel for anything at all.
$ cd 01-foundations

Shell, Terminal, Console: Not the Same Thing

Terminal

The window/program that displays text input and output. It's just the "screen."

Shell

The program that interprets your commands: bash, zsh, fish. This is the "brain."

Console

A physical or virtual direct-access screen tied to the machine itself, not a separate window.

bash
you@machine:~$ echo $SHELL /bin/bash
$ cd 01-foundations

The Unix Philosophy, Inherited by Linux

  • "Everything is a file." Devices, processes, even network sockets are represented as files you can read or write.
  • Small programs, one job each. A command should do one thing well, then you combine it with others.
  • Prefer plain text. Configuration and output stay scriptable, diffable, and greppable.
  • This is exactly why chaining commands together with pipes (Module 02) feels so natural on Linux: it was designed for it from day one.
$ cd 02-filesystem-and-commands

The Filesystem Hierarchy Standard

Every Linux distro arranges files this way. Once you learn it, you can navigate any Linux machine on earth.

tree -L 1 /
/ ├── bin # essential user binaries (ls, cp, bash…) ├── etc # system configuration files ├── home # personal user directories ├── var # logs, mail, spool, variable data ├── usr # installed software & libraries ├── tmp # temporary files, cleared on reboot ├── dev # device files (disks, terminals…) ├── proc # live kernel & process information └── root # home directory of the root user
$ cd 02-filesystem-and-commands

Finding Your Way Around

  • pwd: print your current directory (where am I?).
  • ls / ls -la: list files; -l for details, -a to show hidden files.
  • cd path: change directory; cd .. goes up one level, cd ~ goes home.
  • Absolute path: starts from / (e.g. /home/user/notes). Relative path: starts from where you are now.
bash
you@machine:~$ pwd /home/you you@machine:~$ ls -la drwxr-xr-x notes/ -rw-r--r-- todo.txt you@machine:~$ cd notes
$ cd 02-filesystem-and-commands

File & Directory Management

  • mkdir name: create a directory. touch file: create an empty file.
  • cp src dst: copy. mv src dst: move or rename.
  • rm file: delete a file. rm -r dir: delete a directory and its contents.
  • ln -s target link: create a shortcut (symbolic link) to another file or folder.
Careful: rm -rf has no undo and no recycle bin. Always double-check your path before pressing enter.
bash
you@machine:~$ mkdir reports you@machine:~$ touch reports/scan.txt you@machine:~$ cp scan.txt scan_backup.txt you@machine:~$ mv scan_backup.txt archive/
$ cd 02-filesystem-and-commands

Viewing Files Without an Editor

  • cat file: dump the whole file to the screen.
  • less file: scroll through a long file page by page (q to quit).
  • head -n 10 file: first 10 lines. tail -n 10 file: last 10 lines.
  • tail -f file: follow a file live as new lines are written. This is exactly how you watch a log in real time.
auth.log
root@server:~# tail -f /var/log/auth.log Accepted password for sara Session opened for user sara # new lines appear here live
$ cd 02-filesystem-and-commands

Searching for Files & Content

  • find . -name "*.log": search by filename, type, or size, starting from a folder.
  • locate file: instant search using a prebuilt index (faster, but can be slightly outdated).
  • grep -rin "password" .: search file contents. -r recursive, -i case-insensitive, -n show line numbers.
  • Wildcards: * any characters, ? one character, [abc] one of a set.
bash
you@machine:~$ grep -rin "password" . ./config.php:14:$password = "***";
$ cd 02-filesystem-and-commands

Text Processing Power Tools

Finding the data is half the job. These commands shape it into something useful.

  • cut -d',' -f2 file.csv: pull out one column from delimited text.
  • sort file.txt / sort -n / sort -r: sort lines alphabetically, numerically, or in reverse.
  • uniq: collapse adjacent duplicate lines. Pair it with sort -u for a clean unique list.
  • wc -l file: count lines (-w words, -c characters).
  • sed 's/old/new/g' file: find and replace text, line by line.
  • awk '{print $1}' file: pull out specific fields from structured text.
auth.log
you@machine:~$ cat auth.log | grep "Failed" \ | awk '{print $11}' | sort | uniq -c | sort -nr 42 192.168.1.50 17 10.0.0.9 3 10.0.0.4
Security angle: grep, then awk, then sort and uniq -c, is exactly how a raw log becomes a ranked list of the IPs hammering your login.
$ cd 02-filesystem-and-commands

Users, Groups & Permissions

  • Every file has three permission sets: owner, group, and other, each with read (r), write (w), execute (x).
  • chmod 755 file or chmod u+x file: change permissions (numeric or symbolic).
  • chown user:group file: change who owns the file.
- rwx r-x r--
-
type
r
owner read
w
owner write
x
owner exec
r
group read
-
group write
x
group exec
r
other read
-
other write
-
other exec
Security angle: world-writable files and overly permissive scripts are one of the most common findings in a real pentest.
$ cd 02-filesystem-and-commands

Process Management

  • ps aux: snapshot of every running process.
  • top / htop: live, updating view of CPU & memory usage per process.
  • kill PID / kill -9 PID: politely ask, then forcefully stop, a process.
  • command & runs in the background; jobs, fg, bg manage it.
Security angle: spotting an unfamiliar process eating CPU or phoning out on the network is a basic incident-response skill.
$ cd 02-filesystem-and-commands

System Info & Disk Usage

Before you fix or secure anything, you need to know exactly what you're working with.

  • whoami / id: who am I, and which groups do I belong to?
  • uname -a: kernel version and system architecture.
  • df -h: disk space used per filesystem, in human-readable form.
  • du -sh folder: how much space a specific folder is taking up.
  • free -h: RAM and swap usage.
  • history: your most recent commands, useful for replaying or auditing what you ran.
Stuck on a command? man command or command --help opens its manual. which command tells you exactly which binary will run.
bash
you@machine:~$ df -h Filesystem Size Used Avail Use% /dev/sda1 50G 12G 38G 24% you@machine:~$ free -h total used free Mem: 16G 4.2G 8G
$ cd 02-filesystem-and-commands

Package Management

  • apt: Debian, Ubuntu, Kali. dnf/yum: Fedora, RHEL. pacman: Arch.
  • sudo apt update: refresh the list of available packages.
  • sudo apt install nmap: install a tool by name.
  • sudo apt remove nmap: uninstall it again.
bash
you@machine:~$ sudo apt install nmap Setting up nmap... done.
$ cd 02-filesystem-and-commands

Networking & Security Extras

A handful of commands you'll reach for constantly once you leave the local filesystem.

Networking

ip a

List network interfaces and their IP addresses.

ping host

Check whether a host is reachable.

curl / wget

Fetch a web resource straight from the terminal.

ssh / scp

Log into, or copy files to, a remote machine.

Integrity & Archives

sha256sum file

Fingerprint a file to verify it hasn't been tampered with.

tar -czvf out.tar.gz dir/

Compress a folder into a single archive.

unzip file.zip

Extract a zip archive's contents.

Security angle: comparing a downloaded file's sha256sum against the value published by its source is exactly how you confirm an ISO or tool hasn't been swapped for a malicious copy.
$ cd 02-filesystem-and-commands

I/O Redirection & Pipes

>

Send output to a file, overwriting it.

>>

Send output to a file, appending to it.

<

Feed a file in as input to a command.

|

Pipe: send one command's output straight into the next.

Example: count how many shell scripts are in this folder.

ls -l
→ | →
grep ".sh"
→ | →
wc -l
→
4
$ cd 03-bash-scripting

Your First Bash Script

  • A script is just a text file full of the same commands you'd type by hand, saved so you can run them all at once.
  • The first line, called the shebang, tells the system which interpreter to use: #!/bin/bash.
  • Save it as myscript.sh, then make it executable: chmod +x myscript.sh.
  • Run it with ./myscript.sh (or bash myscript.sh without the chmod step).
hello.sh
#!/bin/bash echo "Hello, world!"
$ cd 03-bash-scripting

Variables & User Input

  • Assign with name=value. No spaces around the =. Use it with a $: $name.
  • read -p "Prompt: " var: ask the user for input and store it.
  • $1, $2…: positional arguments passed to the script. $#: how many were given.
greet.sh
#!/bin/bash target=$1 read -p "Your name: " name echo "$name is scanning $target" you@machine:~$ ./greet.sh 10.0.0.5 Your name: sara sara is scanning 10.0.0.5
$ cd 03-bash-scripting

Conditionals

  • if [ condition ]; then … elif … else … fi: the basic shape.
  • Common tests: -eq equal, -f file file exists, -z "$v" empty string, == string match.
  • Double brackets [[ … ]] are a more forgiving, modern alternative to [ … ].
Check: is this user root?
if [ "$EUID" -eq 0 ]
true
Run privileged task
false
echo "Access denied"
$ cd 03-bash-scripting

Loops & Functions

  • for f in *.log; do … done: repeat once per item in a list.
  • while [ condition ]; do … done: repeat while something stays true.
  • name() { … }: define a reusable function; call it later just by typing name.
bash
for ip in 10.0.0.1 10.0.0.2; do ping -c 1 $ip done
$ cd 03-bash-scripting

Putting It Together: A Mini Recon Script

Everything from today, in one small, real script.

quick_recon.sh
#!/bin/bash # Quick recon script: a basic system snapshot for a security check echo "Hostname: $(hostname)" echo "Uptime: $(uptime -p)" echo "Listening ports:" ss -tuln echo "Users currently logged in:" who read -p "Save this report to a file? (y/n): " choice if [[ "$choice" == "y" ]]; then ./quick_recon.sh > recon_report.txt echo "Saved to recon_report.txt" fi
$ cd 03-bash-scripting

Why This Matters for Security

  • Automating recon: run the same checks across dozens of hosts in seconds instead of by hand.
  • Parsing logs at scale: counting failed logins, extracting suspicious IPs, flagging patterns.
  • Chaining tools together: feeding one tool's output straight into the next without manual copy-pasting.
  • Writing quick custom checks: when no existing tool does exactly what an assessment needs, you write five lines of bash instead of waiting.
$ cd 04-wrap-up

Key Takeaways

✓
Linux = kernel + shell + toolsA distribution packages all of it into something installable.
✓
The FHS gives every file a logical home/etc for config, /var for logs, /home for users.
✓
Permissions control who can do whatrwx for owner, group, and other. Central to securing any system.
✓
Text tools and pipes chain commands togethergrep, awk, sort, and uniq turn raw logs into real answers.
✓
Bash scripts turn manual steps into repeatable automationExactly what you'll lean on throughout this guide.
$ cd 04-wrap-up

Thank You.
Questions?

Let's open a terminal and start practicing. The best way to learn Linux is to break it, then fix it.

# Abderrahmane Yahiaoui, Instructor
bash
yahiaoui@linux:~$ exit