CertGrid CertGrid

RHCSA command cheat sheet

The commands an EX200 task actually needs, grouped by objective domain - software, users, storage, file systems, services, networking and SELinux. Every output is from a real session on a RHEL 10.0 machine.

Finding out what you need

  • dnf provides */semanage

    Which package ships a command. The `*/` matters - without a slash dnf reads the argument as a package name.

    Full guide
  • rpm -qc <package>

    A package's configuration files. The fastest answer to "where does this service keep its config".

    Full guide
  • man -k <word>

    Search one-line descriptions only. Searching the word a task uses often fails - search the word the documentation would use.

    Full guide
  • namei -l <path>

    Every component of a path with its mode. Finds a denial three directories above the file.

    Full guide

Software

  • dnf makecache --repo <id>

    The only way to verify a repository. `dnf repolist` lists a broken repo as happily as a working one.

    Full guide
  • dnf install ./file.rpm

    A local package WITH dependency resolution. `rpm -ivh` refuses on unmet dependencies. The `./` is required.

    Full guide
  • dnf history undo last

    Reverse a transaction. The undo is itself logged, so it can be undone.

    Full guide
  • flatpak remote-add --if-not-exists <name> <url>

    Configure access to a Flatpak repository - one of the two new RHEL 10 objectives. Needs sudo for a system remote.

    Full guide

Users, groups and sudo

  • useradd -u <uid> -c "<comment>" -s <shell> -d <home> -m <name>

    An account built to specification. `-m` is required with a custom `-d`.

    Full guide
  • usermod -aG <group> <user>

    ALWAYS -aG. Plain -G replaces every secondary group, silently, with exit 0.

    Full guide
  • chage -M <max> -m <min> -W <warn> <user>

    Password ageing. `-E` is a different thing: an absolute account expiry date.

    Full guide
  • chage -l <user>

    Read the ageing policy with the dates decoded. What a grader would read.

    Full guide
  • visudo -c

    Validate sudoers. The ONLY reliable signal - a typo produces a bogus rule and sudo keeps working.

    Full guide

Storage

  • parted -s -a optimal <disk> mkpart <name> <start> <end>

    A GPT partition. parted writes immediately - there is no save step and no undo.

    Full guide
  • wipefs -a <partition>

    Clear a stale filesystem signature. On the DISK it does not reach inside where partitions used to be.

    Full guide
  • pvcreate <dev> · vgcreate <vg> <dev> · vgextend <vg> <dev>

    Build and grow a volume group. Growing needs no downtime.

    Full guide
  • lvcreate -L <size> -n <name> <vg> · -l 100%FREE

    Sizes round UP to a whole extent, and LVM says so. `-l` takes extents or a percentage.

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

    The one to memorise. `-r` grows the filesystem too, while mounted. Without it df does not change.

    Full guide
  • mkswap <dev> · swapon <dev> · swapon -a

    `swapon -a` reads fstab, which is what boot does - so it is the way to test a swap entry without rebooting.

    Full guide

File systems and mounting

  • mkfs.xfs · mkfs.ext4 · mkfs.vfat -F 32

    XFS is the RHEL default and can only ever GROW. Size it generously.

    Full guide
  • blkid -s UUID -o value <dev>

    Just the UUID, for a command substitution. Never type a UUID by hand.

    Full guide
  • findmnt --verify

    Checks every fstab entry without mounting. Run it before every reboot - a bad fstab loses the whole exam.

    Full guide
  • showmount -e <server>

    What a server exports. Comes with nfs-utils, which is NOT installed by default.

    Full guide
  • chmod 2770 <dir> · 3770 adds sticky

    SGID so new files take the directory group; sticky so members cannot delete each other's files.

    Full guide

Services, scheduling and logs

  • systemctl enable --now <unit>

    Both halves in one command. `start` alone is the single most expensive mistake on this exam.

    Full guide
  • systemctl show <unit> -p ActiveState -p UnitFileState

    The two facts, unambiguously named. Running and enabled are unrelated.

    Full guide
  • systemctl list-timers

    Next and last run for every timer. cron has no equivalent.

    Full guide
  • systemd-analyze calendar '<expr>'

    Test a schedule BEFORE relying on it. A cron mistake is only discovered by the job not running.

    Full guide
  • journalctl -b -1 -p err

    Errors from the previous boot. Needs a persistent journal, which is not the default.

    Full guide

Networking and the firewall

  • nmcli con mod <name> ipv4.method manual ipv4.addresses <a/p> ipv4.gateway <g>

    Edits the profile ONLY. Nothing changes until `nmcli con up`.

    Full guide
  • nmcli con mod <name> +ipv4.addresses <a/p>

    The `+` APPENDS. Plain assignment replaces the whole list - the same trap as usermod -G.

    Full guide
  • getent hosts <name>

    Resolution the way an application sees it. `dig` and `host` ignore /etc/hosts and will lie to you.

    Full guide
  • firewall-cmd --add-service=<name> --permanent && firewall-cmd --reload

    Both, always. `--permanent` alone does not change the running firewall; without it the rule dies at the next reload.

    Full guide
  • firewall-cmd --list-all

    The complete state of the active zone. The one command to verify any firewall task.

    Full guide

SELinux

  • semanage fcontext -a -t <type> "<path>(/.*)?"

    Writes the RULE. It does not relabel anything - the file is unchanged until restorecon.

    Full guide
  • restorecon -Rv <path>

    Applies policy to files. The second half of every context fix, and it undoes any chcon.

    Full guide
  • semanage port -a -t <type>_port_t -p tcp <port>

    Permission denied binding a FREE high port as root is an SELinux port label, not a conflict.

    Full guide
  • setsebool -P <boolean> on

    The `-P` is the whole thing. Without it the change is runtime only.

    Full guide
  • ausearch --input-logs -m AVC -ts recent

    WITH --input-logs. The bare form returned no matches on this machine while 16 denials sat in the log.

    Full guide