CertGrid CertGrid

LPIC-2 command cheat sheet

The commands 201-450 and 202-450 ask for, grouped by LPI topic number. Storage and kernel work is captured on a real spare disk and real modules; the DNS rows are captured from a client that runs no name server, which is the only way to know a service actually answers.

Topic 201 - Linux kernel

  • lsmod

    Loaded modules. The third column is a reference count - non-zero means it cannot be unloaded until its users go first.

    Full guide
  • modinfo <mod> · modinfo -p <mod>

    Reads the module file on disk without loading it. `-p` lists the parameters it accepts, which is the fastest answer to "what can I tune".

    Full guide
  • modprobe <mod> <param>=<value>

    Loads the module AND its dependencies. `insmod` takes a path and resolves nothing, which is why it fails on anything with a dependency.

    Full guide
  • modinfo -F depends <mod> · depmod -a

    Dependencies come from `modules.dep`, which `depmod` writes. Add a module by hand and modprobe will not find it until you rerun depmod.

    Full guide
  • modprobe -r <mod>

    Unloads it and anything it pulled in. Interfaces or devices the module created disappear with it.

    Full guide
  • sysctl <name> == cat /proc/sys/<name with / for .>

    The dots are directory separators. `net.ipv4.ip_forward` IS `/proc/sys/net/ipv4/ip_forward`.

    Full guide
  • sysctl -w <name>=<value> (runtime only)

    Changes the running kernel and nothing on disk. Lasts until reboot - which is why a setting "keeps resetting itself".

    Full guide
  • /etc/sysctl.d/*.conf then sysctl --system

    The persistent half. Writing the file alone changes nothing until reboot; `--system` re-reads them all now.

    Full guide

Topics 203/204 - Filesystems and advanced storage

  • lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT <disk>

    Prove a disk is spare before destroying it: no partitions, no filesystem, no mountpoint - and check root is elsewhere.

    Full guide
  • pvcreate <disk> · pvs · pvdisplay

    A bare PV reports `Allocatable NO` and `Total PE 0` - the extent size is decided by the volume group, so that is not an error.

    Full guide
  • vgcreate <vg> <pv> · vgdisplay <vg>

    The VG sets the extent size - 4 MiB by default. Every LV is a whole number of extents, which is why sizes round.

    Full guide
  • lvcreate -n <lv> -L <size> <vg>

    Reachable at both `/dev/<vg>/<lv>` and `/dev/mapper/<vg>-<lv>`. `lvs` reports the first, `df` the second.

    Full guide
  • lvextend -L +<size> <lv> (device only)

    Grows the block device. `df` still shows the OLD size - stopping here is the commonest LVM mistake.

    Full guide
  • resize2fs <lv> (ext) · xfs_growfs <mountpoint> (XFS)

    The second half. `lvextend -r` does both at once. XFS takes the MOUNTPOINT, not the device, and cannot be shrunk at all.

    Full guide
  • mdadm --create /dev/md0 --level=1 --raid-devices=2 --spare-devices=1 <devs>

    RAID 1 capacity equals ONE device - the mirrors buy redundancy, not space.

    Full guide
  • mdadm --fail <md> <dev> · mdadm --detail <md>

    The spare is promoted automatically and the array stays `clean`. Watch a real rebuild in /proc/mdstat.

    Full guide

Topic 207 - Domain name server

  • named-checkconf

    Validate named.conf before restarting anything. Silence means valid - it reports problems and nothing else.

    Full guide
  • named-checkzone <zone> <file>

    Echoes the serial it loaded, so it doubles as a check that you remembered to increment it.

    Full guide
  • named-checkzone (a failure)

    A bad record names the line and the reason, and the zone is `NOT LOADED`. Restarting with a broken zone keeps serving the OLD data instead.

    Full guide
  • dig @<server> <name> +short (from a CLIENT)

    The only query worth trusting. From the server itself it proves the zone parsed and nothing about reachability.

    Full guide
  • dig @<server> <cname> +short

    A CNAME shows the whole chain - target name first, then its address.

    Full guide
  • dig <name> → status: NXDOMAIN

    The name does not exist, authoritatively (`aa` flag). `+short` shows nothing AND exits 0, which is the trap.

    Full guide
  • dig <out-of-zone name> → status: REFUSED

    Not a failure - a policy. `recursion no` means this server answers only for its own zones, which is what an authoritative server should do.

    Full guide
  • communications error (nothing listening)

    A transport error, not a DNS status - no header, no flags. Distinguish it from a silent timeout, which usually means a firewall dropped the packet.

    Full guide