RHCSA study materials
RHCSA study resources

RHCSA cheat sheet

RHCSA · Keep the key ideas within reach.

Quick reference

Understand and use essential tools

  • man -k keyword searches manual page names and descriptions (apropos); run mandb first if the index is stale or newly installed pages are missing.

  • grep -r pattern /dir searches recursively; grep -E uses extended regular expressions; grep -v inverts the match and -n prints line numbers.

  • find /path -type f -name '*.conf' matches regular files by basename; -mtime -7 selects files modified in the last 7 days and -perm /u+s finds setuid files.

  • tar -czf archive.tar.gz dir creates a gzip-compressed archive; tar -tzf lists contents; tar -xzf extracts into the current directory.

  • ln -s /target /link creates a symbolic link; a hard link (ln target link) shares the inode and cannot span filesystems or link directories.

  • Output redirection: > truncates, >> appends, 2> captures stderr, &> captures both, and | pipes stdout to the next command; tee writes to a file and stdout.

  • rpm -q pkg reports installed version; rpm -ql lists files from an installed package; rpm -qf /path identifies the owning package; rpm -qp --scripts file.rpm shows scripts of a downloaded package.

  • File mode: chmod 640 file sets rw-r-----; chown user:group file changes owner and group; umask 027 yields new files 640 and directories 750.

  • cut -d: -f1 /etc/passwd extracts the first colon-separated field; sort -u sorts and removes duplicates; wc -l counts lines.

Quick reference

Manage software

  • dnf install pkg, dnf remove pkg, and dnf update pkg manage packages; dnf search term and dnf info pkg query repository metadata.

  • dnf provides /usr/bin/command or '*/filename' finds the package supplying a file when a command is missing.

  • Repository definitions live in /etc/yum.repos.d/*.repo; enabled=1 activates a repository and gpgcheck=1 verifies package signatures.

  • dnf repolist shows enabled repositories; dnf repolist --all includes disabled ones; dnf config-manager --set-enabled ID enables a repository.

  • dnf history lists transaction IDs; dnf history undo ID reverses a transaction; dnf history info ID shows transaction details.

  • dnf module list shows streams and profiles; dnf module enable name:stream selects a stream; dnf module install name/profile installs a profile.

  • rpm -qa lists all installed packages; rpm -qp --requires file.rpm shows dependencies of a downloaded package; dnf repoquery --requires pkg queries repository metadata.

  • dnf group list and dnf group install 'Group Name' manage package groups; group IDs are safer than display names.

Quick reference

Create simple shell scripts

  • The first line #!/bin/bash selects the interpreter; make a script executable with chmod +x script and run it as ./script or bash script.

  • Assign variables without spaces: name=value; read with $name or ${name}; export name makes it available to child processes.

  • Positional parameters: $1 is the first argument, $# is the count, and $0 is the script name; "$@" preserves argument boundaries while "$*" joins them.

  • The exit status of the last command is $?; exit N sets the script status; set -e exits on any unchecked failing command.

  • if [ -f file ]; then ...; fi tests files; [[ ... ]] adds pattern matching and safer string tests in bash.

  • Loops: for x in a b c; do ...; done; while read -r line; do ...; done < file processes a file line by line.

  • Arithmetic: ((count++)) or count=$((count+1)); command substitution $(command) captures stdout.

  • case "$1" in start) ... ;; stop) ... ;; *) echo usage ;; esac matches patterns and uses *) as the default.

  • Test operators: -e exists, -f regular file, -d directory, -r/-w/-x permissions, -z empty string, -n non-empty.

Quick reference

Operate running systems

  • systemctl start|stop|restart|status unit manages services; enable makes a unit start at boot; disable removes boot start; --now combines enable and start.

  • systemctl get-default prints the default target; set-default multi-user.target or graphical.target changes boot mode; isolate TARGET switches immediately.

  • journalctl -u unit shows unit logs; -f follows, -b limits to current boot, --since '1 hour ago' filters time; journald persistence is set by Storage= in /etc/systemd/journald.conf.

  • ps aux lists all processes with CPU and memory percentages; ps -ef lists every process in standard format; pgrep -u user matches processes by user; pkill -SIGNAL name signals by name.

  • Process priority ranges from -20 (highest) to 19 (lowest); nice -n 10 command starts lower priority; renice -n 5 -p PID changes a running process.

  • kill -TERM PID requests graceful termination; kill -KILL PID forces termination; kill -l lists signal names.

  • uptime shows load averages; free -h shows memory; vmstat 1 samples CPU, memory, and I/O every second.

  • crontab -e edits the current user's cron table; crontab -l lists it; systemctl enable --now crond ensures the cron service runs.

Quick reference

Configure local storage

  • lsblk shows block devices and mountpoints; blkid prints UUID and filesystem type; fdisk -l lists partition tables.

  • MBR supports four primary partitions and 2 TiB disks; GPT supports 128 partitions by default and larger disks; use parted for GPT labels.

  • parted /dev/sdb mklabel gpt; parted /dev/sdb mkpart primary xfs 1MiB 1GiB; partprobe /dev/sdb rereads the table.

  • LVM order: pvcreate /dev/sdb1, vgcreate vgname /dev/sdb1, lvcreate -L 1G -n lvname vgname; pvs, vgs, and lvs report status.

  • Extend LVM: lvextend -L +1G /dev/vg/lv; then xfs_growfs /mount for XFS or resize2fs /dev/vg/lv for ext4.

  • Swap: mkswap /dev/sdb1; swapon /dev/sdb1; add UUID=... swap swap defaults 0 0 to /etc/fstab for persistence.

  • Persistent mounts: use UUID= in /etc/fstab, run systemctl daemon-reload after editing, and mount -a to test; nofail prevents boot failure if absent.

  • Remove a partition or LV only after unmounting it; check with lsof or fuser /mountpoint to find processes using the mount.

Quick reference

Create and configure file systems

  • mkfs.xfs /dev/vg/lv creates XFS; mkfs.ext4 creates ext4; formatting destroys existing data on the device.

  • /etc/fstab fields: device, mount point, type, options, dump, fsck order; use UUID= and verify with mount -a before rebooting.

  • mount /dev/vg/lv /mnt attaches a filesystem; umount /mnt detaches it; findmnt shows the mount tree and source devices.

  • df -h reports filesystem usage; du -sh /path summarizes directory size; lsblk -f shows filesystem types and UUIDs.

  • XFS cannot shrink; ext4 can be shrunk offline with resize2fs after e2fsck. To grow XFS use xfs_growfs; for ext4 use resize2fs.

  • xfs_repair fixes XFS after unmounting; e2fsck -f checks ext4; never run fsck on a mounted read-write filesystem.

  • setfacl -m u:user:rw file grants an ACL entry; getfacl file displays ACLs; chmod affects the mode bits and mask.

  • Labels: xfs_admin -L label /dev/... for XFS; tune2fs -L label /dev/... for ext4; mount LABEL=label /mnt uses the label.

Quick reference

Deploy, configure, and maintain systems (includes Manage basic networking)

  • nmcli con show lists connection profiles; nmcli dev status shows device state; nmcli con up NAME activates a profile.

  • nmcli con mod NAME ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1; then nmcli con up NAME.

  • ip addr show displays addresses; ip route shows routes; ip link show displays interface state; changes via ip are not persistent.

  • hostnamectl set-hostname name sets the persistent static hostname; hostnamectl status displays it; add the name to /etc/hosts for local resolution.

  • firewall-cmd --list-all shows the active zone; --add-service=http and --add-port=8080/tcp change runtime; add --permanent and --reload for persistence.

  • systemctl enable --now firewalld starts and enables the firewall; firewall-cmd --get-default-zone prints the default zone.

  • timedatectl set-timezone America/New_York changes the timezone; timedatectl status shows NTP synchronization; chronyc sources lists time sources.

  • ssh-keygen -t ed25519 creates a key pair; ssh-copy-id user@host installs the public key; ~/.ssh/authorized_keys must be mode 600 and .ssh mode 700.

  • Test connectivity with ping, ss -tulnp for listening sockets, and nmcli networking connectivity check; use nmcli con reload after editing files in /etc/NetworkManager/system-connections/.

Quick reference

Manage users and groups

  • /etc/passwd fields: name, password placeholder, UID, GID, GECOS, home, shell; /etc/shadow stores hashed passwords and aging; /etc/group stores groups.

  • useradd -m -s /bin/bash -G wheel alice creates a user, home from /etc/skel, login shell, and supplementary group.

  • usermod -aG group user adds a supplementary group without removing others; usermod -L locks, -U unlocks, -s changes shell, -d changes home.

  • userdel -r alice removes the account, home directory, and mail spool; groupdel removes a group only if no user has it as primary group.

  • passwd alice sets a password; passwd -S alice shows status; chage -l alice lists aging; chage -M 90 alice sets maximum age.

  • id user shows UID, primary GID, and supplementary groups; groups user prints group names; getent passwd user queries NSS.

  • /etc/login.defs sets password aging and UID/GID ranges for new accounts; /etc/skel contents populate new home directories.

  • sudoers: edit with visudo; %wheel ALL=(ALL) ALL grants wheel members full sudo; /etc/sudoers.d/ files are included by default.

  • umask controls default permissions: umask 027 gives files 640 and directories 750; umask 077 gives files 600 and directories 700.

Quick reference

Manage security

  • getenforce prints Enforcing, Permissive, or Disabled; setenforce 0/1 toggles enforcing/permissive until reboot; persistent mode is SELINUX= in /etc/selinux/config.

  • ls -Z shows SELinux contexts; ps -Z shows process contexts; id -Z shows the current shell context.

  • restorecon -Rv /path resets file contexts to policy defaults; chcon changes a context temporarily and may be lost on relabel.

  • semanage fcontext -a -t httpd_sys_content_t '/web(/.*)?' adds a persistent mapping; restorecon -Rv /web applies it.

  • setsebool -P boolean on makes an SELinux boolean persistent; getsebool -a lists booleans; semanage boolean -l describes them.

  • firewall-cmd --permanent --add-service=ssh; firewall-cmd --reload opens the SSH port persistently in the active zone.

  • sshd hardening: PermitRootLogin no and PasswordAuthentication no in /etc/ssh/sshd_config; validate with sshd -t and reload sshd.

  • File permissions: chmod 600 ~/.ssh/authorized_keys and 700 ~/.ssh prevent sshd from rejecting key authentication.

  • Check SELinux denials with ausearch -m AVC -ts recent or sealert -a /var/log/audit/audit.log, which explains likely causes and fixes.