LPIC-1 102-500 cheat sheet
LPIC-1 102-500 · Keep the key ideas within reach.
Shells and Shell Scripting
Shebang line selects the interpreter: #!/bin/bash runs the script with bash, #!/bin/sh with the system shell; the file must also be executable (chmod +x) or invoked as bash script.sh.
Exit status: 0 means success, non-zero means failure; $? holds the last command's status, and exit N sets the script's own status.
Positional parameters: $0 script name, $1..$9 arguments, ${10} onward needs braces; $# is the argument count, $@ and $* expand all arguments.
test/[ ] and [[ ]]: -f file exists and is regular, -d directory, -e exists, -r/-w/-x permissions, -z empty string, -n non-empty; numeric compare uses -eq -ne -lt -le -gt -ge.
Loops: for x in list; do ...; done iterates a list, while read line; do ...; done loop reads stdin line by line, until runs while the condition is false.
case pattern matching uses case $var in a) ...;; b|c) ...;; *) ...;; esac; patterns accept globs such as * and ?.
Quoting rules: single quotes preserve everything literally; double quotes allow $var, $(...) and backticks but block globbing and word splitting.
Redirection: > truncates, >> appends, 2> redirects stderr, &> both, < reads a file, <<EOF is a here-document, and command substitution is $(cmd) or backticks.
Interfaces and Desktops
X11 uses a display server (Xorg) with DISPLAY=:0 for the local display; remote X clients connect over TCP port 6000 or via ssh -X for forwarded X11.
Wayland replaces X11 with a compositor; XWayland provides compatibility for legacy X clients.
Display managers: GDM, LightDM, SDDM, and XDM start the graphical login and session; they are enabled as systemd services such as gdm.service.
Desktop environments: GNOME (gdm, gnome-shell), KDE Plasma (sddm, plasmashell), Xfce (lightdm, xfwm4); the session file lives in /usr/share/xsessions.
Accessibility on the desktop: Orca is the GNOME screen reader, and the on-screen keyboard is provided by GNOME's a11y settings or onboard.
The X server configuration is in /etc/X11/xorg.conf and /etc/X11/xorg.conf.d/*.conf; modern systems often use automatic configuration with no xorg.conf.
Fonts: fontconfig reads /etc/fonts/fonts.conf, and fc-cache rebuilds the font cache; user fonts live in ~/.local/share/fonts or ~/.fonts.
The xrandr command lists and configures outputs and resolutions; xdpyinfo prints display capabilities, and xwininfo queries windows.
Administrative Tasks
User management: useradd creates an account, usermod modifies it, userdel removes it, and passwd changes the password; the defaults are in /etc/default/useradd and /etc/login.defs.
Account files: /etc/passwd holds user records, /etc/shadow holds hashed passwords, /etc/group holds groups, and /etc/gshadow holds group passwords.
Group commands: groupadd, groupmod, groupdel, gpasswd manage groups; usermod -aG group adds a supplementary group without removing existing ones.
Cron: crontab -e edits the user table, and the fields are minute hour day-of-month month day-of-week command; /etc/crontab and /etc/cron.d/* include a user field.
systemd timers: a .timer unit triggers a matching .service; OnCalendar= defines the schedule, and systemctl list-timers shows the next run.
at schedules a one-time job: at 15:00 runs it, atq lists pending jobs, and atrm removes one; batch runs the job when load permits.
Logging: rsyslog rules are in /etc/rsyslog.conf with facility.priority selectors; journalctl reads the systemd journal, and journalctl -u unit filters by unit.
logrotate rotates logs using configs in /etc/logrotate.conf and /etc/logrotate.d/; options include rotate N, daily/weekly, and compress.
Essential System Services
systemd unit types: .service, .socket, .timer, .target, .mount, .path; systemctl start/stop/enable/disable/status controls them, and enable creates the symlink for boot.
systemctl daemon-reload is required after editing a unit file; systemctl mask prevents a unit from being started even as a dependency.
targets replace runlevels: multi-user.target is runlevel 3, graphical.target is runlevel 5, and systemctl get-default shows the default.
NTP time sync: chronyd is configured in /etc/chrony.conf and queried with chronyc sources; timedatectl shows and sets the system clock and timezone.
Syslog priorities from most to least severe: emerg, alert, crit, err, warning, notice, info, debug; facilities include kern, user, mail, daemon, auth.
The journal can be made persistent by setting Storage=persistent in /etc/systemd/journald.conf, which stores logs in /var/log/journal.
A unit file has [Unit], [Service], and [Install] sections; ExecStart runs the process, and WantedBy= in [Install] determines the enable target.
Mail transfer agents such as Postfix and Exim listen on port 25; a null client forwards all mail to a relay host defined by relayhost.
Networking Fundamentals
IPv4 addresses are 32 bits written in dotted decimal; the /N prefix or netmask splits network and host bits, and the broadcast address has all host bits set.
Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16; 127.0.0.0/8 is loopback, and 169.254.0.0/16 is link-local (APIPA).
IPv6 is 128 bits; ::1 is loopback, fe80::/10 is link-local, and address configuration can be SLAAC (RA) or DHCPv6.
Tools: ip addr shows addresses, ip route shows the routing table, ip link shows interfaces, and ss -tulpn lists listening TCP/UDP sockets with ports and processes.
Legacy tools: ifconfig, route, and netstat are deprecated but still appear; ping tests reachability with ICMP, and traceroute/tracepath shows the path.
Name resolution: /etc/hosts is checked before DNS; /etc/resolv.conf lists nameservers, and /etc/nsswitch.conf sets the lookup order (files dns).
Ports: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 123 NTP, 443 HTTPS, 3306 MySQL, 5432 PostgreSQL; /etc/services maps names to ports.
DHCP uses ports 67 (server) and 68 (client); a DHCP client request goes through DISCOVER, OFFER, REQUEST, ACK.
Security
File permissions: r=4, w=2, x=1; chmod 755 sets rwxr-xr-x, and chmod u+s sets setuid, g+s sets setgid, o+t sets the sticky bit.
Special bits: setuid on an executable runs it as the file owner, setgid on a directory makes new files inherit the group, and the sticky bit on a directory limits deletion to owners.
umask subtracts permissions from the defaults: umask 022 yields 755 for directories and 644 for files (files never get execute by default).
SSH keys: ssh-keygen creates the pair, ssh-copy-id installs the public key in ~/.ssh/authorized_keys, and the private key must stay mode 600.
GPG: gpg --gen-key creates a keypair, gpg --encrypt -r recipient encrypts, gpg --decrypt decrypts, and gpg --sign adds a signature.
sudo is configured in /etc/sudoers, edited with visudo; a rule like user ALL=(ALL:ALL) ALL grants full sudo, and NOPASSWD: skips the password prompt.
The shadow password hash field: a leading ! or * locks the account; chage -l user shows password aging, and passwd -l locks, passwd -u unlocks.
Firewalls: iptables/nftables rules filter packets; ufw allow 22/tcp and firewall-cmd --add-service=ssh manage host firewalls on Debian and RHEL families respectively.