Linux Operating System – Complete DevOps Study Notes
Source: Dev.to
Part 1 – Linux Fundamentals & Architecture
1. What is Linux?
Linux is an open‑source, Unix‑like operating‑system kernel. In a DevOps context “Linux” usually refers to a distribution (e.g., Ubuntu, CentOS, Alpine) that bundles the kernel, system utilities, and a package manager.
| Component | Description |
|---|---|
| Kernel | Core that manages CPU, memory, and I/O |
| Shell | CLI interface to the kernel (e.g., Bash, Zsh) |
| Userspace | Where applications run |
2. Linux File‑System Hierarchy
Linux uses a single hierarchical tree that starts at the root /.
/
├─ bin & /usr/bin – Essential user binaries (ls, cp, …)
├─ etc – Configuration files (e.g., /etc/nginx/nginx.conf)
├─ home – User home directories (e.g., /home/john)
├─ var – Variable data (logs, spool files, temporary e‑mail)
├─ tmp – Temporary files (cleared on reboot)
└─ proc – Virtual FS exposing process & kernel info
Part 2 – Essential File Management & Permissions
1. File‑Management Commands
| Category | Commands |
|---|---|
| Navigation | pwd – print working directory cd – change directory ls -la – list all files with details |
| Manipulation | touch file – create empty file mkdir -p dir/subdir – create directory (parents if needed) cp -r source dest – copy recursively mv source dest – move/rename rm -rf path – force‑remove (use with caution) |
| Viewing | cat file less file head file tail file |
2. File Permissions
Permissions are split into User (u), Group (g), and Others (o).
| Symbol | Value |
|---|---|
| r (read) | 4 |
| w (write) | 2 |
| x (execute) | 1 |
Common commands
chmod 755 file # u=rwx (7), g=rx (5), o=rx (5)
chmod +x script.sh # add execute bit
chown user:group file # change owner & group
chgrp group file # change group only
Part 3 – User, Group, & Package Management
1. User & Group Management
| File | Purpose |
|---|---|
/etc/passwd | User account information |
/etc/shadow | Secure password hashes |
/etc/group | Group definitions |
Typical commands
# Create a user with a home directory and Bash shell
useradd -m -s /bin/bash username
# Add user to the sudo group
usermod -aG sudo username
# Set (or change) password
passwd username
# Show UID/GID information
id username
2. Package Management
| Distro Family | Package Manager | Install Command | Update / Upgrade Command |
|---|---|---|---|
| Debian / Ubuntu | apt | apt install <package> | apt update && apt upgrade |
| RHEL / CentOS | yum / dnf | yum install <package> | yum update |
| Alpine | apk | apk add <package> | apk update |
Part 4 – Networking & Firewall
1. Network Configuration & Troubleshooting
| Command | Description |
|---|---|
ip addr show | Show IP addresses (modern replacement for ifconfig) |
ip route | Display routing table |
ping <host> | Test connectivity |
curl -I <url> | Show HTTP headers |
wget <url> | Download files |
nslookup <domain> / dig <domain> | DNS lookup |
netstat -tulpn or ss -tulpn | List listening ports (useful for debugging services) |
2. Linux Firewalls
| Firewall | Typical Usage |
|---|---|
| UFW (Ubuntu) | Simple wrapper around iptables |
| firewalld (CentOS/RHEL) | Dynamic firewall manager |
| iptables | Legacy, low‑level packet filter |
Examples
# UFW
ufw allow 22/tcp # allow SSH
ufw enable # enable firewall
# firewalld
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
# iptables (basic example)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Part 5 – Processes, Systemd, & Boot
1. The Boot Process
- BIOS/UEFI – hardware POST, loads bootloader.
- Bootloader (GRUB) – loads the kernel image.
- Kernel – mounts the root filesystem, starts
init. - init (systemd) – PID 1, launches user‑space services.
2. Systemd (Service Management)
systemctl start nginx # start now
systemctl enable nginx # start on boot
systemctl status nginx # view status
journalctl -u nginx # view service‑specific logs
3. Monitoring & Troubleshooting
| Tool | Purpose |
|---|---|
top / htop | Real‑time CPU & memory |
df -h | Disk space usage |
du -sh /path | Size of a specific directory |
free -m | Memory summary |
ps aux | grep <process> | Find processes |
kill -9 <pid> | Force‑kill a process |
Part 6 – Shell Scripting (Bash)
Automation is the heart of DevOps.
#!/bin/bash
# -------------------------------------------------
# Example Bash script
# -------------------------------------------------
# Variables
NAME="DevOps Engineer"
DIR="/var/www/html"
# Conditionals
if [ -d "$DIR" ]; then
echo "Directory exists."
else
mkdir -p "$DIR"
echo "Directory created."
fi
# Loops
for i in {1..5}; do
echo "Iteration $i"
done
Key concepts
| Concept | Explanation |
|---|---|
| Exit status | $? – 0 = success, non‑zero = error |
| Arguments | $1, $2, … – positional parameters |
| Redirection | > overwrite, >> append, ` |
Part 7 – SSH Configuration & Security
| File | Purpose |
|---|---|
/etc/ssh/sshd_config | SSH daemon configuration |
Security Best Practices (Hardening)
- Disable root login – set
PermitRootLogin no. - Disable password authentication – set
PasswordAuthentication no. - Change the default port (optional) – e.g.,
Port 2022.
Key‑Based Authentication
# On the client
ssh-keygen -t rsa -b 4096 # generate key pair
ssh-copy-id user@remote-server # copy public key to server
# On the server (verify permissions)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Part 8 – Advanced Concepts & Cloud
1. Web‑Server Administration
| Server | Typical Use | Main Config Location |
|---|---|---|
| Nginx | Reverse proxy / load balancer | /etc/nginx/sites-available/ (linked from sites-enabled) |
| Apache | Traditional web server | /etc/httpd/conf/httpd.conf (RHEL) or /etc/apache2/apache2.conf (Debian) |
Logs are usually found under /var/log/nginx/ or /var/log/httpd/.
2. Reading Access Logs
- File:
/var/log/nginx/access.log - Purpose: Debug 404/500 errors.
3. Linux in the Cloud (AWS / Azure / GCP)
- Cloud‑Init – runs once when a cloud instance boots to install packages and write files.
- Ephemeral Storage – some cloud disks disappear on termination; be aware of their transient nature.
- Metadata Services – query
http://169.254.169.254from within the VM to retrieve instance information (IP, region, etc.).
4. Text Processing (The “Swiss Army Knives”)
DevOps engineers frequently parse logs using these tools:
-
grep– Search for textgrep "error" file.log -
awk– Print specific columnsawk '{print $1}' file.txt -
sed– Find and replace textsed 's/old/new/g' file.txt
Checkout this for advanced study on Linux for DevOps.