beginner
Good starting points for newcomers
-
apt
Search, install, remove and upgrade packages with apt, including how to see what it will do before it does it, and which commands are safe in a script.
-
cat
Tested cat examples: joining rotated logs, numbering lines with -n and -b, and using cat -A to find the carriage returns stopping a script from running.
-
cd
Tested cd examples: why no program could do this job, what cd - and $OLDPWD hold, and the two different answers cd .. gives under a symlink.
-
cp
Tested cp examples: copying files and whole trees, why a second cp -r nests the directory inside itself, and what -a preserves that a plain copy loses.
-
less
Tested less examples: the keys that move and search, why a piped less turns into cat, and how lesspipe lets it open a compressed file directly.
-
ln
Tested ln examples: why a symlink's target is resolved from the link's own directory, what a hard link shares, and the -n that stops a relink landing inside.
-
ls
Tested ls examples: the long format column by column, hidden files, sorting by time and size, symlinks, time styles, and why piped output looks different.
-
man
Tested man and apropos examples: what the section numbers mean, searching by description, finding which package shipped a page, and reading a synopsis.
-
mkdir
Tested mkdir examples: the two separate things -p does, why an existing file still fails it, and why -m never reaches the parents it invents.
-
mv
Tested mv examples: renaming and moving files, why a second mv nests a directory inside itself, and what changes once the destination is another filesystem.
-
rm
Tested rm examples: -r and -rf, why a directory's permissions decide what you may delete, and three ways a command removes more than the files you named.
-
touch
Tested touch examples: creating a file without truncating an existing one, setting access and modification times separately, and the timestamp nothing can set.
-
which
Tested which examples: how PATH order decides the answer, the shell script Debian ships in place of the GNU program, and the deprecation that was reversed.
-
Exit codes and error handling
How $?, PIPESTATUS, set -e, and pipefail combine to tell a script what succeeded and what failed, and where each one falls short.
-
File permissions explained
The rwx/owner-group-other model, numeric vs symbolic chmod, umask, and why setuid/setgid on directories behave differently than you'd expect.
-
Pipes and redirection
How | connects commands together, and how >, >>, 2>&1, and <() route data to and from files, other commands, and each other.
-
Terminal, shell and tty
What a terminal, a tty, a shell and a console each actually are, why Ctrl-D is not a signal, and why Ctrl-S appears to freeze everything.
-
Your first script
Write, mark executable, and run your first bash script, plus what the shebang line and PATH lookup do.
-
Variables and quoting
Why unquoted variables break bash scripts, when to use double vs single quotes, and how glob characters make it worse.
-
Conditionals and test
The difference between [ and [[ in bash, why unquoted variables crash [ but not [[, and pattern matching with case.
-
Loops
for, while and until in bash, iterating over files without breaking on spaces, and why a while read loop in a pipeline forgets everything it did.
-
Script arguments
How a script reads what it was called with: positional parameters, why "$@" and "$*" are not the same, shift, and parsing real flags with getopts.
-
Functions
Defining bash functions, why return gives a status not a value, how to hand data back, and why local separates a helper from a landmine.
-
Arrays
Indexed and associative arrays in bash: building them, why the @ and * subscripts differ, and filling one from command output without splitting.