🐧 Enroll in Linux Course →
🐧 Free Lecture Notes

Linux Fundamentals
— Complete Notes

All 16 modules. Every concept explained simply. Linux vs Windows comparisons so you understand the why, not just the commands. Free to read — no account needed.

✓ 100% Free 16 Modules Linux vs Windows
MODULE 01

What is Linux?

History, distros, Linux vs Windows — the full picture before touching a terminal.

What is Linux?

Linux is an operating system — just like Windows. An operating system is the software that runs your computer. It manages the hardware (CPU, RAM, disk) and lets you run programs on top of it.

Linux was created in 1991 by Linus Torvalds — a student who wanted a free version of Unix. He put the code online for anyone to use and improve. Today, Linux runs 90%+ of all web servers, every Android phone, most cloud platforms, and all supercomputers in the world.

Linux vs Windows — Key Differences
TopicLinuxWindows
CostFree and open sourcePaid license (~$200 for Pro)
InterfaceTerminal first (GUI optional)GUI first (terminal optional)
Used forServers, cloud, DevOps, developmentDesktop, gaming, office, enterprise apps
SecurityFewer viruses, better permission modelMore targeted by malware
UpdatesYou choose when and what to updateWindows decides and restarts your PC
CustomisationFull control over everythingLimited to what Microsoft allows
Package installOne command (dnf install nginx)Download .exe, run installer, click Next
Servers worldwide~96% of all web servers~4% of web servers

What is a Distro?

Linux is a kernel — the core engine. A distro (distribution) is a complete OS built on top of that kernel. Different distros package it differently — different tools, package managers, and purposes.

RHEL
Red Hat Enterprise Linux. Used in enterprise companies. What RHCSA is based on. Paid support.
CentOS / AlmaLinux
Free alternatives to RHEL. Same commands and behaviour. Good for learning RHCSA.
Ubuntu
Most beginner-friendly. Great for development and cloud. Uses apt for packages.
Fedora
Cutting-edge features. Community version of RHEL. Uses dnf.
Kernel
The core of Linux. Talks to hardware. Everything else runs on top of it.
Shell
The program that reads your commands and runs them. Bash is the most common shell.
💡

Course uses: AlmaLinux / RHEL 9 inside VirtualBox. All commands work identically on any RHEL-family distro.


MODULE 02

Installation & First Boot

Install Linux in a VM. Understand partitions and the boot process.

What is a Virtual Machine?

A virtual machine (VM) is a computer inside your computer. Software called a hypervisor pretends to be hardware — your Linux install thinks it has its own CPU, RAM, and disk. Your actual Windows or Mac machine keeps running normally alongside it.

We use VirtualBox (free) as the hypervisor. You install it on your Windows laptop, then install Linux inside a VirtualBox VM.

Installation — Linux vs Windows
StepLinux (RHEL/AlmaLinux)Windows
Boot mediaISO file → boot from VirtualBox or USBISO or USB, same concept
PartitioningYou choose manually — /, /boot, swapUsually automatic, you pick the disk
Software selectionMinimal install or Server with GUIAlways installs the full GUI
Root passwordYou set it during installNo root — Administrator account instead
Time to complete~10–15 minutes~20–30 minutes
Disk space needed~10 GB minimum~20 GB minimum

Partitions — What They Are

A partition is a section of your disk. Linux separates the OS into multiple partitions for better control and safety. If one partition fills up, the others keep working.

/
Root partition. Everything in Linux lives under /. Like C:\ in Windows.
/boot
Holds the bootloader and kernel files needed to start Linux.
swap
Extra space on disk used as backup RAM. Like Windows page file.
GRUB
The bootloader. First thing that runs when you turn on the PC. Loads the Linux kernel.
Kernel
The core Linux program. GRUB loads it into RAM. Then it starts everything else.
systemd
The first process that runs after the kernel. It starts all services and brings you to login.
⚠️

RAM for VMs: Assign at least 2 GB RAM to your Linux VM. 4 GB if your machine has 16 GB or more. Less RAM = slow, laggy experience.


MODULE 03

The Terminal — Basic Commands

Navigate files, read logs, manage directories — all from the command line.

Why the Terminal?

On Windows you click through File Explorer to move files, right-click to rename, open folders in multiple windows. On Linux you type commands — and it's faster, scriptable, and works the same on any server anywhere in the world. Servers almost never have a GUI — you SSH in and use the terminal.

Common Tasks — Linux vs Windows
TaskLinux CommandWindows Equivalent
List filesls -laFile Explorer or dir
Change directorycd /etccd C:\Windows
Create foldermkdir myfolderRight-click → New Folder
Delete filerm file.txtDelete key or del file.txt
Copy filecp file.txt /tmp/Ctrl+C, Ctrl+V
Move/renamemv old.txt new.txtRight-click → Rename
Read a filecat file.txtOpen in Notepad
Search in filegrep "error" log.txtCtrl+F in Notepad
Check disk spacedf -hRight-click drive → Properties
Current directorypwdLook at address bar
Clear screenclearcls
Command helpman lsGoogle it
Essential Commands Practice
# Where am I right now?
pwd
# Output: /home/kamran

# List files (l=detailed, a=show hidden, h=human readable sizes)
ls -lah

# Go to /etc directory (main config folder in Linux)
cd /etc

# Go back to home directory
cd ~

# Create a directory
mkdir /tmp/mylab

# Create an empty file
touch /tmp/mylab/test.txt

# Write text into a file
echo "Hello Linux" > /tmp/mylab/test.txt

# Read the file
cat /tmp/mylab/test.txt

# Search for a word in a file
grep "Hello" /tmp/mylab/test.txt

# Copy the file
cp /tmp/mylab/test.txt /tmp/backup.txt

# Rename or move
mv /tmp/backup.txt /tmp/renamed.txt

# Delete a file
rm /tmp/renamed.txt

# Delete a folder and everything in it
rm -rf /tmp/mylab
⚠️

rm -rf is permanent. There is no Recycle Bin in Linux. Deleted = gone instantly. Always double-check the path before you press Enter.

Absolute path
Full path from root. Starts with /. Example: /etc/nginx/nginx.conf
Relative path
Path from where you are now. Example: ../config/file.txt
~
Shortcut for your home directory. cd ~ takes you home.
Tab completion
Press Tab to auto-complete commands and paths. Saves time, prevents typos.
Arrow keys
Up/down arrows scroll through previous commands. No need to retype.
Ctrl+C
Cancel a running command immediately.

MODULE 04

Text Editors — Nano & Vim

Edit config files from the terminal. Nano is simple. Vim is powerful. Learn both.

Why Terminal Editors?

On a Linux server there is no desktop, no File Explorer, no right-click. You SSH into the machine and the only way to edit a config file is through a terminal text editor. Nano is what beginners reach for first — it shows you the shortcuts at the bottom. Vim is what professionals use once they learn it — faster, more powerful, works on every system.

Rule: Use nano when you're starting out. Learn vim when you're comfortable. Both are useful — you'll use whichever is available on the server you're on.

Nano vs Vim — Quick Comparison
FeatureNanoVim
Learning curve5 minutesDays to weeks
Shortcuts shownYes — bottom of screenNo — must memorise
ModesJust type, no modesNormal, Insert, Visual, Command
Speed (once learned)AverageVery fast
Pre-installed onMost Ubuntu/Debian systemsAlmost every Linux distro
Best forQuick edits, beginnersHeavy editing, senior admins
Windows equivalentNotepadVS Code (once you know the shortcuts)
Nano — Open, Edit, Save, Exit
# Open a file with nano
nano /etc/hostname

# Now you're in nano. Just type — no mode switching needed.
# Edit the file normally.

# Save (Write Out):
Ctrl + O  → press Enter to confirm filename

# Exit nano:
Ctrl + X

# Save and exit in one go: Ctrl+X → Y → Enter

# Other useful nano shortcuts:
Ctrl + K  → cut (delete) a line
Ctrl + U  → paste the cut line
Ctrl + W  → search (find) text in file
Ctrl + G  → show help
Vim — Open, Edit, Save, Exit
# Open a file with vim
vim /etc/hostname

# Vim starts in NORMAL mode — keys are commands, not text input.
# To start typing, press:
i  → enters INSERT mode (now you can type)

# After typing, press Escape to go back to NORMAL mode
Esc

# To save and exit (from NORMAL mode):
:wq  → write (save) and quit

# To exit WITHOUT saving:
:q!  → force quit, discard changes

# Other useful vim commands (all from NORMAL mode):
dd    → delete (cut) current line
yy    → copy current line
p     → paste
:set number  → show line numbers
/word  → search for "word" in file
u     → undo last action
G     → jump to end of file
gg    → jump to start of file
💡

Stuck in vim? If you accidentally opened vim and can't exit — press Esc then type :q! and press Enter. That gets you out every time.

ℹ️

Which to use? Start every lab with nano. As you get comfortable, switch to vim. Within a few weeks you'll reach for vim naturally — it's faster once the shortcuts are in your fingers.


MODULE 05

Users & Permissions

Create users, assign groups, set who can read, write, or execute files.

Why Users & Permissions Matter

Linux is a multi-user system. Multiple people can log into the same server simultaneously. Permissions control exactly who can read, write, or execute each file. This is the foundation of Linux security — no antivirus needed when access is controlled at the file level.

User Management — Linux vs Windows
TaskLinux CommandWindows
Add a useruseradd ahmedSettings → Accounts → Add user
Set passwordpasswd ahmedSet during account creation or Settings
Delete useruserdel -r ahmedSettings → Accounts → Remove
Create groupgroupadd developersComputer Management → Groups
Add user to groupusermod -aG developers ahmedGroup Properties → Add member
List userscat /etc/passwdSettings → Accounts
Switch usersu - ahmedLog out and log in as other user
Admin accesssudo commandRight-click → Run as administrator
User Management — Commands
# Create a new user
useradd ahmed

# Set or change password
passwd ahmed

# Create user with home directory and specific shell
useradd -m -s /bin/bash ahmed

# Delete user and their home folder
userdel -r ahmed

# Create a group
groupadd developers

# Add user to a group (without removing existing groups)
usermod -aG developers ahmed

# Check which groups a user belongs to
groups ahmed

# Switch to another user
su - ahmed

# Run a command as root without logging in as root
sudo dnf update

File Permissions — How They Work

Every file in Linux has three sets of permissions: one for the owner, one for the group, and one for everyone else. Each set has three options: read (r), write (w), execute (x).

When you run ls -la, you see something like -rwxr-xr--. That breaks down as: owner can read/write/execute, group can read/execute, others can only read.

Permissions — chmod & chown
# See permissions on files
ls -la /etc/nginx/nginx.conf
# Output: -rw-r--r-- 1 root root 2048 Jan 1 nginx.conf
#          ↑↑↑↑↑↑↑↑↑  = permissions | owner | group

# chmod — change permissions
# Numeric method (most common):
# 4=read, 2=write, 1=execute. Add them up:
# 7 = rwx (4+2+1), 6 = rw- (4+2), 5 = r-x (4+1), 4 = r--

chmod 755 script.sh   # owner: rwx | group: r-x | others: r-x
chmod 644 config.txt  # owner: rw- | group: r-- | others: r--
chmod 600 id_rsa      # owner: rw- | group: --- | others: ---  ← SSH keys use this

# chown — change who owns a file
chown ahmed file.txt           # change owner to ahmed
chown ahmed:developers file.txt # change owner + group
chown -R ahmed /var/www/html   # change owner of folder + everything inside
root
The superuser. Like Administrator on Windows but with zero restrictions. Use carefully.
sudo
Run one command as root without being root. Safer than logging in as root.
/etc/passwd
List of all users on the system. Not passwords — those are in /etc/shadow (encrypted).
/etc/group
List of all groups and which users belong to each.
chmod
Change permissions on a file or folder.
chown
Change the owner and group of a file or folder.

MODULE 06

Package Management

Install, update, and remove software with a single command.

What is a Package Manager?

On Windows you install software by downloading an .exe or .msi file from a website, running it, clicking through a wizard, accepting agreements, and hoping it doesn't install toolbars. On Linux, a package manager does all of this with one command — it downloads, installs, and manages dependencies automatically.

Package Management — Linux vs Windows
TaskLinux (RHEL/AlmaLinux)Windows
Install softwarednf install nginxDownload .exe → click through installer
Remove softwarednf remove nginxControl Panel → Uninstall
Update all softwarednf updateWindows Update (often forces restart)
Search for softwarednf search nginxGoogle it, visit website
See installed packagesdnf list installedControl Panel → Programs
DependenciesInstalled automaticallyOften manual or bundled in installer
Source of packagesOfficial repos (verified, safe)Any website — no verification
dnf — RHEL/AlmaLinux/Fedora Package Manager
# Install a package
dnf install nginx -y       # -y means yes to all prompts
dnf install httpd git vim -y  # install multiple at once

# Remove a package
dnf remove nginx -y

# Update everything
dnf update -y

# Update only one package
dnf update nginx -y

# Search for a package
dnf search "web server"

# Get info about a package
dnf info nginx

# List all installed packages
dnf list installed

# Clean cache
dnf clean all
apt — Ubuntu/Debian Package Manager
# Same concept, different command
apt update               # refresh package list (do this first)
apt install nginx -y
apt remove nginx -y
apt upgrade -y           # update all installed packages
apt search nginx
apt show nginx
ℹ️

dnf vs yum: Older RHEL systems used yum. RHEL 8+ uses dnf. Commands are almost identical — dnf is faster and smarter. Both still work.


MODULE 07

Storage & LVM

Add disks, create partitions, mount them, resize live with LVM.

What is LVM?

LVM (Logical Volume Manager) is a layer between your physical disks and the filesystem. Instead of partitioning a disk directly, LVM lets you create flexible "logical volumes" that can be resized on the fly — even while the server is running and files are being accessed. It's how production servers manage storage without downtime.

Storage Management — Linux vs Windows
TaskLinuxWindows
View diskslsblk or fdisk -lDisk Management GUI
Partition a diskfdisk /dev/sdbRight-click → New Simple Volume
Format a partitionmkfs.xfs /dev/sdb1Format → NTFS
Mount a diskmount /dev/sdb1 /dataAutomatic when you plug in
Auto-mount on bootAdd entry to /etc/fstabAutomatic
Resize partition liveYes — with LVM, no downtimeRequires reboot in most cases
Check disk usagedf -h, du -sh /varRight-click drive → Properties
LVM — Create and Manage Logical Volumes
# Step 1: Create a Physical Volume from a disk
pvcreate /dev/sdb

# Step 2: Create a Volume Group (a pool of storage)
vgcreate myvg /dev/sdb

# Step 3: Create a Logical Volume (like a partition, but flexible)
lvcreate -L 10G -n mydata myvg

# Step 4: Format it
mkfs.xfs /dev/myvg/mydata

# Step 5: Create a mount point and mount it
mkdir /data
mount /dev/myvg/mydata /data

# Step 6: Auto-mount on boot — add to /etc/fstab
echo "/dev/myvg/mydata /data xfs defaults 0 0" >> /etc/fstab

# --- Later: Extend the volume (add 5 more GB live) ---
lvextend -L +5G /dev/myvg/mydata
xfs_growfs /data     # resize the filesystem to use new space

# Check disk usage
df -h
lvdisplay

MODULE 08

Processes & Services

See what's running, manage services, read logs.

What is a Process?

Every program running on your system is a process — it has a PID (Process ID), uses CPU and RAM, and is owned by a user. On Windows you see processes in Task Manager. On Linux you use ps, top, or htop.

A service is a process that runs in the background — like nginx serving web pages or sshd listening for SSH connections. Linux uses systemd to start, stop, and monitor services.

Process & Service Management — Linux vs Windows
TaskLinuxWindows
View running processesps aux or topTask Manager (Ctrl+Shift+Esc)
Kill a processkill 1234 or kill -9 1234End Task in Task Manager
Start a servicesystemctl start nginxServices → Start
Stop a servicesystemctl stop nginxServices → Stop
Enable on bootsystemctl enable nginxServices → Startup type: Automatic
Service statussystemctl status nginxServices → check Status column
View logsjournalctl -u nginxEvent Viewer
systemctl — Managing Services
# Start, stop, restart a service
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx    # reload config without full restart

# Enable/disable auto-start on boot
systemctl enable nginx    # start automatically when server boots
systemctl disable nginx

# Check if service is running
systemctl status nginx

# Start AND enable in one command
systemctl enable --now nginx

# List all running services
systemctl list-units --type=service --state=running

# View logs for a service (live)
journalctl -u nginx -f    # -f = follow (like tail -f)

# View last 50 lines of logs
journalctl -u nginx -n 50
Process Management
# See all running processes
ps aux

# Live process monitor (like Task Manager)
top       # basic
htop      # better (install with: dnf install htop -y)

# Find a process by name
ps aux | grep nginx

# Kill a process by PID
kill 1234         # polite kill (asks process to stop)
kill -9 1234      # force kill (process has no choice)

# Kill by name
pkill nginx

MODULE 09

Networking Basics

IPs, interfaces, SSH, firewall — the essentials for managing any Linux server.

How Networking Works on Linux

Every device on a network has an IP address — a unique number that identifies it. Linux manages network interfaces (like your ethernet card or WiFi adapter) through the ip command and NetworkManager. To connect to a remote Linux server, you use SSH — a secure encrypted terminal session over the network.

Networking — Linux vs Windows
TaskLinuxWindows
Check IP addressip addr showipconfig
Set static IPnmcli or edit config fileNetwork adapter properties → TCP/IP
Test connectivityping 8.8.8.8ping 8.8.8.8
DNS lookupdig domain.com or nslookupnslookup or ping domain
Remote accessSSH (ssh user@ip)RDP (Remote Desktop)
Open firewall portfirewall-cmd --add-port=80/tcpWindows Firewall → Allow an app
Check open portsss -tulnpnetstat -an or Resource Monitor
Network Commands
# Check your IP address
ip addr show
ip addr show ens33  # specific interface

# Test connectivity
ping 8.8.8.8        # Google DNS — tests internet access
ping -c 4 8.8.8.8   # stop after 4 packets

# DNS lookup
dig google.com
nslookup google.com

# Set a static IP using nmcli
nmcli con mod "ens33" ipv4.addresses 192.168.1.100/24
nmcli con mod "ens33" ipv4.gateway 192.168.1.1
nmcli con mod "ens33" ipv4.dns 8.8.8.8
nmcli con mod "ens33" ipv4.method manual
nmcli con up "ens33"

# SSH into a remote server
ssh ahmed@192.168.1.50
ssh -i ~/.ssh/id_rsa ahmed@192.168.1.50   # with SSH key

# Firewall — open a port
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-service=http
firewall-cmd --reload

# Check which ports are listening
ss -tulnp

MODULE 10

SELinux Basics

Linux's built-in security layer — what it is and how to work with it.

What is SELinux?

SELinux (Security-Enhanced Linux) is an extra security layer built into the kernel. Even if a process is running as root, SELinux can restrict what it can access. Think of it as a second gate after file permissions — even if you unlock the door, SELinux can still block you.

It's the reason many beginners get "permission denied" on RHEL even when the file permissions look correct. Once you understand SELinux, you stop fighting it and start using it.

SELinux vs Windows Security
ConceptLinux (SELinux)Windows
Extra security layerSELinux — built into kernelWindows Defender + UAC
ControlsWhat every process can access — file, port, networkUAC prompts for admin actions
Default on RHELYes — enforcing mode by defaultAlways on
When it blocksSilently in logs — you see "permission denied"Shows UAC popup
Check what's blockedausearch -m avcEvent Viewer → Security
SELinux — Essential Commands
# Check current SELinux mode
getenforce
# Outputs: Enforcing | Permissive | Disabled

# Enforcing  = actively blocks violations
# Permissive = logs violations but does NOT block (good for troubleshooting)
# Disabled   = completely off (not recommended on production)

# Temporarily set to permissive (resets on reboot)
setenforce 0   # permissive
setenforce 1   # enforcing

# Permanently change mode — edit config file
nano /etc/selinux/config
# Change: SELINUX=enforcing  →  SELINUX=permissive

# Check SELinux context (label) on a file
ls -Z /var/www/html/index.html

# Fix context on web files (common fix for Apache permission denied)
restorecon -Rv /var/www/html/

# Check what SELinux blocked recently
ausearch -m avc -ts recent
💡

Golden rule: If a service works in permissive mode but not in enforcing mode, SELinux is the issue. Run ausearch -m avc -ts recent to see what it blocked, then fix the context or policy — never just disable SELinux on production.


MODULE 11

Web Server — Apache & Nginx

Set up a working web server and host a website from your Linux machine.

What Does a Web Server Do?

A web server is software that waits for HTTP requests (when someone types a URL in a browser) and responds with HTML files, images, or data. Apache and Nginx are the two most common on Linux. Windows uses IIS (Internet Information Services) — same concept, different software.

Apache vs Nginx — When to Use Each
FeatureApacheNginx
Best forTraditional web apps, .htaccessHigh traffic, reverse proxy, static files
Config file/etc/httpd/conf/httpd.conf/etc/nginx/nginx.conf
Default port80 (HTTP), 443 (HTTPS)80 (HTTP), 443 (HTTPS)
Web root/var/www/html//usr/share/nginx/html/
Windows equivalentIIS (Internet Information Services)
Apache — Install and Configure
# Install Apache (called httpd on RHEL)
dnf install httpd -y

# Start and enable on boot
systemctl enable --now httpd

# Open firewall for web traffic
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

# Create a test web page
echo "<h1>Hello from Devriston</h1>" > /var/www/html/index.html

# Fix SELinux context on web files
restorecon -Rv /var/www/html/

# Now visit http://your-ip in a browser

# Check Apache logs
tail -f /var/log/httpd/access_log
tail -f /var/log/httpd/error_log
Nginx — Install and Configure
# Install Nginx
dnf install nginx -y

# Start and enable
systemctl enable --now nginx

# Open firewall
firewall-cmd --permanent --add-service=http
firewall-cmd --reload

# Test config before applying changes
nginx -t

# Reload config without downtime
systemctl reload nginx

# Nginx logs
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log

MODULE 12

DHCP Server

Automatically assign IP addresses to devices on your network.

What is DHCP?

DHCP (Dynamic Host Configuration Protocol) automatically gives IP addresses to devices when they connect to a network. Without DHCP, you'd have to manually set the IP, gateway, and DNS on every single device — every phone, laptop, and printer in an office. DHCP does it automatically. Your home router runs a DHCP server. So does every office network.

DHCP — Linux vs Windows Server
TaskLinux (dhcpd)Windows Server
Installdnf install dhcp-serverServer Manager → Add Role → DHCP
Config file/etc/dhcp/dhcpd.confDHCP Manager GUI
View leasescat /var/lib/dhcpd/dhcpd.leasesDHCP Manager → Address Leases
Restart servicesystemctl restart dhcpdRight-click → Restart
DHCP Server Setup
# Install DHCP server
dnf install dhcp-server -y

# Edit config file
nano /etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd.conf — Example Config
# Global settings
default-lease-time 600;     # lease for 600 seconds (10 min)
max-lease-time 7200;        # max lease 2 hours

# Subnet definition
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;  # IP range to hand out
  option routers 192.168.1.1;          # default gateway
  option domain-name-servers 8.8.8.8, 8.8.4.4;  # DNS servers
  option domain-name "devriston.local";
}
Start DHCP Service
# Enable and start
systemctl enable --now dhcpd

# Open firewall for DHCP
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --reload

# Check active leases
cat /var/lib/dhcpd/dhcpd.leases

MODULE 13

DNS Server

Build your own DNS server with BIND. Translate domain names to IPs.

What is DNS?

DNS (Domain Name System) translates human-readable domain names (like google.com) into IP addresses (like 142.250.80.46) that computers actually use. It's like a phone book for the internet — you look up the name, it gives you the number. Every time you type a URL, a DNS lookup happens before your browser can connect.

DNS — Linux vs Windows Server
ConceptLinux (BIND)Windows Server
SoftwareBIND9 (named)Windows DNS Server role
Config file/etc/named.confDNS Manager GUI
Zone files/var/named/Stored in GUI, exported as text
Forward zonedomain → IP (A records)Same concept in GUI
Reverse zoneIP → domain (PTR records)Same in GUI
Test DNSdig, nslookupnslookup
BIND9 DNS Server Setup
# Install BIND
dnf install bind bind-utils -y

# Edit main config
nano /etc/named.conf
named.conf — Add Zone
# Add inside named.conf:
zone "devriston.local" IN {
    type master;
    file "/var/named/devriston.local.zone";
    allow-update { none; };
};
Zone File — /var/named/devriston.local.zone
$TTL 86400
@   IN  SOA  ns1.devriston.local. admin.devriston.local. (
            2024010101  ; Serial
            3600        ; Refresh
            900         ; Retry
            604800      ; Expire
            86400 )     ; Minimum TTL

; Name servers
@   IN  NS   ns1.devriston.local.

; A Records (name → IP)
ns1     IN  A   192.168.1.10
www     IN  A   192.168.1.20
mail    IN  A   192.168.1.30
Start and Test DNS
# Check config for errors
named-checkconf
named-checkzone devriston.local /var/named/devriston.local.zone

# Start DNS
systemctl enable --now named

# Open firewall
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload

# Test it
dig @192.168.1.10 www.devriston.local
nslookup www.devriston.local 192.168.1.10

MODULE 14

File Sharing — NFS & Samba

Share folders between Linux machines (NFS) and with Windows machines (Samba).

NFS vs Samba — What's the Difference?

NFS (Network File System) shares folders between Linux/Unix machines. Fast and simple but Windows can't access NFS natively. Samba implements the Windows SMB protocol on Linux — so Windows machines see your Linux server as a Windows file share. No special software on the Windows side.

File Sharing — Linux vs Windows
FeatureLinux (Samba)Windows
ProtocolSMB (via Samba)SMB native
Config/etc/samba/smb.confFile Explorer → Share tab
Windows access\\IP\sharename — works natively\\Server\share
User authSamba users (separate from Linux users)Windows users/AD
Installdnf install sambaBuilt in
Samba — Share a Folder with Windows
# Install Samba
dnf install samba samba-client samba-common -y

# Create a shared folder
mkdir -p /srv/shared
chmod 0775 /srv/shared

# Edit Samba config
nano /etc/samba/smb.conf
smb.conf — Add a Share
[shared]
    comment = Devriston File Share
    path = /srv/shared
    browseable = yes
    writable = yes
    valid users = ahmed
Start Samba and Add User
# Add Samba password for a Linux user
smbpasswd -a ahmed

# Enable and start Samba services
systemctl enable --now smb nmb

# Open firewall
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload

# Fix SELinux for Samba
setsebool -P samba_export_all_rw 1

# Test config
testparm

# On Windows: open File Explorer and type:
# \\192.168.1.10\shared

MODULE 15

Security Hardening

SSH keys, firewall rules, fail2ban, and audit logs — production-safe from day one.

Why Harden a Server?

A fresh Linux server on the internet gets attacked within minutes — bots scan for SSH, try default passwords, probe every open port. Hardening means closing every unnecessary door and making the remaining ones require a key, not a password. These steps are standard on every production server.

SSH Key Authentication — Passwordless and Secure
# On your LOCAL machine — generate SSH key pair
ssh-keygen -t ed25519 -C "ahmed@devriston"
# Creates: ~/.ssh/id_ed25519 (private key — never share this)
#          ~/.ssh/id_ed25519.pub (public key — goes on server)

# Copy public key to server
ssh-copy-id ahmed@192.168.1.50
# Now you can SSH without password:
ssh ahmed@192.168.1.50

# On the SERVER — disable password login (after key works!)
nano /etc/ssh/sshd_config
# Change these lines:
PasswordAuthentication no
PermitRootLogin no
Port 2222           # optional: change default port

# Restart SSH
systemctl restart sshd
fail2ban — Block Brute-Force Attacks
# Install fail2ban
dnf install fail2ban -y

# Create local config (don't edit the main file)
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
nano /etc/fail2ban/jail.local

# Set these values:
[sshd]
enabled  = true
maxretry = 3        # ban after 3 failed attempts
bantime  = 3600     # ban for 1 hour
findtime = 600      # count attempts in 10 minute window

# Start fail2ban
systemctl enable --now fail2ban

# Check banned IPs
fail2ban-client status sshd

# Unban an IP
fail2ban-client set sshd unbanip 192.168.1.99
Security — Linux vs Windows
Security FeatureLinuxWindows
Brute-force protectionfail2banAccount lockout policy (Group Policy)
Firewallfirewalld / iptablesWindows Firewall / Defender
Remote access securitySSH keys (no password)Certificate-based RDP or VPN
Audit logsauditd + journalctlEvent Viewer → Security logs
Disable root loginPermitRootLogin no in sshd_configNo direct Administrator login via RDP

MODULE 16

Shell Scripting — Automate It

Write bash scripts that do in seconds what would take you minutes manually.

What is a Shell Script?

A shell script is a text file full of Linux commands that run one after another. Instead of typing 10 commands every morning to check disk space, restart services, and send a report — you write one script and run it. Or schedule it with cron to run automatically at 6am every day. This is the entry point to automation.

Scripting — Bash vs PowerShell (Windows)
FeatureBash (Linux)PowerShell (Windows)
File extension.sh.ps1
Run a scriptbash script.sh or ./script.sh.\script.ps1
Variablesname="Ahmed"$name = "Ahmed"
Output textecho "Hello"Write-Output "Hello"
Available onEvery Linux server on earthWindows (and now Linux via PS Core)
Script 1 — Basic Structure
#!/bin/bash
# The first line (shebang) tells the system to run this with bash

# Variables
NAME="Ahmed"
DATE=$(date +%Y-%m-%d)   # capture command output into variable

# Print
echo "Hello $NAME"
echo "Today is $DATE"

# Conditions
if [ -f "/etc/nginx/nginx.conf" ]; then
    echo "Nginx config exists"
else
    echo "Nginx not installed"
fi

# Loops
for USER in ahmed kamran ali; do
    echo "Creating user: $USER"
    useradd $USER
done
Script 2 — Disk Space Alert
#!/bin/bash
# Alert if any disk is over 80% full

THRESHOLD=80

df -h | grep -vE '^Filesystem|tmpfs' | awk '{ print $5 " " $6 }' | while read USAGE MOUNT; do
    USE=$(echo $USAGE | sed 's/%//')
    if [ "$USE" -gt "$THRESHOLD" ]; then
        echo "WARNING: $MOUNT is at $USAGE"
    fi
done
Cron — Schedule Scripts to Run Automatically
# Open crontab editor
crontab -e

# Cron format: minute hour day month weekday command
# Examples:

# Run disk check every day at 6am
0 6 * * * /home/ahmed/scripts/disk-alert.sh

# Run backup every Sunday at 2am
0 2 * * 0 /home/ahmed/scripts/backup.sh

# Run every 5 minutes
*/5 * * * * /home/ahmed/scripts/check.sh

# List all scheduled cron jobs
crontab -l
💡

Make a script executable: After writing a .sh file, run chmod +x script.sh to make it runnable. Then execute it with ./script.sh.


🐧

Ready to go beyond reading?

The live course includes hands-on labs, Q&A sessions, and a final enterprise project for your GitHub portfolio. Same instructor who wrote these notes.

💬 Enroll via WhatsApp →

Batch info & fee on request