CertGrid CertGrid

LFCS command cheat sheet

The commands an LFCS task actually needs, grouped by the five objective domains. Every output is from a real session - Ubuntu 26.04 where the exam is most likely to put you, RHEL 10 where the two families differ.

Domain 1 - Essential Commands (20%)

  • stat -c '%A %a %U:%G %n' <file>

    Mode, owner and size in one line you choose the shape of. `ls -l` for reading, `stat -c` for scripting.

    Full guide
  • find . -type f -size +1k

    Size filters take `k`, `M`, `G` - and round UP to whole units, which is why a `+1k` matches a 1-byte file on some filesystems.

    Full guide
  • chmod 640 <file>

    Numeric sets all three groups at once; symbolic (`g+w`) changes one and leaves the rest. Use numeric when a task states the whole mode.

    Full guide
  • grep -E '<pattern>' <file>

    Extended regex without the backslashes. `-c` counts, `-n` numbers, `-i` ignores case, `-v` inverts.

    Full guide
  • tar -tf <archive>

    ALWAYS list before extracting. An archive with absolute paths or `../` will write outside the directory you are standing in.

    Full guide

Domain 2 - Operations Deployment (25%)

  • dpkg -S <path> / rpm -qf <path>

    Which package owns a file. `-S` searches and `-L` lists on Debian; `-qf` and `-ql` on Red Hat. The most-fumbled pair in the domain.

    Full guide
  • dnf provides <path>

    Finds the package for a command you do NOT have. apt has no built-in equivalent - `apt-file` is a separate package needing `apt-file update`.

    Full guide
  • dpkg -V <pkg> / rpm -V <pkg>

    Silence means every file matches what was installed. Column 3 is the checksum and is the one that always catches a content change.

    Full guide
  • apt-mark hold <pkg> / showhold

    Run `showhold` when an upgrade mysteriously skips one package. dnf uses `exclude=` in dnf.conf, or the versionlock plugin.

    Full guide
  • systemctl --failed

    The first command to run on a machine you have inherited. It is short, and anything in it is a real problem.

    Full guide
  • journalctl -u <unit> -n 20

    `-b` for this boot, `--since "1 hour ago"`, `-p err` for priority, `-f` to follow. `-o short-iso` for timestamps you can sort.

    Full guide
  • ps -eo <fields> --sort=-pcpu

    Choose your own columns and sort by one. Far more useful under pressure than memorising what `aux` happens to print.

    Full guide

Domain 3 - Users and Groups (10%)

  • useradd -m -c "<comment>" <user>

    `-m` creates the home directory and is NOT the default on every distribution. Without it the account exists and cannot log in usefully.

    Full guide
  • getent passwd <user>

    Seven fields: name, password placeholder, UID, GID, comment, home, shell. `getent` reads every source, not just the file.

    Full guide
  • chage -m 7 -M 90 -W 14 -I 30 <user>

    Minimum, maximum, warning, inactive. `chage -l` reads them back, and `-d 0` forces a change at next login.

    Full guide
  • visudo -c -f <file>

    Check a sudoers fragment BEFORE installing it. A syntax error in `/etc/sudoers` locks everyone out of sudo, including you.

    Full guide

Domain 4 - Networking (25%)

  • ip -brief addr show

    One line per interface. `link` is the interface, `addr` is the IP on top of it - an interface can be UP with no address, which is a distinct fault.

    Full guide
  • ip route / ip route get <dest>

    `get` asks the kernel which line it would use, and sends nothing. Run it before ping - it separates "no route" from "route exists, path broken".

    Full guide
  • grep ^hosts: /etc/nsswitch.conf

    `files dns` is why `/etc/hosts` wins. This one line explains more resolution mysteries than any other file on the system.

    Full guide
  • getent hosts <name>

    What a PROGRAM would get, via nsswitch. `dig` skips nsswitch entirely and never reads `/etc/hosts` - which is why the two disagree.

    Full guide
  • ss -lntp

    listening, numeric, tcp, process. Always `-n` - without it ss reverse-resolves every address and hangs on the very host you are debugging.

    Full guide
  • sshd -t / sshd -T

    `-t` checks syntax before a restart; `-T` prints the EFFECTIVE config after every include. Read `-T`, never the file.

    Full guide
  • firewall-cmd --list-all

    Zone, interfaces, services and ports at once. Run it FIRST - a rule added to the wrong zone has no effect and no error.

    Full guide
  • firewall-cmd --add-port=8080/tcp --permanent && firewall-cmd --reload

    Runtime and permanent are separate stores. Neither flag does both, and `--reload` discards unsaved runtime rules. `--runtime-to-permanent` commits a set you have already tested.

    Full guide

Domain 5 - Storage (20%)

  • blkid -s UUID -o value <dev>

    The UUID for the fstab line. Device names are assigned in discovery order and a `/dev/sdb1` in fstab is a machine that will eventually fail to boot.

    Full guide
  • findmnt --verify

    Validates fstab WITHOUT mounting. Run it after every edit - it also catches the `systemctl daemon-reload` you have not done yet.

    Full guide
  • vgdisplay <vg>

    PE Size is 4 MiB by default and every logical volume is a whole number of extents. `-l 100%FREE` takes the rest with no arithmetic.

    Full guide
  • lvextend -r -L +<size> <lv>

    `-r` resizes the volume AND the filesystem, in the right order, calling the right tool. `+` is relative; without it you may be shrinking.

    Full guide
  • fallocate -l 256M f && chmod 600 f && mkswap f && swapon f

    Four commands in that order. `fallocate` not `truncate` - swap on a sparse file loses machines. 600 before mkswap.

    Full guide
  • lsof +L1 <mountpoint> | grep <mountpoint>

    Deleted-but-open files - when `df` and `du` disagree. Grep the path: `+L1` alone also lists systemd memfds and hands you PID 1.

    Full guide
  • df -i <mountpoint>

    Full with 99% of the space free means inodes. ext4 fixes the count at mkfs time and it cannot be changed afterwards; xfs has no such limit.

    Full guide
  • tune2fs -m 1 <dev>

    Reclaims most of ext4's 5% root reserve instantly, on a mounted filesystem. An emergency lever for a data volume - never for `/`.

    Full guide