DevOps.Academy
CoursesCurriculumInterview prepPricing
◔My learningSign in
DevOps.Academy

Free, hands-on DevOps lessons. Made with care in India.

System status

Learn

All coursesLinux roadmapCurriculumInterview questionsCheat sheetsMy learning

Academy

PricingCertificates

Legal

PrivacyTermsContact

devops.rajeev.pro

Linux & Bash for DevOps · revision

Linux & Bash cheat sheet

Recall first: read each stage's one-line summary and try to remember its commands. Then open the stage to check yourself.

16 stages32 commands

01Navigation basicsStart by orienting yourself: identify the current directory, read the prompt, then inspect the filesystem. Absolute paths start at /; relative paths start where you are.
  • pwd

    Show the current working directory

  • ls -l /etc/hostname

    Inspect a known file without opening a graphical editor

Remember

  • /etc holds system configuration; don't guess where a file lives.
  • Use --help for a quick command reference before reaching for a full manual.

Watch for A relative path changes meaning when you change directories; check pwd first.

Open the lesson: The shell and the filesystem →
02Editing filesServer configuration is text, so learn one terminal editor well. Back up a live config, edit it, validate it, and keep a way to restore the previous version.
  • nano -l notes.txt

    Open a file in nano with line numbers

  • vim app.conf

    Open a configuration file in vim

Remember

  • Vim opens in Normal mode; press i to insert text and Esc to return to commands.
  • A backup plus a config check makes a live edit reversible.

Watch for In vim, typing while still in Normal mode runs editor commands instead of inserting text.

Open the lesson: Editing files: nano, vim, and changing a server safely →
03Shell basicsThe shell resolves commands through builtins and PATH, expands variables and patterns, and connects stdin, stdout and stderr. Know which account and shell context a command uses.
  • type cd

    Check whether a command is a shell builtin or external program

  • man 5 crontab

    Open the manual for the crontab file format

Remember

  • > replaces a file; >> appends to it.
  • 2> redirects errors; a pipe passes stdout to the next command.

Watch for cd is a shell builtin, so looking for a separate cd executable misses the point.

Open the lesson: Shell basics: PATH, variables, streams and sudo →
04Working with filesFile operations are also permission and path operations. Read owner, group and mode before changing access; use archives and links deliberately when preparing deployments.
  • chmod 640 app.env

    Give the owner read/write and the group read access

  • ls -l deploy.sh

    Inspect a file's mode and ownership before executing it

Remember

  • In a numeric mode, the three digits apply to owner, group and everyone else.
  • Recursive permission changes can affect every file beneath the target path.

Watch for chmod 777 is not a general fix; grant only the access the user or service needs.

Open the lesson: Working with files: permissions, archives and links →
05Text processingTreat logs as streams of text: filter first, then cut, count, group or transform the matching lines. Pipes let small tools answer a focused operational question.
  • grep '" 500 ' access.log

    Find log lines with an HTTP 500 status

  • tail -f access.log

    Follow new log lines as they arrive

Remember

  • Use grep, cut, sort, uniq, wc, awk and sed as composable tools.
  • Quote patterns when shell metacharacters or spaces are part of the match.

Watch for tail -f keeps running; press Ctrl+C when you have the lines you need.

Open the lesson: Text processing: get answers out of logs →
06Server reviewOn a slow server, check load, memory, disk, services, listening ports and logins in a fixed order. Each observation narrows the next diagnostic step.
  • hostnamectl | head -n 3

    Identify the host and see its basic operating-system details

  • uptime

    Read uptime and the system load averages

Remember

  • Load average is runnable or uninterruptible work, not a CPU percentage.
  • Compare load with available CPU cores and check memory and disk before blaming the app.

Watch for High load alone does not prove the CPU is saturated; inspect the processes and I/O state.

Open the lesson: Server review: a five-minute health check →
07Process managementFind the process consuming resources, understand its parent and state, then stop it with the least disruptive signal. Background and persistent jobs have different lifetimes.
  • ps aux --sort=-%cpu | head -5

    Show the five processes using the most CPU

  • pstree -p | head -n 12

    Inspect parent/child process relationships

Remember

  • A process has a PID and a parent PID; the process tree explains how it started.
  • Try a normal termination signal before escalating to a forceful one.

Watch for Killing a parent or using SIGKILL first can interrupt cleanup and leave work inconsistent.

Open the lesson: Processes: see them, control them, stop them →
08Users & groupsGive each person and service the identity it needs, then use groups and narrow sudo rules to share only the required access.
  • id

    Show the current user's UID and group memberships

  • getent group devops

    Look up a group through the system's configured identity sources

Remember

  • A service account should not be able to log in interactively unless it has a real need.
  • Group membership is a practical way to grant shared file access.

Watch for Editing /etc/sudoers directly can break sudo; validate changes with the tool taught in the lesson.

Open the lesson: Users and groups: who can do what →
09Services with systemdsystemd starts services, restarts them under policy and records their logs. Separate a one-time start from enabling a service for future boots.
  • systemctl status nginx

    Inspect whether nginx is running and see recent status details

  • journalctl -u cron -n 20

    Read the latest journal entries for nginx

Remember

  • start affects the current boot; enable configures startup at boot.
  • Use journalctl -u SERVICE to narrow the journal to one unit.

Watch for A service that is running now may still be disabled for the next reboot.

Open the lesson: Services with systemd: run, restart, read the logs →
10Package managementInstall software from configured repositories so dependencies and updates are tracked. Check what a package manager will do before applying upgrades to a server.
  • apt-cache policy curl

    Check the installed and repository candidate versions of curl

  • apt-get -s install tree

    Simulate an installation without changing the system

Remember

  • APT and DNF resolve package dependencies from configured repositories.
  • A simulation is a safe way to review a package transaction first.

Watch for Don't mix package managers for the same software; use the system's supported source.

Open the lesson: Packages: install, update and trust software →
11Disks & filesystemsA disk becomes usable through a chain of device, partition, filesystem and mount point. Check free space and mount state before expanding storage or editing fstab.
  • lsblk -f

    List block devices with filesystem and UUID information

  • df -Th

    Check filesystem type, capacity and usage for mounted filesystems

Remember

  • lsblk shows devices; df shows space on mounted filesystems.
  • A persistent mount belongs in /etc/fstab, and should be checked before rebooting.

Watch for A new disk is not automatically a mounted filesystem; verify each step in the storage stack.

Open the lesson: Disks and filesystems: add, mount, grow and repair →
12Booting LinuxTrace startup from firmware through GRUB, kernel and initramfs to systemd. When boot fails, use the available console and previous-boot logs to locate the stage that stopped.
  • cat /proc/cmdline

    Read the kernel arguments used for the current boot

  • journalctl -b -1 -p err

    Review errors from the previous boot

Remember

  • The initramfs provides early userspace tools needed before the real root filesystem is mounted.
  • GRUB configuration is generated; change its source configuration and rebuild it.

Watch for Do not edit generated grub.cfg directly; regenerate it from the maintained configuration.

Open the lesson: How Linux boots, and what to do when it does not →
13NetworkingDiagnose network paths from local interface and route outward through DNS, ports and SSH. Establish which hop or lookup fails before changing firewall or resolver settings.
  • ip -br addr

    Show interface state and addresses in a compact form

  • getent ahostsv4 example.com

    Resolve a hostname through the system's configured name service

Remember

  • DNS resolution and IP reachability are separate checks.
  • SSH keys authenticate a connection; scp and rsync move files over SSH.

Watch for A successful DNS lookup does not prove that a service port is reachable.

Open the lesson: Networking: addresses, DNS, routes and SSH →
14Shell scriptingTurn repeated work into a Bash script with quoted variables, explicit branching, loops and exit codes. Validate syntax and test failure paths before scheduling it.
  • chmod +x hello.sh

    Make the script executable

  • ./hello.sh team

    Run the script from the current directory with an argument

Remember

  • Quote variable expansions so spaces and wildcard characters stay inside one argument.
  • A non-zero exit code tells the caller that a command or script failed.

Watch for ./script runs a file in the current directory; the shell does not search . in PATH by default.

Open the lesson: Shell scripting: automate it once, run it forever →
15TroubleshootingWork from basic reachability to the listening socket and then inspect packets and firewall rules. Distinguish a refused connection from a timeout before changing anything.
  • sudo ss -tlnp

    Show listening TCP ports and the owning processes

  • ping -c 3 1.1.1.1

    Check basic IP reachability with three ICMP requests

Remember

  • Connection refused usually means the host answered but nothing accepted that port.
  • A timeout means no response arrived; routing or filtering may be involved.

Watch for A failed ping alone does not prove the application is down; ICMP may be filtered.

Open the lesson: Troubleshooting the network: from "it is down" to the cause →
16Containers on LinuxA container is an ordinary Linux process isolated by namespaces and limited by cgroups. Docker assembles these kernel features and the filesystem layers into a repeatable workflow.
  • ls /proc/self/ns

    List the namespace handles for the current process

  • stat -fc %T /sys/fs/cgroup

    Identify the filesystem backing the cgroup hierarchy

Remember

  • Namespaces control what a process can see; cgroups control how much it can use.
  • A process has one namespace membership per namespace type.

Watch for Containers share the host kernel; they are not lightweight virtual machines.

Open the lesson: Containers are Linux: namespaces, cgroups and Docker →
← Back to the Linux & Bash course