Programming Languages
Work fluently in the terminal and write Bash scripts that are safe, readable and easy to debug.
From your first cd to production-grade scripts. Learn the commands for files, text processing and system monitoring, then the scripting language itself — variables, expansions, conditionals, loops, functions — and finish with strict error handling, debugging, process control, networking and scheduled jobs. Aimed at developers and ops engineers who live in a terminal. Each subject links the GNU Bash manual or the relevant man page.
The subjects follow the roadmap.sh Shell / Bash roadmap.
A shell is the program that reads your commands, expands them and starts other programs. Bash is the default on most Linux servers and in CI images, so being fluent in it pays off every day you touch a terminal, a Dockerfile or a deploy script.
A GUI is discoverable; a command line is composable, scriptable and works over SSH on a machine with no display. Repetitive tasks that take ten clicks become one line you can save and rerun.
The GNU "Bourne-Again SHell", a POSIX-compatible shell with extras such as arrays, [[ ]], brace expansion and readline editing. macOS ships an old 3.2 build and defaults to zsh, so install a current Bash there if scripts need 4.x+ features.
Saving the commands you would type into a file so they run the same way every time. Shell scripts glue existing programs together; once logic grows past a few hundred lines or needs data structures, a language like Python is usually the better tool.
Shells share the basic idea but differ in syntax, interactive features and POSIX compliance. Write portable scripts for sh when they must run anywhere, Bash when you control the machine, and pick whatever interactive shell you enjoy.
The de facto scripting shell on Linux and the one this path teaches. Check the version with bash --version; associative arrays need 4.0 or newer.
macOS's default interactive shell, largely Bash-compatible, with stronger globbing, spelling correction and a large plugin ecosystem (Oh My Zsh). Arrays are 1-indexed, a classic gotcha when porting scripts.
A small, fast POSIX shell that is /bin/sh on Debian and Ubuntu. Scripts with a #!/bin/sh shebang run under it there, so Bash-only syntax like [[ or arrays breaks.
A friendly interactive shell with autosuggestions and syntax highlighting out of the box. Its scripting language is deliberately not POSIX-compatible, so keep Bash for scripts.
The KornShell, an ancestor of many Bash features, still found on commercial Unix systems such as AIX. Worth recognising if you maintain older enterprise scripts.
An enhanced C shell with C-like syntax, historically the default on FreeBSD for root. The csh family is considered a poor fit for scripting.
Microsoft's cross-platform shell where pipelines pass .NET objects instead of text, so you filter on properties rather than parsing columns. The native choice for Windows administration.
The legacy Windows command interpreter that runs .bat and .cmd files. Still around in old build scripts; new Windows automation should use PowerShell.
Login shells read ~/.bash_profile (or ~/.profile), interactive non-login shells read ~/.bashrc, so most people source the latter from the former. Put your PATH changes, aliases, prompt (PS1) and history settings there, and change your default shell with chsh -s.
Moving around the filesystem and creating, copying, moving and deleting files are the first commands to make automatic. Paths are absolute from / or relative to the current directory, and quoting matters as soon as a name contains spaces.
Prints the current working directory. pwd -P resolves symlinks to the physical path; scripts can also read $PWD.
Lists directory contents. ls -la shows hidden files, permissions, owners and sizes; -h gives readable sizes and -t sorts by time. Never parse its output in scripts — use globs or find.
Changes the current directory; a builtin, since a child process could not change its parent's. cd alone goes home, cd - returns to the previous directory.
Use . and .., ~ for home, and cd - to bounce between two places. pushd and popd keep a stack of directories, handy in scripts that must return where they started.
Creates directories. mkdir -p a/b/c creates the parents as needed and does not fail if the directory already exists, which makes it safe to rerun.
Removes directories only if they are empty — a safer choice than rm -r when you expect nothing to be inside.
Creates an empty file or updates an existing file's modification time, useful for marker files and for nudging tools that watch timestamps.
Copies files; -r for directories, -a to preserve permissions, timestamps and symlinks, -i to prompt before overwriting.
Moves or renames files. Within one filesystem it is just a rename and instant; across filesystems it copies then deletes. -n refuses to overwrite.
Deletes files permanently — there is no trash. rm -r removes directories; be careful with -f and with unquoted variables that might expand to nothing or to /.
Walks a directory tree and filters by name, type, size, age or permissions, e.g. find . -name "*.log" -mtime +7 -delete. Use -print0 with xargs -0 or -exec … {} + to handle odd file names safely.
Reading files and searching inside them without opening an editor. These tools stream, so they work on multi-gigabyte logs as easily as on small configs.
Concatenates files to standard output — the quickest way to dump a short file or join several. cat -A reveals tabs and line endings; avoid piping a single file through it when the next command can read it directly.
Pagers for scrolling through long output. less can go backwards, search with /, and follow a growing file with F; more is the older forward-only version.
Show the first or last lines of a file (-n 20). tail -f follows a log as it grows, and tail -n +2 skips a header line.
Prints lines matching a pattern. Key flags: -i ignore case, -r recurse, -n line numbers, -v invert, -E extended regex, -o only the match, -q quiet for use in if.
Small filters that each do one thing to a stream of lines and chain together with pipes. Together they replace a lot of one-off scripts for cleaning, reshaping and extracting data.
Translates or deletes single characters: tr a-z A-Z upper-cases, tr -d "\r" strips Windows line endings, tr -s " " squeezes repeated spaces. It only reads standard input.
cut -d, -f2 pulls fields or character ranges from each line; paste joins lines from several files side by side, or with -s turns a column into one line.
join merges two files on a common field, like a database join (both inputs must be sorted on that field). split breaks a large file into pieces by lines (-l) or size (-b).
A stream editor applying scripted edits line by line; most usage is sed "s/old/new/g". -i edits in place, but its syntax differs between GNU (-i) and BSD/macOS (-i '').
A small language for field-based text processing: awk -F: '{ print $1 }' /etc/passwd. Patterns, associative arrays and BEGIN/END blocks make it ideal for summing columns or reformatting reports.
Counting, ordering and deduplicating lines turns raw logs into answers. The classic sort | uniq -c | sort -rn | head idiom finds the most frequent values in almost any text.
Sorts lines. -n numeric, -h human sizes, -r reverse, -k2,2 by a field, -t, for the delimiter, -u unique. Set LC_ALL=C for fast byte-wise, predictable ordering.
Collapses adjacent duplicate lines, so sort first. -c prefixes counts, -d shows only duplicates, -u only unique lines.
Counts lines (-l), words (-w) and bytes (-c). wc -l < file prints just the number without the file name.
Numbers the lines of a file, by default skipping blank ones; -ba numbers every line. Handy when quoting output in reviews or bug reports.
The shell, not the command, expands glob patterns into matching file names before the command runs. If nothing matches, Bash passes the pattern through literally unless nullglob or failglob is set — a common source of surprises.
Matches any string, including the empty one, within a single path component: *.txt. It skips dot-files unless dotglob is on; ** recurses only with shopt -s globstar.
Matches exactly one character, so img-??.png finds img-01.png but not img-1.png.
Matches one character from a set or range: [abc], [0-9], or a class like [[:digit:]]. A leading ! or ^ negates the set.
Brace expansion generates strings whether or not files exist: mkdir -p src/{lib,bin}, cp app.conf{,.bak}, echo {1..5}. It happens before globbing and does not work inside quotes.
Press Tab to complete commands, paths and variable names, and Tab twice to list candidates. The bash-completion package adds context-aware completion for options and subcommands of tools like git, ssh and docker, built on the complete builtin.
Bash keeps a history of commands. Use the arrow keys or Ctrl-R for reverse search, !! to rerun the last command (as in sudo !!), !$ for its last argument, and history to list entries; HISTSIZE and HISTCONTROL=ignoreboth tune what is kept.
man ls opens a command's manual, man -k word searches them, and help cd documents Bash builtins, which have no man page of their own. type name tells you whether a word is an alias, function, builtin or file, and most tools accept --help.
An alias is a text shortcut for interactive use: alias ll="ls -lah", saved in ~/.bashrc. Aliases are not expanded in scripts by default and cannot take arguments in the middle, so reach for a function when you need either; \ls bypasses an alias once.
Ctrl-C sends SIGINT to the foreground job and Ctrl-Z suspends it; kill PID sends SIGTERM and kill -9 the uncatchable SIGKILL as a last resort. Inside a script, exit N stops it with a status and return leaves a function.
Every process starts with three open streams, and the shell lets you point them at files or at other processes. This is what makes small Unix tools composable: one program's output becomes the next one's input.
File descriptors 0, 1 and 2. Programs read input from 0, write results to 1 and diagnostics to 2, so errors still reach the terminal when output is piped elsewhere.
> writes stdout to a file, truncating it; >> appends. set -o noclobber prevents accidental overwrites, and >| forces one anyway.
< file feeds a file to a command's stdin, as in sort < names.txt or while read -r line; do …; done < list.txt.
2> err.log sends errors to a file and 2>/dev/null hides them. > out.log 2>&1 (order matters) or Bash's &> out.log captures both streams together.
a | b connects a's stdout to b's stdin, running both concurrently. The pipeline's exit status is the last command's unless set -o pipefail; PIPESTATUS holds each stage's status.
$(command) is replaced by the command's output, with trailing newlines stripped: today=$(date +%F). Prefer it over backticks, since it nests cleanly, and quote the result.
<(command) gives a command's output a file-like path, so tools that need file names can read it: diff <(sort a) <(sort b). >(command) works in the other direction.
On a server you will often edit config files in a terminal editor. Learn to open a file, move around, insert and delete text, search and replace, save, and quit without saving — in whichever editor you pick, before you need it in an emergency.
Terminal editors are always available over SSH. Nano is the gentle start, Vim is the one installed nearly everywhere and worth learning properly, and Emacs is a whole programmable environment. Set your favourite in $EDITOR so git and crontab -e use it.
A simple modeless editor with its shortcuts listed at the bottom of the screen: Ctrl-O saves, Ctrl-X exits, Ctrl-W searches. The default editor on Ubuntu and Debian.
The original modal editor specified by POSIX, so some form of it is on every Unix system. Know i to insert, Esc to leave insert mode, :wq to save and quit, and :q! to abandon changes.
Vi improved: syntax highlighting, undo history, splits, plugins and composable motions like ciw or dap. Run vimtutor once — it takes half an hour and covers the essentials.
An extensible editor configured in Emacs Lisp, with modes for nearly everything, including Magit for git and Org for notes. Its default keybindings are also what Bash's readline uses (Ctrl-A, Ctrl-E, Ctrl-K).
A script starts with a shebang such as #!/usr/bin/env bash, often followed by set -euo pipefail, constants, function definitions and a main "$@" call at the bottom. Keeping that shape makes scripts predictable to read, test and reuse.
How you start a script decides which interpreter runs it and whether it gets its own process. The difference matters for shebangs, permissions and whether variables leak into your current shell.
bash script.sh runs the file in a new Bash process, ignoring its shebang and execute bit. Useful for one-off runs and for adding flags like bash -x.
After chmod +x script.sh, run ./script.sh; the kernel reads the shebang to choose the interpreter. The script must be on PATH to run without the ./ prefix.
source file (or . file) runs the commands in the current shell, so variables, functions and cd persist afterwards. That is how .bashrc reloads and .env-style files are loaded; an exit inside closes your shell.
Bash variables are fundamentally strings; integers exist only in arithmetic contexts, and arrays are the one real structure. declare -i, -a, -A and -r attach attributes but do not make Bash a typed language.
The default for every value. Double quotes allow $var and $(…) expansion while keeping spaces intact; single quotes are fully literal; $'…' understands escapes like \t.
Integers live inside (( )) and $(( )), are 64-bit signed and have no decimals. For floating point use bc or awk.
Indexed lists: files=(a.txt b.txt), ${files[0]}, "${files[@]}" for all elements safely quoted, ${#files[@]} for the count, files+=(c.txt) to append. mapfile -t reads lines into one.
Key-value maps declared with declare -A ports=([web]=80 [db]=5432); iterate keys with "${!ports[@]}". Bash 4 or later only, so not on stock macOS Bash.
Variables hold strings that the shell substitutes when it sees $name. Most shell bugs come from unquoted expansions, so quote every "$var" unless you deliberately want word splitting and globbing.
Assign with no spaces around = (name="Ada"), read with "$name" or "${name}", change by assigning again or appending with +=. unset name removes it.
A plain variable is local to the current shell; export copies it into the environment of child processes. VAR=value cmd sets it for one command only; env and printenv list what is exported.
Variables are global to the script by default, even inside functions. Subshells — ( … ), pipelines and $( … ) — get copies, so changes made there vanish when they exit.
Read-only values set by the shell: $? last status, $$ this shell's PID, $! last background PID, $0 script name, plus Bash variables like $RANDOM, $LINENO, $SECONDS and $BASH_SOURCE.
Quote expansions, use local in functions, upper-case only for exported or environment variables, readonly for constants, and ${var:-default} or ${var:?message} to handle unset values explicitly.
Scripts talk to users and to other programs through standard streams. Print with printf for anything formatted, read with read -r, and feed multi-line text into commands with here documents.
Prints its arguments followed by a newline. Behaviour of -e and -n differs between shells and echo itself, so use it only for simple fixed text and switch to printf otherwise.
C-style formatting with predictable behaviour: printf "%-10s %5.2f\n" "$name" "$price". The format is reused for extra arguments, and printf -v var writes into a variable instead of stdout.
read -r -p "Name: " name prompts and stores a line; -r keeps backslashes, -s hides typing for passwords, -t 5 times out. while IFS= read -r line is the safe way to loop over a file.
cat <<EOF … EOF feeds a block of lines to a command's stdin, with variables expanded. Quote the delimiter (<<'EOF') to keep it literal, and use <<- to strip leading tabs.
cmd <<< "$text" passes one string as stdin, avoiding an echo | pipeline and its subshell: read -r a b <<< "$pair" sets variables in the current shell.
A # at the start of a word begins a comment that runs to the end of the line. Use comments to explain why a command is there, document a function's arguments and outputs, and leave # shellcheck disable=SC… directives with a reason.
Tests and calculations use different syntaxes: [[ … ]] for string and file tests, (( … )) for integer maths and comparisons, and &&/|| to chain commands by exit status. Mixing them up — > inside [[ ]] compares strings, not numbers — is a classic bug.
+ - * / % ** plus ++, += and bitwise operators, inside (( )) or $(( )). Division truncates, and a leading zero makes a number octal, so 08 is an error.
Integers: -eq -ne -lt -le -gt -ge in [[ ]], or == != < > inside (( )). Strings: ==, !=, and </> for lexical order inside [[ ]].
&& and || run the next command based on the previous one's success, and ! negates. Inside [[ ]] they combine tests; a && b || c is not a true if-else, since c also runs when b fails.
-z empty, -n non-empty, == with globs on the right ([[ $f == *.txt ]]), and =~ for regular expression matching with captures in BASH_REMATCH.
-e exists, -f regular file, -d directory, -r -w -x permissions, -s non-empty, -L symlink, -nt newer than. Guard file operations with them before acting.
Bash only does integer arithmetic natively. Use the built-in arithmetic syntax for counters and indices, and hand decimals or big numbers to an external calculator.
$(( expression )) is replaced by the result: total=$(( a * b + 1 )). Variable names need no $ inside, and (( count++ )) changes a variable without printing anything.
A builtin that evaluates arithmetic expressions given as arguments: let "x = x + 1". Equivalent to (( )), which is usually easier to read.
An external command from before shells had arithmetic: expr 3 + 4, with spaces required and * escaped. Only needed in very old or strictly POSIX scripts.
An arbitrary-precision calculator: echo "scale=2; 10 / 3" | bc gives 3.33. bc -l loads the maths library with sine, logarithms and default decimal precision.
Parameter expansion slices and rewrites strings inside the shell without spawning sed or cut, which is faster in loops. The operators look cryptic at first but follow a small set of patterns.
${#var} gives the number of characters in the value (locale-aware); on an array, ${#arr[@]} gives the element count instead.
${var:offset:length} slices by position; negative offsets need a space, as in ${var: -3}. ${var#prefix}, ${var%suffix} and their doubled forms strip glob patterns, e.g. ${file%.*} drops an extension.
${var/old/new} replaces the first match, ${var//old/new} all of them; # and % anchor the pattern at the start or end. Patterns are globs, not regular expressions.
${var^^} upper-cases, ${var,,} lower-cases, and single ^/, change just the first character. Bash 4+; on older shells pipe through tr.
Arguments passed on the command line arrive as positional parameters. Validate their count early, print a usage message on mistakes, and use getopts once a script accepts flags.
The name the script was invoked with, path included, so $(basename "$0") makes a nice usage line. Inside a sourced file it is the parent shell's name; use ${BASH_SOURCE[0]} there.
The first, second and third arguments. From the tenth on you need braces: ${10}. Supply defaults with ${1:-default}.
The number of positional arguments, used to check usage: (( $# == 2 )) || { echo "usage: …" >&2; exit 2; }.
All arguments. Quoted as "$@" each one stays a separate word, spaces and all — the correct way to forward arguments to another command or loop over them.
Also all arguments, but "$*" joins them into a single string separated by the first character of IFS. Useful for messages, wrong for forwarding.
Drops the first positional parameter and renumbers the rest; shift 2 drops two. The usual loop for parsing options is while (( $# )); do case $1 in …; esac; shift; done.
Every command returns a status from 0 to 255 and every if, && and || branches on it. Scripts should return meaningful statuses too, so callers, CI pipelines and cron can tell what happened.
exit N ends the script with status N; without N it uses the last command's status. Reserve 1 for general errors and 2 for misuse; 126/127 mean not executable or not found.
The status of the most recent command. Read it immediately — even an echo overwrites it — or store it: cmd; rc=$?.
Zero means success and anything else failure, the reverse of most languages' booleans. That is why if grep -q x file works: if tests a command's status, not a value.
Each file has an owner, a group and permission bits for owner, group and others. Understanding them explains "Permission denied", keeps secrets unreadable, and is why a script needs the execute bit to run directly.
Read, write and execute, shown by ls -l as -rwxr-x---. On a directory, r lists names, w creates and deletes entries, and x lets you enter it. Octal digits sum 4+2+1.
Changes permission bits, numerically (chmod 600 key.pem, 755 for scripts) or symbolically (chmod u+x, go-w). -R recurses; be careful not to make every file executable.
Changes a file's owner and optionally group: sudo chown -R www-data:www-data /var/www. Only root can give files away.
Changes only the group, which you can do for files you own if you belong to the target group — useful for shared project directories.
Branch on the exit status of commands and tests. [[ ]] is the Bash test command — safer than [ ] because it does not word-split variables — while (( )) handles numeric conditions.
if cmd; then …; elif other; then …; else …; fi. The condition is any command: if [[ -f $cfg ]], if (( n > 3 )) or if grep -q error log.
Matches a word against glob patterns: case $1 in start|up) …;; *.tar.gz) …;; *) usage;; esac. Cleaner than long elif chains for argument parsing and file types.
Repeat commands over lists, files, numbers or until a condition changes. Loop over globs and "${array[@]}" rather than over $(ls) output, and redirect into while read instead of piping when variables must survive the loop.
for f in *.log; do …; done iterates over words; for (( i = 0; i < 10; i++ )) is the C-style counter form. for x in {1..10} works only with literal numbers, not variables.
Runs while a command succeeds: polling (while ! curl -fs "$url"; do sleep 2; done) or reading a file line by line with while IFS= read -r line.
The inverse of while: repeats until the command succeeds, which reads naturally for retries such as until pg_isready; do sleep 1; done.
break leaves the loop and continue skips to the next iteration; both accept a number to act on enclosing loops, like break 2.
Named groups of commands defined as name() { …; } that take positional arguments like a script. They return a status with return, and "return" data by printing it for the caller to capture with $( ).
Variables set in a function are global unless declared local, which Bash scopes dynamically — callees can see a caller's locals. Declare local on its own line before assigning from $( ), or the command's status is lost.
A function can call itself, e.g. to walk a directory tree, but every level costs a stack frame and $( ) captures spawn subshells. FUNCNEST can cap the depth; for heavy recursion use another language.
Shell bugs usually come from quoting, expansion and unexpected exit statuses. Lint first, then trace execution to see exactly what each line expanded to.
Prints each command after expansion, prefixed by PS4, before running it. Turn it on for a region with set -x … set +x, or run bash -x script.sh; PS4='+${LINENO}: ' adds line numbers.
Reads the script and reports syntax errors without executing anything. A cheap check in CI or a pre-commit hook.
A static analyser that catches unquoted variables, useless cat, broken tests and portability problems, with a wiki page per warning code. Run it on every script and in your editor.
A VS Code extension built on the bashdb debugger that adds breakpoints, stepping and variable inspection for Bash scripts. Useful for long scripts where set -x output gets overwhelming.
By default Bash keeps going after a failed command, which can turn a small error into a destructive one. Strict-mode options, explicit checks and cleanup traps make scripts fail loudly and leave things tidy.
Exits as soon as a command fails. It is ignored in if conditions, &&/|| lists and functions called from them, so treat it as a safety net, not a substitute for checking important commands.
Treats expanding an unset variable as an error, catching typos like $fiel before they become rm -rf "/$fiel". Use ${var:-} where empty is genuinely allowed.
Sets options by name: set -o pipefail makes a pipeline fail if any stage fails, set -o noclobber protects files from >. set -o alone lists the current settings.
Runs a command when the shell receives a signal or pseudo-signal: trap 'rm -f "$tmp"' EXIT for cleanup, ERR to report the failing line, INT/TERM for graceful shutdown.
Send diagnostics to stderr (echo "msg" >&2) so they do not pollute output, include a timestamp and the script name, and use logger to write to the system journal when running unattended.
Patterns for matching text, used by grep, sed, awk and Bash's =~. POSIX defines basic and extended flavours; they differ from the Perl-style regex of most programming languages, and from shell globs.
BRE, the default for grep and sed: . any character, * repetition, ^/$ anchors, […] classes. Grouping and alternation need backslashes: \(…\), and GNU adds \| and \+.
ERE, enabled by grep -E, sed -E and used by awk and [[ =~ ]]: +, ?, {n,m}, | and ( ) work without backslashes. No lookarounds or \d — use [[:digit:]].
Every command runs as a process with a PID, a parent and a state. Job control lets you juggle several of them from one terminal, and a few commands keep work running after you log out.
Snapshots running processes. ps aux or ps -ef lists everything; ps -o pid,ppid,%cpu,cmd -p PID picks columns. pgrep and pkill find and signal processes by name.
Lists the background and stopped jobs of the current shell, numbered so you can refer to them as %1, %2. Start a job in the background by ending the command with &.
After Ctrl-Z suspends a job, bg resumes it in the background and fg %1 brings a job back to the foreground.
Runs a command immune to the hang-up signal sent when the terminal closes, writing output to nohup.out by default. For anything long-lived, prefer tmux, screen or a systemd service.
Removes a job from the shell's job table so it is not sent SIGHUP on exit — the fix when you started something with & and forgot nohup.
Quick checks of CPU, memory, disk and I/O tell you whether a slow machine is busy, swapping or out of space. These tools read from /proc and are on nearly every Linux host.
Live, sorted views of processes and load. In top, press M to sort by memory and 1 for per-CPU usage; htop adds colour, mouse support and easy killing.
free -h shows total, used and available memory plus swap. Look at "available", not "free" — Linux uses spare RAM as page cache and gives it back on demand.
Shows how long the system has run, logged-in users and the 1, 5 and 15-minute load averages. Compare load against the CPU count from nproc.
df -h shows free space per filesystem (-i for inodes); du -sh * shows how much each directory uses, and du -h --max-depth=1 | sort -h finds the biggest.
vmstat 1 prints memory, swap, run queue and CPU wait every second; iostat -x 1 (sysstat package) shows per-disk utilisation and latency to spot I/O bottlenecks.
Command-line tools to check connectivity, transfer files, call HTTP APIs and log into remote machines. They are the first things to reach for when a service "cannot connect".
Sends ICMP echo requests to test reachability and round-trip time; -c 4 stops after four. Many hosts block ICMP, so no reply does not always mean down.
Transfers data over HTTP and many other protocols. Essential flags: -fsSL for scripts, -X method, -H header, -d body, -o output file, -v to see the exchange, -w "%{http_code}" for status.
Downloads files non-interactively, resuming with -c and mirroring sites recursively with -r. Simpler than curl for "fetch this file", less flexible for APIs.
Encrypted remote login and command execution: ssh user@host 'df -h'. Use key pairs (ssh-keygen, ssh-copy-id), host aliases in ~/.ssh/config, and -L for port forwarding.
Copies files over SSH: scp file host:/path, -r for directories. Fine for one-offs; for repeated or large copies rsync is faster and resumable.
Synchronises files locally or over SSH, sending only differences: rsync -avz --delete src/ host:dst/. Mind the trailing slash on the source, and preview with --dry-run.
ip addr, ip link and ip route show and configure interfaces, addresses and routes on modern Linux. ifconfig is the deprecated net-tools equivalent still common on macOS and BSD.
ss -tulpn lists listening TCP/UDP sockets with their processes, answering "what is on port 8080?". ss replaces the older and slower netstat.
Package managers install software with its dependencies from trusted repositories and keep it updated. Each distribution family has its own; scripts that install things should detect which one is present.
Debian and Ubuntu: apt update refreshes indexes, apt install pkg, apt upgrade, apt search. In scripts and Dockerfiles use apt-get with -y, since apt's output is not stable.
Fedora, RHEL and derivatives: dnf install, dnf upgrade, dnf search, dnf provides to find which package ships a file.
The predecessor of dnf on RHEL/CentOS 7 and older; on newer releases yum is an alias for dnf. You will still meet it in legacy scripts.
Homebrew, the de facto package manager for macOS (and usable on Linux): brew install, brew upgrade, and brew install bash to get a modern Bash on a Mac.
Archiving bundles many files into one; compression shrinks it. On Unix these are often separate steps — tar archives and gzip, bzip2 or xz compress — and they trade speed against size.
Creates and extracts archives: tar -czf out.tar.gz dir/, tar -xzf out.tar.gz -C dest/, tar -tf to list. -z, -j and -J select gzip, bzip2 or xz.
The ubiquitous fast compressor: gzip file replaces it with file.gz (-k keeps the original), and gunzip reverses it. zcat reads compressed files without unpacking.
The archive format Windows and macOS open natively: zip -r out.zip dir/, unzip -l to list, unzip file.zip -d dest/. Use it when sharing with non-Unix users.
Slower compressors with better ratios; xz usually wins and is used for kernel and distribution tarballs. xz -T0 uses every core.
Running scripts at set times or intervals without anyone logged in. Scheduled jobs run with a minimal environment and no terminal, so use absolute paths, set PATH, and log output somewhere you will see it.
The cron daemon runs jobs from crontabs edited with crontab -e, using five time fields: 30 2 * * 1 /usr/local/bin/backup.sh runs at 02:30 every Monday. % must be escaped inside entries.
Runs a command once at a future time: echo "./deploy.sh" | at 23:00. atq lists pending jobs and atrm removes them; needs the atd service running.
A .timer unit triggers a matching .service with calendar or monotonic schedules. Compared with cron you get journald logs, dependencies, Persistent=true to catch up missed runs, and systemctl list-timers.