DevOps & Tools
Operate Linux from the command line: files, text tools, processes, systemd, storage, networking and scripting.
A practical path for developers and aspiring sysadmins who need to be comfortable on a Linux server. It moves from navigating the filesystem and editing files through text processing, processes, users, systemd, packages, disks, boot and networking, and ends with shell scripting, troubleshooting and the kernel features behind containers. Each subject links the official documentation or the relevant man page.
The subjects follow the roadmap.sh Linux roadmap.
Everything on a Linux box is reached through a single directory tree, and the shell is how you move around it. Get fluent with pwd, cd, ls -la and relative versus absolute paths before anything else — every later topic assumes it.
pwd prints where you are, cd changes directory (cd - jumps back, cd ~ goes home), and ls -lah lists files with sizes, owners and hidden dotfiles.
mv src dest renames or relocates files and whole directories in one step. Use mv -i to be asked before overwriting and mv -n to never clobber an existing target.
touch creates empty files, mkdir -p builds nested directories, rmdir removes empty ones and rm -r removes trees. There is no recycle bin — double-check globs before rm -rf.
The Filesystem Hierarchy Standard explains where things live: binaries in /usr/bin, config in /etc, variable data and logs in /var, user homes in /home, and virtual kernel views in /proc and /sys.
Servers rarely have a GUI, so you edit config files in a terminal editor. Know at least one well and the basics of the other, because whichever is installed on a rescue system is the one you will use.
A modal editor present on almost every system. Learn i to insert, Esc to return to normal mode, :w to save, :q! to quit without saving, and /pattern to search; vimtutor teaches the rest in half an hour.
A simple modeless editor with its shortcuts shown at the bottom of the screen: Ctrl+O writes, Ctrl+X exits, Ctrl+W searches. A good default for quick config tweaks.
The shell finds programs, passes them environment and arguments, and wires their input and output together. Understanding how it resolves commands and how streams flow makes the rest of the command line predictable.
The shell searches the directories in $PATH from left to right for a command name. type cmd or command -v cmd shows what will actually run — an alias, a builtin, or a binary on disk.
Key/value pairs inherited by child processes. export NAME=value sets one for the session, env lists them, and persistent ones go in ~/.bashrc or ~/.profile depending on whether the shell is a login shell.
man cmd opens the manual page, man -k word searches them, cmd --help gives a quick summary, and help documents Bash builtins. tldr is a handy community cheat-sheet add-on.
> writes a command's output to a file, >> appends, < feeds a file as input, and 2>&1 merges errors into output. Order matters: cmd > out 2>&1 captures both, cmd 2>&1 > out does not.
Root (UID 0) bypasses permission checks. Use sudo cmd for one-off elevated commands rather than logging in as root; the allowed commands live in /etc/sudoers, edited only with visudo.
Every process starts with three file descriptors: 0 for input, 1 for normal output, 2 for errors. Keeping errors on a separate stream is what lets you pipe data onward while still seeing failures.
The | operator connects one command's stdout to the next command's stdin, so small tools compose into pipelines. set -o pipefail makes a script notice failures in the middle of a pipeline.
Copies its input both to stdout and to files, so you can save a pipeline's output while still watching it. sudo tee /etc/file is the usual trick for writing root-owned files from a pipe.
Day-to-day file handling: who may read or change a file, how to copy and rename safely, how links point at data, and how to bundle and shrink files for transfer or backup.
Each file has read/write/execute bits for owner, group and others, shown by ls -l. Change them with chmod (chmod 640 file or chmod u+x script) and ownership with chown user:group; umask sets defaults for new files.
tar bundles many files into one archive and can compress on the fly: tar -czf out.tar.gz dir/ creates, tar -xzf extracts, tar -tf lists. gzip, xz and zstd compress single files with different speed/ratio trade-offs.
cp -r copies directories, cp -a preserves permissions, timestamps and links (what you want for backups). Renaming is just mv; for bulk renames use a loop or the rename utility.
A hard link is another name for the same inode and survives deletion of the original; a symbolic link (ln -s target name) stores a path and breaks if the target moves. Hard links cannot cross filesystems or point to directories.
Logs, configs and command output are all text, and Unix ships a toolbox of small filters to slice it. Chained with pipes, these commands answer most ad-hoc questions about a system without writing a script.
Extracts columns from each line: cut -d: -f1 /etc/passwd prints usernames, cut -c1-10 takes characters. It only handles single-character delimiters, so reach for awk when fields are separated by runs of spaces.
Joins files side by side, line by line, separated by tabs (-d changes the separator). paste -sd, file collapses a whole column into one comma-separated line.
Orders lines alphabetically by default; -n for numbers, -h for human sizes like 2G, -r to reverse, -k2 to sort by a field and -u to drop duplicates. Locale settings affect ordering, so set LC_ALL=C for byte order.
Prints the first lines of a file or stream — 10 by default, -n 50 for more, or -n -5 for everything except the last five. Handy for peeking at large files without opening them.
Prints the last lines of a file; tail -f follows it as it grows, which is the classic way to watch a log live. tail -n +2 skips a header line.
Translates or deletes characters from stdin: tr a-z A-Z upper-cases, tr -d '\r' strips Windows line endings, tr -s ' ' squeezes repeated spaces.
Merges two files on a common field, like a database join on text. Both inputs must be sorted on that field first, or the output silently misses rows.
Breaks a large file into pieces by line count (-l) or size (-b 100M), producing xaa, xab and so on. Rejoin them with cat x* > whole.
Numbers the lines of a file. By default it skips blank lines; nl -ba numbers every line, which is useful when citing line numbers from a config.
Counts lines (-l), words (-w) and bytes (-c). grep pattern file | wc -l is the quick way to count matches.
Converts tab characters into spaces, aligned to tab stops of 8 by default (-t 4 to change). Useful before tools that assume space-aligned columns.
The reverse of expand: turns runs of spaces back into tabs. Without -a it only converts leading indentation.
Collapses adjacent duplicate lines, so it is almost always used after sort. sort | uniq -c | sort -rn gives a frequency table — great for finding the noisiest IPs in a log.
Searches text for lines matching a regular expression. Key flags: -i ignore case, -v invert, -r recurse into directories, -n show line numbers, -E extended regex, -o print only the match.
A small language for field-based text processing. awk '{print $1}' prints the first whitespace-separated column, and patterns plus BEGIN/END blocks let you filter rows and sum values in one line.
The first five minutes on an unfamiliar or misbehaving server: how loaded it is, who has logged in, what is running, and whether memory or disk is about to run out.
uptime shows how long the machine has run and the 1, 5 and 15-minute load averages — the number of tasks running or waiting. Compare load to the CPU count from nproc; top or htop show who is responsible.
Login attempts, sudo use and SSH sessions are logged to /var/log/auth.log (Debian/Ubuntu), /var/log/secure (RHEL) or the journal. last and lastb list successful and failed logins.
systemctl list-units --type=service --state=running lists active services, and ss -tulpn shows which processes are listening on which ports — together they reveal what a box actually does.
free -h shows memory; read the "available" column, since Linux uses spare RAM for cache. df -h shows free space per filesystem and du -sh * finds what is eating it.
Every running program is a process with a PID, a parent, an owner and a priority. Knowing how to find, signal, prioritise and background processes is the core of keeping a system responsive.
Append & to start a job in the background, Ctrl+Z suspends the foreground job, and bg, fg and jobs manage them. Use nohup or a terminal multiplexer so jobs survive logging out.
ps aux lists every process, ps -ef --forest shows the tree, and pgrep -a name finds PIDs by name. top/htop give a live view sorted by CPU or memory.
Signals are asynchronous notifications: SIGTERM (15) asks a process to exit cleanly, SIGKILL (9) cannot be caught, SIGHUP often means "reload config", and SIGINT is what Ctrl+C sends.
kill PID sends SIGTERM; escalate to kill -9 only if it refuses to die, since it skips cleanup. pkill and killall target processes by name — check the match with pgrep first.
The niceness value (-20 highest to 19 lowest) influences CPU scheduling. Start a job gently with nice -n 10 cmd or adjust a running one with renice; ionice does the same for disk I/O.
New processes are created by fork(), which clones the parent, usually followed by exec() to load a new program. This is why every process has a parent PID and why orphaned children get adopted by PID 1.
Linux is multi-user: accounts and groups decide who owns files and who can run what. Managing them well is basic security hygiene on any shared or internet-facing machine.
useradd -m -s /bin/bash name (or Debian's friendlier adduser) creates an account, usermod changes it, userdel -r removes it with its home, and passwd sets or locks the password.
Accounts live in /etc/passwd, password hashes in /etc/shadow, and groups in /etc/group. id user shows UID, GID and supplementary groups; usermod -aG group user adds a group without dropping existing ones.
Beyond basic mode bits: shared group directories with the setgid bit, the sticky bit on /tmp, ACLs via setfacl/getfacl for per-user grants, and sudoers rules for delegated admin rights.
systemd is the init system on nearly every mainstream distribution: it starts services at boot, restarts them on failure, and collects their logs in the journal. systemctl and journalctl are the two commands you will use constantly.
systemctl status name shows whether a unit is active, its main PID, memory use and the last log lines. systemctl --failed lists everything that crashed.
systemctl start|stop|restart|reload name controls a service now; enable/disable controls whether it starts at boot. enable --now does both in one go.
journalctl -u name shows a unit's logs, -f follows them, -b limits to the current boot and --since "1 hour ago" narrows the window.
Write a unit file in /etc/systemd/system/app.service with [Unit], [Service] (ExecStart, User, Restart=on-failure) and [Install] sections, then run systemctl daemon-reload and enable --now.
Distributions ship software as packages with dependency metadata, installed from signed repositories. Debian and Ubuntu use apt/dpkg; Fedora and RHEL use dnf/rpm. The concepts transfer even when the commands differ.
Servers hosting packages plus signed index files. On Debian-family systems they are listed in /etc/apt/sources.list.d/, on RHEL-family in /etc/yum.repos.d/. Only add third-party repos you trust — they get root on install.
Refresh indexes with apt update, search with apt search or dnf search, inspect with apt show, then install with apt install pkg or dnf install pkg.
apt list --installed or dpkg -l on Debian, dnf list installed or rpm -qa on RHEL. dpkg -S /path and rpm -qf /path tell you which package owns a file.
apt upgrade updates installed packages, apt remove uninstalls (purge also deletes config), and apt autoremove clears unneeded dependencies. Enable unattended security updates on servers.
Canonical's self-contained package format that bundles dependencies, updates automatically and runs confined. Convenient for desktop apps, but packages are larger and auto-refresh can surprise you on servers.
Block devices get partitioned, formatted with a filesystem and mounted into the directory tree. Understanding this stack is what lets you add storage, grow volumes and recover from a full disk.
An inode stores a file's metadata and data block pointers — everything except its name. Filesystems have a fixed number on ext4, so millions of tiny files can exhaust them while space remains; check with df -i.
ext4 is the safe default, XFS suits large files and is RHEL's default, Btrfs adds snapshots and checksums. Create one with mkfs.ext4 /dev/sdX1 and check it with fsck while unmounted.
mount /dev/sdb1 /data attaches a filesystem to a directory; findmnt shows what is mounted where. Permanent mounts go in /etc/fstab — use UUIDs and the nofail option so a missing disk does not block boot.
Find the new device with lsblk, partition it with fdisk or parted (GPT for anything modern), format it, create a mount point and add an fstab entry. blkid prints the UUID you need.
Disk space the kernel can page memory out to under pressure. Create a swap file with fallocate, mkswap and swapon; vm.swappiness tunes how eagerly it is used. Heavy swapping means you need more RAM.
The Logical Volume Manager pools physical volumes into volume groups and carves flexible logical volumes from them, so you can grow a filesystem online with lvextend -r or take snapshots.
Firmware (UEFI or BIOS) hands off to a boot loader, which loads the kernel and initramfs, which mounts the root filesystem and starts systemd as PID 1. Knowing each stage tells you where to look when a machine will not come up.
journalctl -b shows the current boot, -b -1 the previous one (needs persistent journal storage), and dmesg prints kernel messages about hardware and drivers. systemd-analyze blame shows which units slowed boot.
GRUB 2 is the common choice; edit /etc/default/grub and regenerate its config rather than editing grub.cfg by hand. systemd-boot is a simpler UEFI-only alternative. Kernel command-line parameters are set here.
Most Linux machines are servers on a network, so you need the model underneath (addresses, routes, names) and the tools to inspect and control it: ip, ss, dig, ssh and the firewall.
The layered model: link (Ethernet), internet (IP), transport (TCP for reliable streams, UDP for datagrams) and application protocols. Ports identify services on a host; ss -tan shows connection states.
CIDR notation like 10.0.1.0/24 splits an address into network and host parts. Being able to work out ranges, broadcast addresses and whether two hosts share a subnet is essential for routing and firewall rules.
On a local segment frames are delivered by MAC address; ARP maps an IPv4 address to a MAC, and ip neigh shows the cache. RARP did the reverse and is obsolete, replaced by DHCP.
Hands out IP addresses, gateways and DNS servers automatically via a lease. Clients are typically NetworkManager or systemd-networkd; servers need static addresses or DHCP reservations.
The kernel picks an outgoing interface and next hop from the routing table: ip route shows it, ip route get 1.1.1.1 explains a single decision. The default route sends everything not matched elsewhere to the gateway.
Names are resolved via /etc/hosts and the servers in /etc/resolv.conf (often systemd-resolved's stub). dig name and resolvectl query show exactly what answer comes back and from where.
The kernel packet-filtering framework behind firewalls. Modern systems configure it with nft (nftables); iptables still exists, often as a compatibility layer, and front ends like ufw and firewalld sit on top.
Encrypted remote login and command execution. Use key pairs (ssh-keygen -t ed25519, ssh-copy-id), disable password and root login in sshd_config, and keep host aliases in ~/.ssh/config.
scp copies files over SSH, sftp gives an interactive session, and rsync -avz syncs only what changed and can resume — the best choice for anything large or repeated.
Bash scripts automate the commands you would otherwise type. Start every script with #!/usr/bin/env bash and set -euo pipefail, quote your variables, and keep anything complex in a real language.
Single quotes keep text exactly as written, double quotes still expand $vars and $(commands), and $'...' interprets escapes like \n. Getting quoting right prevents most word-splitting bugs.
Assign with name=value (no spaces) and read with "$name". Parameter expansion gives defaults (${x:-def}), substring removal (${f%.txt}) and length (${#s}); local scopes variables inside functions.
for f in *.log; do ...; done iterates over words or globs, while read -r line; do ...; done < file reads line by line, and break/continue control flow.
if runs a command and branches on its exit status. [[ ... ]] tests strings, files (-f, -d) and patterns; (( ... )) does arithmetic comparison; case matches globs cleanly.
bash -x script or set -x prints each command after expansion; set -e stops at the first failure and trap '...' ERR reports where. Run ShellCheck to catch quoting and portability mistakes before they bite.
When something cannot reach something else, work up the stack: is the host up, is the route there, is the port open, and what packets actually cross the wire. These tools answer each question in turn.
The control protocol IP uses for error reports and diagnostics — echo request/reply, "destination unreachable", "time exceeded". Blocking all ICMP breaks path-MTU discovery, so filter it selectively.
Sends ICMP echo requests to test reachability and round-trip time. ping -c 4 host stops after four; a failed ping does not prove the host is down, as many networks drop ICMP.
Reveals each router hop by sending packets with increasing TTL. mtr combines it with ping for a live per-hop loss view, which is the clearest way to show where a path degrades.
The legacy tool for sockets, routes and interface stats from net-tools. On modern systems use ss -tulpn for listening ports and ip for routes; you will still meet netstat in older docs and boxes.
tcpdump -i eth0 port 443 -w cap.pcap captures traffic with BPF filters; open the file in Wireshark to follow streams and decode protocols. It settles arguments about whether packets really arrive.
Containers are ordinary Linux processes isolated with namespaces and limited with cgroups — not virtual machines. Understanding those kernel features explains container behaviour, limits and security far better than any tool tutorial.
Per-process resource caps such as open files (nofile) and processes (nproc). ulimit -n shows the current soft limit; persistent limits go in /etc/security/limits.conf or a systemd unit's LimitNOFILE=.
Control groups account for and limit CPU, memory, I/O and PIDs for groups of processes. cgroup v2 offers a single unified hierarchy under /sys/fs/cgroup; systemd and container runtimes both build on it.
Low-level runtimes like runc create namespaces and cgroups from an OCI bundle; higher-level ones such as containerd and CRI-O pull images and manage lifecycles for Docker and Kubernetes.
The most popular toolchain for building images from a Dockerfile and running containers. Learn docker run, volumes, port publishing and docker compose; Podman offers a daemonless, rootless alternative with a compatible CLI.