LFCE cheat sheet
LFCE · Keep the key ideas within reach.
Linux System Administration
systemd unit states: enabled = symlink in /etc/systemd/system/*.wants/; active = running now.
systemctl is-enabledandis-activeanswer different questions.systemctl daemon-reloadis required after editing any unit file; without it systemd keeps the old in-memory definition.Targets replace runlevels: multi-user.target ≈ runlevel 3, graphical.target ≈ runlevel 5.
systemctl get-defaultshows the default.journald persistence: /var/log/journal/ exists → logs persist across reboot; absent → logs live in /run/log/journal and are lost.
nicevalues range -20 (highest priority) to 19 (lowest); only root can set negative values.renice -nchanges a running process.Scheduling precedence on cron: /etc/cron.d and /etc/crontab include a user field; files in /etc/cron.{hourly,daily,weekly,monthly} run as root without one.
ulimit -nis per-process soft limit; hard limits (-H) can only be raised by root. Persistent values go in /etc/security/limits.conf or limits.d.Package manager decision: dpkg/rpm operate on local files and do not resolve dependencies; apt/dnf/yum resolve dependencies from repositories.
Networking
ip addr add 10.0.0.5/24 dev eth0does not persist; persistence is via NetworkManager (nmcli), systemd-networkd (.network files), or /etc/network/interfaces on Debian.ip route add default via 10.0.0.1sets the default gateway;ip route get 8.8.8.8shows which route and source address the kernel would use.ss -tulpnlists listening TCP/UDP sockets with process name and PID;-llistening,-tTCP,-uUDP,-pprocess,-nnumeric.nftables replaced iptables:
nft list rulesetdumps all tables/chains. Base chain hook types are input, output, forward, prerouting, postrouting.sysctl net.ipv4.ip_forward=1enables routing between interfaces; persist in /etc/sysctl.d/*.conf. Without it, forwarded packets are dropped.DNS resolution order is governed by /etc/nsswitch.conf (hosts line); /etc/resolv.conf lists nameservers,
searchdomains, andoptions ndots.dig +trace example.comwalks from the root servers down;dig @8.8.8.8 example.comqueries a specific resolver directly.Bonding modes: mode=1 active-backup needs no switch config; mode=4 (802.3ad/LACP) requires a LACP-configured switch port channel.
Storage Management
LVM stack order: physical volume (pvcreate) → volume group (vgcreate) → logical volume (lvcreate).
lvextend -rresizes the filesystem in the same step.XFS grows online with
xfs_growfsbut cannot shrink. ext4 grows online withresize2fsand shrinks only offline aftere2fsck./etc/fstabfields: device, mountpoint, fstype, options, dump, fsck-pass. Use UUID= or LABEL= because device names like /dev/sdb are not stable.mount -atests fstab without rebooting; a bad fstab entry can drop the system into emergency mode. Thenofailoption prevents boot failure.NFS export in /etc/exports:
ro/rw,sync,root_squash(maps remote root to nobody),no_subtree_check. Apply withexportfs -ra.Software RAID: mdadm --create --level=1 --raid-devices=2; /proc/mdstat shows rebuild progress. RAID is not a backup and does not replace snapshots.
dfreports filesystem-level free space;dusums file usage. A large gap usually means deleted-but-open files held by a process.blkidprints UUIDs and filesystem types;lsblk -fshows the device tree with mountpoints and filesystem labels.
Service Configuration and Security
SSH hardening: PermitRootLogin no, PasswordAuthentication no, AllowUsers/AllowGroups lists. Validate with
sshd -tbefore restarting.Key auth requires ~/.ssh permissions 700 on the directory and 600 on authorized_keys, owned by the target user; otherwise sshd silently rejects the key.
SELinux modes: enforcing, permissive, disabled.
getenforce/sestatusshow state;restorecon -Rvfixes mislabeled files;semanage fcontext -aadds persistent contexts.Firewalld zones bind interfaces/sources to rule sets;
firewall-cmd --permanentchanges are not active until--reload. Runtime and permanent configs are separate.TLS certificates:
openssl x509 -in cert.pem -noout -dates -subjectinspects validity and subject;openssl s_client -connect host:443tests the served chain.sudopolicy lives in /etc/sudoers and /etc/sudoers.d/; always edit withvisudoto catch syntax errors that would otherwise lock out sudo.PAM controls authentication stacking; /etc/pam.d/sshd and /etc/pam.d/system-auth define modules.
pam_tally2/faillockimplement lockout after failed logins.
Troubleshooting and Automation
Boot diagnosis order: GRUB → initramfs → root mount → systemd targets.
journalctl -b -1reads the previous boot;-p errfilters to errors.systemd-analyze blameranks units by boot time;systemd-analyze critical-chainshows the dependency path that actually delayed boot.strace -f -p PIDtraces syscalls of a running process;-e trace=open,connectnarrows output. Useful when a service fails without a clear log line.tcpdump -i eth0 -nn port 443captures traffic without name resolution;-w file.pcapwrites for later analysis.Ansible idempotence: modules like
copy,service,packagereport changed only when state differs;command/shellalways report changed unlesschanged_whenis set.Ansible inventory groups plus
hosts:targeting;--checkruns a dry run and--diffshows file content changes.Shell strict mode:
set -euo pipefailexits on error, undefined variable, or failed pipeline stage.trap 'cleanup' EXITruns cleanup on any exit.lsof +L1finds deleted files still held open - the usual cause when df shows full but du does not.