← Back to tools

Foundations

Linux Documentation

Linux is the base operating system for most DevOps workloads.

Level: Beginner

What Is Linux?

Linux is a beginner-level DevOps tool used to manage specific parts of software delivery and operations. It helps teams standardize workflows and reduce manual effort.

Why We Use It

Teams use Linux to improve speed, reliability, and consistency. It reduces repetitive manual work, lowers failure risk, and makes collaboration easier across development and operations.

Where It Fits In DevOps

It sits at the base of every DevOps workflow. Without this layer, CI/CD, cloud, and reliability work become slow and error-prone.

From Beginner To End-to-End

1. Foundations

Start with core Linux concepts and basic setup so you can use it safely in day-to-day work.

- Understand Linux fundamentals

- Set up local/dev environment

- Run first working example

2. Team Workflow

Integrate Linux into real team practices with repeatable conventions and collaboration patterns.

- Adopt standards and naming conventions

- Integrate with repositories and CI/CD

- Create reusable templates

3. Production Operations

Use Linux in production with observability, security, and rollback plans.

- Monitor behavior and failures

- Secure access and secrets

- Define incident and rollback flow

4. Scale and Optimization

Continuously improve reliability, performance, and cost while standardizing usage across services.

- Improve performance and cost

- Automate compliance checks

- Document best practices for the team

Key Concepts

- Filesystem

- Permissions

- Processes

Learning Path

- Shell basics

- User and permission management

- Service operations

Real Use Cases

- Local and remote server operations

- Code collaboration workflows

- Task automation in build and deploy scripts

Beginner Learning Plan

- Read the Linux basics and terminology

- Run at least one hands-on mini project

- Break and fix a small setup to build confidence

- Document your first repeatable workflow

Advanced / Production Plan

- Integrate Linux with your full delivery pipeline

- Add security and policy checks

- Add observability and incident playbooks

- Define reusable standards for multiple services

Common Mistakes

- Using defaults in production without security hardening

- Skipping monitoring and post-deployment validation

- No rollback strategy for failed changes

- Over-complex setup before mastering fundamentals

Production Readiness Checklist

- Access control and least privilege applied

- Secrets managed securely

- Monitoring and alerting enabled

- Rollback and recovery process tested

- Documentation updated for team onboarding

Installation Guide

Install Linux on host with practical commands and verification steps.

Ubuntu/Debian base update

sudo apt update && sudo apt upgrade -y

Install common Linux admin packages

sudo apt install -y curl wget git vim htop net-tools unzip zip

Verify Linux kernel and distro

uname -a
cat /etc/os-release

Quick Start

Check OS details

uname -a

List files

ls -la

Find current path

pwd

Common Commands

Simple command list with short descriptions.

uname -a

Kernel + OS information (fast environment check).

whoami

Show the current user (helps with permission issues).

pwd

Print current working directory.

ls -lah

List files with human sizes + hidden files.

cd -

Jump back to previous directory.

tree -L 2

Show folder tree up to depth 2 (install `tree` if missing).

cat file.txt

Print a file.

less file.txt

Read large files safely (search with `/`).

head -n 50 file.txt

Show first N lines.

tail -n 50 file.txt

Show last N lines.

tail -f /var/log/syslog

Follow logs live (Debian/Ubuntu).

grep -R "needle" .

Recursive text search in current folder.

rg "needle" .

Fast recursive search (ripgrep).

find . -type f -name "*.log"

Find files by pattern.

chmod 644 file.txt

Set permissions (rw-r--r--) for a file.

chmod -R u+rwX,go-rwx secret_dir

Make dir private for owner.

chown -R user:group /path

Change ownership recursively.

id

Show uid/gid and groups for current user.

ps aux | head

List processes (classic view).

top

Interactive process viewer (CPU/mem).

free -h

Memory usage summary.

df -h

Disk usage by filesystem.

du -sh * | sort -h

Find large folders/files in current directory.

ss -lntp

Show listening TCP ports and processes.

curl -I https://example.com

Fetch HTTP headers (quick health check).

dig example.com

DNS lookup.

systemctl status nginx

Check service status (systemd).

systemctl restart nginx

Restart a service.

journalctl -u nginx -n 200 --no-pager

Show last logs for a systemd unit.

sudo -l

Show allowed sudo commands (permission debugging).

Reference

Official documentation:

https://www.kernel.org/doc/html/latest/

Complete Guide

A full, structured guide for this tool (with commands, diagrams, best practices, and learning path).

Linux Documentation (Beginner to Advanced)

How to Use This Guide

This page is written like a tutorial handbook. Each tutorial includes:

  • What you should learn
  • Commands you can run right now
  • Exercises (practice tasks)
  • “What to check when it fails” notes

If you are new to Linux, do Tutorials 1 to 4 first. If you are already comfortable with the terminal, jump to Tutorials 6 to 10 and the Advanced Topics.

Quick Setup

Use any Linux machine:

  • Your laptop (Linux)
  • A VM (VirtualBox, VMware)
  • Cloud VM (Azure, AWS, GCP)
  • WSL on Windows

Create a safe practice folder:

mkdir -p ~/linux-labs/{files,logs,scripts}
cd ~/linux-labs

If you break something, delete the lab folder and start fresh:

rm -rf ~/linux-labs

Tutorial 1: Navigating the Filesystem

What you learn

  • Where you are (pwd)
  • What is around you (ls)
  • How to move (cd)
  • How paths work (. and ..)

Commands

Show your current directory:

pwd

List files:

ls
ls -la
ls -lh

Move around:

cd ~
cd /tmp
cd -

Concepts (in simple words)

  • A path like /var/log is an absolute path.
  • A path like ../logs is a relative path.
  • . means “this directory”.
  • .. means “parent directory”.

Exercises

  1. Create a folder ~/linux-labs/files/tutorial-1.
  2. Create another folder inside it called backups.
  3. Move into backups, then return back to your home directory without typing the full path.

Tutorial 2: Creating, Viewing, and Editing Files

What you learn

  • Create files quickly
  • Read files fast
  • Search in files
  • Redirection and pipes (the Linux superpower)

Commands

Create files and directories:

cd ~/linux-labs/files
mkdir -p tutorial-2
cd tutorial-2
touch notes.txt

Write to a file:

echo "hello linux" > notes.txt
echo "second line" >> notes.txt

Read a file:

cat notes.txt
nl -ba notes.txt

Preview a large file:

less /etc/services

Search inside files:

grep -n "ssh" /etc/services | head

Pipes:

ps aux | head
ps aux | grep -i ssh

Exercises

  1. Create a file todo.txt with 10 lines.
  2. Find lines that contain the word learn (case-insensitive).
  3. Count how many lines are in the file.

Useful commands:

wc -l todo.txt
grep -ni "learn" todo.txt

Tutorial 3: Permissions and Ownership

What you learn

  • Read (r), write (w), execute (x)
  • User / group / others
  • Why “permission denied” happens

Commands

See permissions:

ls -l

Change permissions:

chmod 644 notes.txt
chmod 755 .

Change ownership (requires sudo):

sudo chown $USER:$USER notes.txt

Quick mental model

  • Files need r to read, w to edit, and x to run as a program.
  • Folders need x to enter (cd) and access files inside.

Exercises

  1. Create a script called hello.sh.
  2. Try to run it and observe the error.
  3. Make it executable and run it again.
cat > hello.sh <<'SH'
#!/usr/bin/env bash
echo "hello from a script"
SH

./hello.sh
chmod +x hello.sh
./hello.sh

Tutorial 4: Processes and Signals

What you learn

  • What a process is
  • How to inspect CPU/RAM usage
  • How to stop a program safely

Commands

List processes:

ps aux | head

Interactive view:

top

Find a process:

ps aux | grep -i node

Send a signal:

kill -TERM <pid>
kill -KILL <pid>

Notes

  • TERM is “please stop gracefully”.
  • KILL is “stop now” (use only when needed).

Exercise

  1. Run sleep 9999 in one terminal.
  2. Find its PID.
  3. Stop it using kill -TERM.

Tutorial 5: Packages and Updates

Different Linux distributions use different package managers.

Debian/Ubuntu (apt)

sudo apt update
sudo apt install -y curl jq
sudo apt upgrade -y

RHEL/CentOS/Fedora (dnf/yum)

sudo dnf install -y curl jq

Why this matters in DevOps

  • Your CI/CD runners install dependencies.
  • Your servers need security updates.
  • You must know how to install troubleshooting tools fast.

Tutorial 6: Networking Fundamentals

What you learn

  • IP and routes (basic)
  • DNS and name resolution
  • Ports and listening services

Commands

Check network interfaces:

ip a

Check routes:

ip route

DNS lookup:

getent hosts devopslabx.com

Check listening ports:

ss -lntp | head

Test HTTP:

curl -I https://devopslabx.com

Exercise

  1. Find which process is listening on port 3000 (if your Next.js app is running).
  2. Confirm you can reach it locally.
ss -lntp | grep ':3000' || true
curl -I http://localhost:3000 || true

Tutorial 7: Logs and Troubleshooting

What you learn

  • Where logs live (/var/log)
  • How to follow logs live
  • How to filter noise fast

Commands

Common system logs:

ls -la /var/log | head

Follow a log:

tail -f /var/log/syslog 2>/dev/null || true
tail -f /var/log/messages 2>/dev/null || true

Systemd journal:

journalctl -n 100 --no-pager
journalctl -u ssh --since "1 hour ago" --no-pager

Troubleshooting checklist

  • What changed last?
  • What errors appear in logs around the time of failure?
  • Is disk full? Is memory exhausted?
  • Is the service listening on the expected port?
  • Is DNS resolving correctly?

Tutorial 8: Users, Groups, and SSH

Commands

Who am I:

whoami
id
groups

Create a user (admin-only):

sudo useradd -m -s /bin/bash demo-user
sudo passwd demo-user

SSH basics:

ssh user@server-ip

Generate an SSH key:

ssh-keygen -t ed25519 -C "devopslabx"

Tutorial 9: Services with systemd

What you learn

  • Start/stop services
  • Enable on boot
  • Read service logs

Commands

systemctl status ssh
sudo systemctl restart ssh
sudo systemctl enable ssh
journalctl -u ssh --no-pager -n 200

Exercise (safe)

Create a simple service that prints a timestamp to a log every 10 seconds:

cat > ~/linux-labs/scripts/tick.sh <<'SH'
#!/usr/bin/env bash
while true; do
  date -Is
  sleep 10
done
SH
chmod +x ~/linux-labs/scripts/tick.sh

You can later run it under a service unit, but only do that after you understand permissions and paths.

Tutorial 10: Shell Scripting

What you learn

  • Variables, loops, functions
  • Defensive scripting
  • Writing scripts you can reuse in DevOps work

A practical script: “is my port open?”

cat > ~/linux-labs/scripts/check_port.sh <<'SH'
#!/usr/bin/env bash
set -euo pipefail

host="${1:-localhost}"
port="${2:-3000}"

if command -v nc >/dev/null 2>&1; then
  nc -zv "$host" "$port"
else
  echo "nc not installed. Try: sudo apt install -y netcat-openbsd"
  exit 2
fi
SH

chmod +x ~/linux-labs/scripts/check_port.sh
~/linux-labs/scripts/check_port.sh localhost 3000

Scripting rules (production-friendly)

  • Always use set -euo pipefail for safer scripts.
  • Validate inputs.
  • Print meaningful errors.
  • Prefer predictable output (easy for CI/CD to parse).

Tutorial 11: Storage, Disks, and Mounts

What you learn

  • How to read disk usage and avoid “disk full” outages
  • What devices and partitions look like
  • What a mount is and why it matters

Commands

Disk usage (what is full?):

df -h

Big folders (what is consuming space?):

du -sh /var/* 2>/dev/null | sort -h | tail

List block devices:

lsblk

See mounts:

mount | head

Exercises

  1. Find your top 5 biggest folders in /var.
  2. Explain the difference between “disk full” and “inode full”.

Useful inode command:

df -ih

Tutorial 12: Security Baseline (SSH + Firewall)

What you learn

  • How attackers typically enter: weak SSH and open ports
  • How to set safe defaults without locking yourself out

SSH checks

sudo sshd -T | head
sudo cat /etc/ssh/sshd_config | sed -n '1,120p'

Firewall basics (Ubuntu: ufw)

sudo ufw status verbose || true

Allow SSH first (important), then enable:

sudo ufw allow OpenSSH
sudo ufw enable

Exercises

  1. List which ports are currently listening.
  2. Decide which ports should be public and which should be private.
ss -lntp

Tutorial 13: Scheduling with cron

What you learn

  • How scheduled tasks work (automation, backups, cleanup)
  • How to avoid cron scripts that fail silently

Commands

Edit your user crontab:

crontab -e

List your cron jobs:

crontab -l

Example: run every day at 2:15 AM (log output):

15 2 * * * /home/<user>/linux-labs/scripts/backup.sh >> /home/<user>/linux-labs/logs/backup.log 2>&1

Exercises

  1. Create a cron job that writes a timestamp to a log every minute.
  2. Confirm the log grows and does not fill disk.

Tutorial 14: Troubleshooting Playbooks

Playbook A: “Service is down”

  1. Is it running?
ps aux | grep -i <service-name> | head
  1. Is it listening on the expected port?
ss -lntp | grep ':<port>' || true
  1. What do logs say?
journalctl -u <service-name> --no-pager -n 200
  1. Is disk full or memory exhausted?
df -h
free -m

Playbook B: “Server is slow”

top
uptime
free -m
df -h

Interpretation tips:

  • Load average very high + CPU low can mean IO wait.
  • Free memory low is fine if cache is high, but OOM events are not.
  • Disk at 100% will break logs, deployments, and databases.

Tutorial 15: Linux Internals for DevOps (Namespaces and cgroups)

This is the mental model behind containers.

Namespaces (isolation)

  • PID namespace: processes look different inside/outside
  • NET namespace: network interfaces differ
  • MNT namespace: filesystem mounts differ

cgroups (resource limits)

  • CPU limits
  • memory limits
  • IO limits

Why this matters

When a container “works locally” but fails in production, the real cause is often:

  • wrong filesystem path or missing mount
  • wrong network/DNS route
  • resource limits causing OOM kill

Architecture Diagram

A real, visual mental model of how Linux fits into a typical workflow.

Fundamental Architecture of Linux

User ApplicationsGNU C Library (glibc)System Call InterfaceKernelArchitecture-Dependent Kernel CodeHardware PlatformUser SpaceKernel SpaceGNU/Linux

Layered view: user space calls into the kernel through the system call interface, running on hardware.

Reference Architecture (Production)

A production-oriented view: guardrails, checks, and the parts that matter when it breaks.

Production Reference Flow

TerminalcommandsOSservicesFiles/etc /varProcessesps/topNetworkdns/portsLinuxrepeatable operations

This diagram is a practical mental model, not vendor-specific.

Key Concepts

  • Filesystem hierarchy: /etc config, /var variable data, /home user data.
  • Processes: everything running has a PID and a parent.
  • Permissions: most outages are “file/port/permission/ownership” issues.
  • Networking: DNS, routing, firewalls, ports.
  • Observability: logs and metrics are your truth in production.

Common Commands (Cheat Sheet)

Filesystem and navigation:

pwd
ls -la
cd /path
du -sh *
df -h

Search and text:

grep -Rni "pattern" .
find . -type f -name "*.log"

Processes:

ps aux | head
top
kill -TERM <pid>

Networking:

ip a
ip route
ss -lntp
curl -I https://example.com

System services:

systemctl status <service>
journalctl -u <service> --no-pager -n 200

Hands-on Labs

Lab 1: “Find why my app is down”

Scenario: You expect a service on http://localhost:3000 but it is failing.

Checklist:

  1. Is the port listening?
  2. Is the process running?
  3. What do logs say?
  4. Is the disk full?

Commands:

ss -lntp | grep ':3000' || true
ps aux | grep -i node | head
df -h

Lab 2: “Permission denied” debugging

  1. Create a file.
  2. Remove write permissions.
  3. Try editing it, then fix permissions.
cd ~/linux-labs/files
echo "secret" > locked.txt
chmod 444 locked.txt
echo "try" >> locked.txt || true
chmod 644 locked.txt
echo "fixed" >> locked.txt

Advanced Topics

1. Filesystems and mounts

  • mount shows what is attached.
  • fstab defines persistent mounts (be careful).
mount | head
cat /etc/fstab

2. SSH hardening basics

  • Disable password auth (use keys)
  • Restrict users
  • Use fail2ban (optional)

3. Performance basics

  • CPU: top, mpstat
  • Memory: free -m, vmstat
  • Disk: iostat, df, du

4. Production habits

  • Write runbooks.
  • Automate repeated checks.
  • Keep changes small and reversible.
  • Always know how to roll back.

FAQ

Do I need to learn Linux if I want DevOps?

Yes. Most infrastructure, containers, CI runners, and servers are Linux-based. Linux makes everything else easier.

What should I learn after Linux basics?

Git, CI/CD, Docker, Kubernetes, Terraform, and monitoring. Linux is the foundation that makes these tools feel “logical”.

Extended Documentation

Extra long-form notes for Linux. This loads on demand so the page stays fast.