Security
-
File permissions
The Unix permission model — read/write/execute, owner/group/other, special bits.
6 minls -lnamei -lchmod -
sudo — running commands as another user
Grants temporary root rights via sudoers; edit the file only through visudo, or a mistake locks everyone out of sudo.
5 minapt updatesudoeditvisudo -f -
visudo — edit sudoers safely
The visudo command edits /etc/sudoers and files in /etc/sudoers.d and refuses to save a rule with a grammar error.
6 minvisudovisudo -fchmod -
PAM: login checks, password policy and lockout
The module stack in /etc/pam.d decides whether to let a user in, which password to accept and when to lock them out.
15 mingrep -vpam-auth-update --enableecho -
Users and groups
Linux accounts and groups; usermod -G without -a replaces all of a user's supplementary groups instead of adding one.
5 minid aliceuseradd -musermod -aG -
Firewall — nftables / ufw
The Linux firewall: filtering traffic with simple ufw and low-level nftables, checking the rules.
6 minufw allowufw statusufw default -
useradd — create a user
The useradd command creates a user account with a home directory, shell, groups and UID; passwd sets the password.
6 minuseradd -mpasswd aliceuseradd -r -
passwd — change or lock a password
The passwd command changes your own password; as root it sets, locks and shows the passwords of other users.
6 minpasswdpasswd alicepasswd -S -
usermod — change an account and its groups
The usermod command changes an existing account — groups, login shell, home directory, name and locking.
6 minusermod -aGusermod -rGusermod -G -
The classic iptables firewall
The classic Linux firewall — chains, rules, NAT, and why nftables replaced it.
5 miniptables -Liptables -Aiptables -I -
auditd — security auditing
Kernel-level auditing — who did what and when; watch rules and event search.
8 minauditctl -wauditctl -aauditctl -l -
ssh, scp — connecting and copying over SSH
A client for logging in and copying files over SSH; host aliases in ~/.ssh/config remove repeated connection parameters.
3 minsshssh -pscp file -
sshd — the SSH server
The OpenSSH server; edit the config with a second session open — a mistake in PermitRootLogin locks you out immediately.
5 minsshd -tsshd -Tsystemctl reload -
Special permission bits: setuid, setgid, sticky
Special permission bits: setuid and setgid run a program as its owner; setgid and sticky shape shared directories.
7 minls -ldchmodstat -c -
Capabilities: root split into parts
Parts of root's rights: a process or a file gets only the one it needs, e.g. CAP_NET_BIND_SERVICE for a low port.
12 mingrepcapshgetpcaps -
SSH keys and ssh-agent
Key pairs for passwordless login; sshd rejects ~/.ssh if it is writable by the group or by others.
5 minssh-keygen -tssh-copy-idssh-keygen -l -
Extended permissions (ACL)
Flexible rights beyond rwx — getfacl/setfacl, per-user and per-group grants.
4 mingetfacl filesetfacl -msetfacl -d -
ssh-keyscan — collecting host keys
Pre-populate known_hosts with server keys — skip the interactive "yes" on first ssh.
5 minssh-keyscanssh-keyscan -Hssh-keyscan -t -
Service hardening: User=, ProtectSystem, NoNewPrivileges
Unit settings that strip a service of root, system writes and new privileges; systemd-analyze security rates them.
13 minsystemd-analyze securitysystemctl showsystemctl edit -
AppArmor
Mandatory access control on Ubuntu — service profiles, enforce/complain modes.
8 minaa-statusjournalctl -kaa-complain -
nmap: which ports are visible from outside
A port scanner: shows which ports of a machine are open, closed or filtered, as another machine sees them.
8 minnmapnmap -pnmap -p- -
restic — deduplicated backups
Incremental encrypted backups with snapshots; without the password the repository cannot be decrypted at all.
4 minrestic initrestic backuprestic snapshots -
unattended-upgrades: security updates with no one at the keyboard
Ubuntu's service that installs updates from allowed origins once a day on an apt timer; by default only security ones.
12 minsystemctl list-timerscatapt-config dump -
fail2ban
Log-based banning — protecting SSH and services from brute force; jails, status, unban.
7 minfail2ban-client statusfail2ban-client setfail2ban-regex -
GPG — encryption and signatures
GnuPG: GPG keys, encrypting files, signing and verifying, symmetric mode with a passphrase.
5 mingpg -cgpg -dgpg -e -
TLS and certificates — openssl, the chain, verification
A TLS certificate binds a server key to a site name; openssl reads its fields, checks the chain and issues a new one.
11 minopensslopenssl verifycurl --cacert -
WireGuard — VPN on keys
A fast VPN on a key pair instead of passwords; the private key in wg0.conf needs permissions, like an SSH key.
4 minwg genkeywg-quick upwg show