Linux Tutorial
Learn the Linux command line and Bash scripting from your first command to pipes, text tools, scripts and real projects. 95 lessons with real commands that run in your browser, quizzes and projects.
Start learning →
of lessons completed
Getting Started
- Getting Started with Linux and the Command Line Learn what Linux is, how the kernel, distributions, shell and terminal fit together, and run your first real Bash commands right in your browser.
- Linux Architecture: Kernel, Subsystems, Libraries and Shells See how Linux is built: kernel types, the scheduler, memory manager, VFS, networking and IPC, user space versus kernel space, system libraries and the shell family.
- Linux Distributions and Unix Heritage Compare the main Linux distribution families, learn what a distro contains and how to choose one, and understand Linux versus Unix, BSD and macOS.
- The Shell: Commands, Arguments and Options Learn how a shell command is built - command, options and arguments - plus command types, exit status and chaining with semicolons, && and ||, with live Bash examples.
- Getting Help: man, --help and Learning Commands Learn how to find out what any Linux command does - man pages, --help, the help builtin, type and command -v - and how to read usage syntax with brackets.
- The Linux Filesystem Understand the Linux directory tree - /, /etc, /usr, /var, /home, /tmp, /proc and /dev - absolute and relative paths, hidden files and why everything is a file.
- Navigating: pwd, cd and ls Learn to move around the Linux filesystem with pwd, cd and ls - options -l, -a, -h, -R, -t and -S, reading ls -l output, and the working directory of every process.
Working with Files
- Creating and Viewing Files Create files and directories with touch, mkdir -p, echo, printf and here-docs, then inspect them with cat, wc, file and stat. Includes tips for file names with spaces.
- Copying, Moving and Deleting Learn cp, mv, rm and rmdir on Linux: copy files and directories, rename and move, delete safely, and avoid the classic mistakes that destroy data.
- Wildcards and Globbing Learn shell globbing on Linux: *, ?, [abc], brace expansion, extglob, globstar, dotfiles, nullglob, and why the shell, not the command, expands wildcards.
- Finding Files: find, locate and which Master the Linux find command: search by name, type, size, time and permissions, run commands with -exec, use -print0 with xargs, prune directories, and know when to use locate.
- Hard Links, Symbolic Links and Inodes Understand inodes, hard links and symbolic links on Linux: how ln and ln -s work, link counts, dangling links, readlink, relative symlinks and links to directories.
- File Permissions and Ownership Understand Linux file permissions: read ls -l, rwx for user, group and other, chmod in symbolic and octal form, umask, directory permissions, setuid, setgid and the sticky bit.
- Archives and Compression Learn tar, gzip, bzip2 and xz on Linux: create, list and extract archives, use -C and streaming pipes, compare compression ratios, extract safely and verify files with sha256sum.
- Disk Usage and File Information Learn how to measure disk space on Linux with du, df, ls -lh and stat, find the biggest files, count files, and understand sparse files and apparent size.
- Editing Files: nano, vim and Emacs Basics Edit files in the terminal with confidence: nano shortcuts, the vim modes and survival kit, Emacs basics, how $EDITOR works and how to get out when stuck.
- ACLs, chattr and Extended Attributes Go beyond rwx permissions: use setfacl and getfacl for per-user access, default ACLs, the mask, chattr +i and +a for immutable files, and xattrs.
Working with Text
- Viewing and Slicing Text Learn the Linux tools that show and slice text: cat, tac, head, tail, nl, cut, paste, tr, fold and expand, with CSV and log examples you can run.
- grep and Searching Text Learn grep on Linux: -i -v -n -c -r -l -o -w -E -F, context lines, patterns and anchors, exit codes, searching code and logs, with runnable examples.
- Regular Expressions for the Shell Learn regular expressions for the Linux shell: basic vs extended syntax, anchors, quantifiers, groups, backreferences, POSIX classes and recipes for grep and sed.
- sed: The Stream Editor Learn sed on Linux: s/// substitution and flags, addresses and ranges, d and p, -n, safe in-place editing with -i, multiple commands, hold space and pitfalls.
- awk: Column Processing and Reports Learn awk on Linux: fields, -F, patterns and actions, BEGIN and END, variables, arrays, printf, built-in functions, sums by key and formatted reports.
- sort, uniq, cut, tr and wc Master sort, uniq, cut, tr, wc and join: numeric and multi-key sorting, frequency tables, top-N lists, locale effects and stable sorts, with runnable examples.
- diff, comm and patch Learn to compare files with diff, comm and cmp, read unified diff hunks, and create and apply patches with diff -u and patch -p1, using runnable examples.
- Building Text Pipelines Learn to compose grep, sed, awk, sort and uniq into reliable text pipelines: log analysis, CSV summaries, process substitution and debugging with tee.
- Hex and Binary Inspection: xxd, od, hexdump, strings Inspect files that are not text on Linux: read hex dumps with xxd, od and hexdump, find readable text with strings, identify formats with file, and compare binaries with cmp.
Pipes and Redirection
- Standard Streams and Redirection Understand stdin, stdout, stderr and file descriptors in Bash: redirect with >, >>, <, 2>, 2>&1 and &>, the order of redirections, noclobber and exec.
- Pipes and Pipelines Learn how Linux pipes connect processes: concurrency, pipefail and PIPESTATUS, tee, buffering, SIGPIPE with head, named pipes (mkfifo) and performance.
- Here-Documents, Here-Strings and Input Learn Bash here-documents (<<EOF, <<-, quoted delimiters) and here-strings (<<<), how to read stdin with read and cat, and how to generate files and templates.
- xargs, Command Substitution and Process Substitution Turn output into arguments with $( ) and xargs (-n, -I, -0, -P), and feed commands like files with process substitution <( ). Safe patterns with find -print0.
- Subshells, Groups and Environment Understand Bash subshells: ( ) versus { }, variable scope, cd in subshells, export and the environment, bash -c, and the pipeline variable-loss gotcha.
Shell Scripting
- Writing Your First Script Write and run your first Bash script: the shebang line, bash script.sh versus ./script, chmod +x, structure, comments, exit status, and bash versus sh.
- Variables and Environment Variables Learn Bash variables: assignment without spaces, $var vs ${var}, unset, readonly, export, the environment, special variables like $? $# $@, PATH and scope.
- Quoting and Expansion Master Bash quoting: single vs double quotes, backslash, $'...', word splitting and globbing, "$@" vs $*, the order of expansions, and the spaces-in-filenames bug.
- Parameter Expansion and String Handling Handle strings in pure Bash: defaults ${var:-x}, ${var:?}, length, substrings, removing prefixes and suffixes, replace, case conversion, trimming and path parts.
- Arithmetic and Numbers Do math in Bash with $(( )), (( )) and let: integer rules, floats with awk, number bases, bit operations, RANDOM, overflow and the classic octal trap.
- Conditionals: if, test and [[ ]] Learn Bash conditionals: if/elif/else, exit status as a condition, test, [ ] versus [[ ]], file, string and numeric tests, regex matching and common mistakes.
- case Statements and Menus Master the Bash case statement: glob patterns, multiple alternatives, ;; ;& ;;& terminators, parsing options, and building select menus. Learn case versus if.
- Loops: for, while and until Learn Bash loops: for over lists, globs and ranges, C-style for, while and until, break and continue, safe file loops and reading lines with IFS= read -r.
- Functions Write Bash functions: arguments, return versus exit, returning data via stdout, local variables, recursion, libraries with source, namerefs and composition.
- Arrays and Associative Arrays Learn Bash indexed and associative arrays: create, append, slice, loop with quotes, mapfile, declare -A, counting, passing arrays to functions and common pitfalls.
- Script Arguments and Options Handle script arguments in Bash: positional parameters, $#, shift, getopts for short options, a loop for long options, validation, usage messages and exit codes.
- Exit Codes, set -e and Error Handling Learn Bash exit status, set -euo pipefail and its gotchas, trap ERR and EXIT, cleanup with mktemp -d, errors to stderr, idempotent scripts and retry loops.
- Signals and trap Understand Unix signals and the Bash trap builtin: INT, TERM, HUP, USR1, EXIT, cleanup handlers, kill to $$, ignoring signals, background jobs and wait statuses.
- Reading Input and Interactive Scripts Master the Bash read builtin: -r, -p, -s, -n, -t, -a, IFS splitting, reading until EOF, validating input, default answers, confirm prompts and [[ -t 0 ]] checks.
- Debugging Shell Scripts Debug Bash scripts like a pro: set -x and PS4 tracing, bash -n syntax checks, set -v, LINENO and FUNCNAME, trap DEBUG, ShellCheck warnings and assert helpers.
Processes and the System
- Processes: ps, top and /proc Understand Linux processes: PIDs and parents, ps options and custom columns, process states (S, R, T, Z), the /proc filesystem, threads, and top and htop.
- Jobs and Background Processes Run commands in the background with & and $!, collect results with wait, limit concurrency, use timeout, and learn jobs, fg, bg, nohup and disown in Bash.
- kill, Signals and Process Control Control Linux processes: kill and kill -l, SIGTERM versus SIGKILL, pgrep and pkill, process groups, nice and renice, ulimit, zombies and orphans.
- Environment, Profiles and Configuration Learn the Linux shell environment: env and export, PATH, .bashrc versus .profile, aliases, shopt and set -o, dotfiles, locale and TZ, and the PS1 prompt.
- Users, Groups and sudo Understand Linux users and groups: UIDs, id and groups, /etc/passwd and /etc/group, root, su and sudo, file access by UID, umask and least privilege.
- Packages, Services and systemd How Linux installs software and runs services: apt, dnf and pacman, dpkg, systemctl, unit files, journalctl, timers, cron syntax, and the history of init systems.
- Networking Basics from the Shell Learn Linux networking from the shell: IP addresses, ports, loopback, /etc/hosts, DNS, ss, curl, ping, and a TCP client in plain Bash with /dev/tcp.
- Disks, Mounts, Logs and Monitoring Read mounts and disk usage, parse /proc/meminfo, analyse log files with grep and awk, follow logs with tail, understand log rotation and basic system monitoring.
- SSH, scp and Working Remotely Use SSH safely: key pairs, ~/.ssh/config, scp and rsync, port forwarding, tmux, remote commands and scripts, and the quoting and stdin traps of automation.
- Scheduling with cron, at and systemd Timers Schedule Linux jobs with cron, at, anacron and systemd timers: crontab syntax, the minimal environment, logging, overlap locks and common mistakes.
- strace, ltrace, lsof, perf and eBPF Intro Find out what a Linux process is really doing: trace system calls with strace, list open files with lsof, profile with perf and meet eBPF tools.
Advanced Bash
- The Order of Expansions in Depth Learn the exact order in which Bash expands a command line: braces, tilde, parameters, command substitution, word splitting, globbing, quote removal, and why eval bites.
- Advanced Patterns: Regex, Process Substitution and Coprocesses Go beyond the basics of Bash: regex matching with BASH_REMATCH, extglob patterns, file descriptors, FIFOs, coproc, lockfiles with flock and parallel jobs with xargs -P and wait -n.
- printf, Dates and Formatting Master printf formats, padding and columns, %q quoting, printf -v and %(fmt)T, GNU date with epoch seconds and time zones, sorting dates and computing durations in Bash.
- POSIX sh, Portability and Compatibility Learn the difference between bash, sh, dash and zsh, find bashisms, write portable POSIX scripts, handle GNU versus BSD tools, and use shellcheck and feature detection.
- Designing Maintainable Scripts Design Bash scripts that last: main function, usage text, logging, layered configuration, dry-run mode, idempotency, locking, tests and when to switch language.
- Text Processing Recipes A cookbook of shell text recipes: dedupe, set operations, joins, column sums, bulk rename, key=value parsing, JSON with grep and sed, CSV pitfalls and templates.
- Performance, Tricks and Pitfalls Make Bash scripts fast and safe: avoid forks and subshells, use builtins, replace slow while-read loops, run jobs in parallel, and dodge classic pitfalls like parsing ls.
- Customizing Bash: Prompts, Completion and Readline Design your own Bash prompt with PS1 and PROMPT_COMMAND, write programmable tab completion with complete and compgen, and tune keys and history with readline.
Projects
- Project: A Backup Script Build a real backup tool in Bash: timestamped tar.gz archives, SHA-256 verification, rotation of old backups, dry-run mode, logging and a safe restore script.
- Project: Log Analyzer Build a log analyzer in Bash: generate a sample access log, then use awk, sort and uniq to report top IPs, status codes, hourly traffic, errors and bandwidth.
- Project: File Organizer Write a Bash file organizer that sorts files into folders by extension or month, handles name collisions, supports dry-run, keeps an undo log and has its own tests.
- Project: A Todo Manager in Bash Build a todo manager in Bash with git-style subcommands, a tab-separated file store, getopts per command, optional colours, atomic updates and a test script.
- Project: A Mini Test Framework Build a test framework in Bash: assert functions, automatic test discovery with declare -F, subshell isolation, temp-dir fixtures, skips and exit codes.
- Project: A Deployment Script Skeleton Build a deployment script skeleton in Bash: environment config, timestamped releases, atomic symlink switch, loopback health check, rollback and dry-run mode.
- Project: Write a Tiny Shell in C Build a working mini shell in C: parse commands with quotes, run them with fork, execvp and waitpid, add cd and exit builtins, pipes and file redirection.
- Project: Server Health Monitor Build a server health monitor in Bash: read CPU, memory, load and disk usage from /proc and df, apply thresholds, alert only on changes, and run it from cron.
Practice and Review
- Linux and Bash Cheat Sheet A one-page Linux and Bash cheat sheet: navigation, files, text tools, redirection, quoting, tests, loops, functions, signals, exit codes and handy one-liners.
- Practice Problems: Commands and Text 15 graded Linux practice problems with hints and verified solutions: files, permissions, links, find, grep, sed, awk, sort, redirection, tar and pipelines.
- Practice Problems: Scripting and Pipelines 15 graded Bash scripting problems with hints and verified solutions: functions, arrays, getopts, regex, traps, retries, background jobs, xargs and pipelines.
- Linux and Bash Interview Questions and Answers Prepare for Linux and Bash interviews with 50 concise questions and answers on the filesystem, permissions, processes, pipes and shell scripting pitfalls.
System Administration
- Disks, Partitions, mkfs and LVM Add and manage storage on Linux: partition tables, fdisk and parted, ext4 and xfs, mounting with fstab, LVM volumes, resizing and a RAID overview.
- Firewalls: ufw, iptables and nftables Understand the Linux firewall: chains and rules, default policies, stateful tracking, ufw commands, iptables and nftables examples and how to avoid locking yourself out.
- Network Troubleshooting: ip, ss, tcpdump, nmap, dig Diagnose Linux network problems layer by layer with ip, ping, traceroute, ss, dig, curl, tcpdump and nmap, and learn to read routes, sockets and packet traces.
- Network Configuration: NetworkManager, netplan, DNS Configure Linux networking that survives a reboot: static IPs with nmcli and netplan, systemd-networkd, resolvers, /etc/hosts, search domains and hostnames.
- Network Services: DHCP, DNS and FTP Servers Learn what DHCP, DNS and FTP servers do on Linux, how dnsmasq, ISC dhcpd, BIND and vsftpd are configured, and why SFTP is usually the safer choice.
- SELinux and AppArmor Learn mandatory access control on Linux: SELinux contexts, modes, booleans and restorecon, AppArmor profiles, and how to read denial logs without disabling them.
- PAM, sudoers and Account Policies Understand PAM stacks and control flags, write safe sudoers rules with visudo, enforce password quality and aging, and lock out repeated login failures.
- Server Hardening Checklist A practical Linux server hardening checklist: lock down SSH, add a firewall and fail2ban, automate updates, remove risky setuid files and watch changes with auditd.
- Boot Process, GRUB, Kernel Modules and sysctl Follow the Linux boot from firmware and GRUB to the kernel and systemd, edit the kernel command line, manage modules with modprobe and tune the kernel with sysctl.
- Logging: journald, rsyslog and logrotate Read, filter and rotate Linux logs: how journald and rsyslog collect messages, journalctl filters by unit, time and priority, and logrotate keeps disks from filling.
- Namespaces, cgroups and chroot See what a container really is on Linux: namespaces isolate what a process sees, cgroups limit what it uses, and chroot changes its root. Includes hands-on /proc exploration.
- Setting Up a Web Server: nginx, TLS, Let's Encrypt Install nginx on Linux, serve several sites with server blocks, add HTTPS with Let's Encrypt and certbot, and put a reverse proxy in front of an application.
- File Sharing: NFS, Samba and rsync Servers Share files between Linux hosts and with Windows: export directories over NFS, publish Samba shares, and run rsync over SSH or as a daemon for backups and mirrors.
- Compiling Software from Source and Building Packages Build Linux software from source with gcc, make and the configure/make/make install routine, understand shared libraries with ldd, and package your program as a .deb or .rpm.
- WSL, Cloud Instances and cloud-init Run Linux on Windows with WSL 2, start a Linux server in the cloud, and use cloud-init to configure it on first boot. Includes runnable path and cloud-init demos.
- Rescue Mode and Recovery Recover a Linux system that will not boot or let you in: reset a forgotten password, fix a broken fstab, repair a filesystem with fsck, and use chroot from a live USB.
- Automation with Ansible and Terraform (overview) Learn what infrastructure as code means, how Terraform creates servers and Ansible configures them, and why idempotence and plan-then-apply matter. With runnable models.