Master every domain of the CompTIA Linux+ XK0-005 exam. This course covers Linux foundations and the boot process, package management across distro families, user and permission management, storage and LVM, networking with modern tools, security hardening with SELinux and AppArmor, bash scripting, containers, and real-world troubleshooting workflows — with precise command syntax and exam-aligned explanations throughout.
Tune in to Linux tips, security hardening walkthroughs, and exam strategies while commuting or working out. New episodes weekly.
Listen on Spotify/bin (essential binaries), /sbin (system binaries), /etc (config files), /var (variable data), /usr (user programs), /tmp (temporary), /proc (kernel/process virtual FS), /sys (device/driver info)/boot/grub2/grub.cfg (RHEL/Fedora) or /boot/grub/grub.cfg (Debian/Ubuntu)grub.cfg directly — edit /etc/default/grub and regenerate with grub2-mkconfig -o /boot/grub2/grub.cfg/etc/default/grub parameters: GRUB_TIMEOUT (menu delay), GRUB_CMDLINE_LINUX (kernel parameters), GRUB_DEFAULT (default entry)grub rescue> promptgrub rescue> ls — list detected partitions (e.g., (hd0,gpt1), (hd0,gpt2))grub rescue> ls (hd0,gpt2)/ — check for /boot/grub2/ directorygrub rescue> set root=(hd0,gpt2) — set the root partitiongrub rescue> set prefix=(hd0,gpt2)/boot/grub2 — point to GRUB modulesgrub rescue> insmod normal then grub rescue> normal — load normal GRUB mode/boot/grub2/grub.cfg on RHEL/CentOS systems. Always regenerate with grub2-mkconfig after editing /etc/default/grub. Editing grub.cfg directly is wrong — changes are overwritten on update.poweroff.target — runlevel 0, system haltrescue.target — runlevel 1 / single-user mode; minimal services, root shell for recoverymulti-user.target — runlevel 3; full multi-user, no GUI; standard for serversgraphical.target — runlevel 5; multi-user with desktop environmentreboot.target — runlevel 6, system restartsystemctl get-default — view current default targetsystemctl set-default multi-user.target — change default target persistentlysystemctl isolate rescue.target — switch to rescue mode immediately (non-persistent)systemd.unit=rescue.target to the kernel command line in GRUB. This is the standard recovery technique for forgotten root passwords alongside rd.break./boot/initramfs-$(uname -r).img (RHEL) or /boot/initrd.img-$(uname -r) (Debian)dracut --force /boot/initramfs-$(uname -r).img $(uname -r)update-initramfs -u -k $(uname -r)/etc/crypttablsinitrd /boot/initramfs-$(uname -r).img | less — inspect initramfs contents (RHEL)dracut --force (RHEL) or update-initramfs -u (Debian) is often the fix. The exam tests which tool to use per distro family.lsmod — list currently loaded kernel modules and their dependenciesmodinfo MODULE — display module metadata: description, author, parameters, filenamemodprobe MODULE — load a module and its dependencies automaticallymodprobe -r MODULE — remove (unload) a module and unused dependenciesrmmod MODULE — remove a module directly (does not handle dependencies)insmod /path/to/module.ko — insert a module by file path (no dependency resolution)/etc/modprobe.d/ — directory for module configuration files (e.g., aliases, options, blacklisting)/etc/modprobe.d/blacklist-MODULE.conf with blacklist MODULEoptions MODULE param=value in a conf file under /etc/modprobe.d//etc/modules-load.d/*.conf filesmodprobe over insmod in almost all cases — modprobe resolves dependencies automatically. insmod requires the full path and won't load required dependencies first.rpm -ivh package.rpm — install a package (-i) with verbose output (-v) and progress bar (-h)rpm -Uvh package.rpm — upgrade a package (installs if not present)rpm -e PACKAGENAME — erase (remove) an installed packagerpm -qa — query all installed packages; combine with grep to searchrpm -qi PACKAGENAME — detailed info about an installed packagerpm -ql PACKAGENAME — list files owned by an installed packagerpm -qf /path/to/file — which package owns a given filerpm -V PACKAGENAME — verify package integrity (checks checksums, permissions, ownership)rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release — import a GPG signing keyrpm -V output codes: S=file size changed, M=mode changed, 5=MD5 checksum mismatch, U=user ownership changed. A dot (.) means no change. This is a frequently tested command on the Linux+ exam.dnf install PACKAGE — install a package and resolve dependenciesdnf remove PACKAGE — remove a packagednf update — update all packages to latest available versionsdnf update PACKAGE — update a specific packagednf search KEYWORD — search for packages by name or descriptiondnf info PACKAGE — show detailed package metadatadnf provides /path/to/file — find which package provides a file or commanddnf history — show transaction history; dnf history undo N reverses transaction Ndnf group install "Development Tools" — install a package groupdnf repolist — list enabled repositories/etc/yum.repos.d/ with .repo extension[repo-id], name, baseurl or mirrorlist, enabled=1, gpgcheck=1, gpgkey=dnf config-manager --add-repo URL — add a new repositorydnf config-manager --enable REPO_ID / --disable REPO_ID — toggle reposdnf update refreshes and installs newer package versions; dnf upgrade is an alias. dnf check-update lists available updates without installing them. Also: yum is the legacy name — on modern RHEL 8+ systems it is a symlink to dnf.dpkg -i package.deb — install a .deb package filedpkg -r PACKAGENAME — remove a package (keeps config files)dpkg -P PACKAGENAME — purge a package (removes config files too)dpkg -l — list all installed packages with status codesdpkg -L PACKAGENAME — list files installed by a packagedpkg -S /path/to/file — which package owns a given filedpkg --get-selections | grep PACKAGENAME — check package installation statusapt update — refresh the local package index (downloads metadata from repos)apt upgrade — install available package updatesapt install PACKAGE — install a package with dependenciesapt remove PACKAGE — remove package, keep config; apt purge PACKAGE removes config tooapt autoremove — remove packages that were installed as dependencies but are no longer neededapt search KEYWORD — search packages; apt-cache search KEYWORD (older syntax)apt show PACKAGE — show package details/etc/apt/sources.list and /etc/apt/sources.list.d/*.listapt update only refreshes the local package cache — it does NOT install any updates. apt upgrade installs the available updates. This two-step pattern is a classic exam question. Always run apt update before apt install on a freshly started system.zypper install PACKAGE (or zypper in PACKAGE) — install a packagezypper remove PACKAGE (or zypper rm PACKAGE) — remove a packagezypper update (or zypper up) — update installed packageszypper search KEYWORD (or zypper se KEYWORD) — search for packageszypper info PACKAGE — display detailed package informationzypper repos (or zypper lr) — list configured repositorieszypper addrepo URL ALIAS — add a new repositoryzypper refresh (or zypper ref) — refresh repository metadatain, rm, up, se, lr) as they appear in practical scenarios.wget https://example.com/app-1.0.tar.gz then tar -xzf app-1.0.tar.gz./configure — checks for required build dependencies, sets compile options, generates Makefile./configure --prefix=/usr/local — install to a custom directory (default is /usr/local)make — compiles the source code using the generated Makefilemake install — installs compiled binaries to the prefix directorymake uninstall — remove installed files (if the Makefile supports it)gcc, make, autoconf, automake, libtool, kernel-develdnf groupinstall "Development Tools" installs the full toolchainapt install build-essential./configure mean a -devel / -dev package is not installed./configure fails with "missing library", install the corresponding -devel package (RHEL) or -dev package (Debian). The configure script reports the exact missing dependency in its error output.useradd USERNAME — create a new user; add -m to create home dir, -s /bin/bash to set shell, -u UID for specific UIDusermod -aG GROUP USERNAME — add user to a supplementary group (-a is critical — appends instead of replacing)usermod -s /sbin/nologin USERNAME — disable login shell for a service accountuserdel USERNAME — delete a user; userdel -r USERNAME also removes home directory and mail spoolid USERNAME — display UID, GID, and all supplementary groups for a usergroupadd GROUPNAME — create a new group; groupmod -n NEWNAME OLDNAME — rename; groupdel GROUPNAME — deletenewgrp GROUPNAME — switch active primary group in the current session without logging out/etc/passwd — format: username:x:UID:GID:comment:home:shell/etc/shadow — format: username:hashed_password:last_change:min:max:warn:inactive:expire/etc/group — format: groupname:x:GID:member1,member2-a flag with usermod -G is critical. Running usermod -G GROUP USER without -a REPLACES all supplementary groups with only the specified group — this is a classic misconfiguration that locks users out of shared resources.passwd USERNAME — set or change a user's password; passwd -l USERNAME locks, passwd -u USERNAME unlockschage -M 90 USERNAME — set maximum password age to 90 dayschage -m 7 USERNAME — set minimum days before password can be changedchage -W 14 USERNAME — warn user 14 days before password expirationchage -E 2026-12-31 USERNAME — set account expiration datechage -l USERNAME — list all aging information for a user/etc/pam.d/ config filespam_pwquality module enforces password complexity (length, uppercase, digits, special characters)/etc/security/pwquality.conf: minlen=12, ucredit=-1, dcredit=-1, ocredit=-1/etc/login.defs — system-wide defaults: PASS_MAX_DAYS, PASS_MIN_DAYS, PASS_WARN_AGE, UID_MIN, UID_MAXrequired (must pass, continues), requisite (must pass, stops on fail), sufficient (if pass, no further required checks), optional (result ignored unless only module).chmod 755 file — numeric: owner rwx (7), group r-x (5), others r-x (5)chmod u+x,g-w file — symbolic: add execute to owner, remove write from groupchmod -R 750 /dir — recursive permission changechown USER:GROUP file — change owner and group; chown USER file — change owner onlychgrp GROUP file — change group ownership onlyumask defines default permissions by masking bits from 666 (files) and 777 (directories)022: files get 644 (rw-r--r--), directories get 755 (rwxr-xr-x)umask 027: files get 640, directories get 750 — more restrictive, suitable for shared servers/etc/bashrc or ~/.bashrc/usr/bin/passwd runs as root. Set with chmod 4755 file or chmod u+s filechmod 2755 file or chmod g+s dir/tmp. Set with chmod 1777 dir or chmod +t dirls -l shows s in place of x for SUID/SGID, t in place of x for sticky bit in others positiongetfacl file — display the full ACL for a file or directorysetfacl -m u:USERNAME:rwx file — grant a specific user rwx on a filesetfacl -m g:GROUPNAME:r-- file — grant a group read-only accesssetfacl -x u:USERNAME file — remove a user's ACL entrysetfacl -b file — remove all ACL entries (except base permissions)setfacl -m mask::r-- file — set the effective rights mask (limits maximum ACL permissions)setfacl -d -m u:USERNAME:rwx /dir — set a default ACL (-d): new files/directories created inside inherit this ACL+ sign in ls -l output indicates ACL entries beyond standard permissions are settune2fs -l /dev/sdX | grep "Default mount"getfacl to see effective permissions after mask application.fdisk /dev/sdX — interactive MBR partition editor; n (new), d (delete), t (change type), w (write), q (quit)gdisk /dev/sdX — interactive GPT partition editor (same command letters as fdisk)parted /dev/sdX — supports both MBR and GPT; non-interactive mode: parted /dev/sdX mklabel gptlsblk — list block devices and partition layout; blkid — show UUIDs and filesystem typesfdisk for MBR disks up to 2 TB. For GPT or disks larger than 2 TB, use gdisk or parted. The exam will present scenarios requiring you to identify the correct partitioning tool based on disk size and UEFI vs BIOS context.mkfs.ext4 /dev/sdX1 — format a partition as ext4; -L LABEL to add a volume labelmkfs.xfs /dev/sdX1 — format as XFS (default on RHEL 7+)tune2fs -L NEWLABEL /dev/sdX1 — change ext2/3/4 volume label; tune2fs -c 50 — set max mount count before fsckxfs_admin -L NEWLABEL /dev/sdX1 — change XFS volume labele2fsck -f /dev/sdX1 — check and repair an ext filesystem (must be unmounted)xfs_repair /dev/sdX1 — check and repair an XFS filesystem (must be unmounted)mount /dev/sdX1 /mnt/data — mount temporarily; mount -o ro /dev/sdX1 /mnt — mount read-onlyumount /mnt/data — unmount; use lsof /mnt/data or fuser /mnt/data if "device busy"/etc/fstab format: UUID=... /mountpoint fstype options dump passblkid) in fstab, not device names — device names can change across rebootsdefaults, noatime, nosuid, noexec, romount -a — mount all entries in fstab that aren't already mounted (tests fstab syntax)e2fsck first). The exam will present a scenario asking about resizing, and the correct answer depends on the filesystem type.pvcreate /dev/sdX — initialize a physical volumevgcreate myvg /dev/sdX — create a volume group; vgextend myvg /dev/sdY — add a PV to VGlvcreate -L 20G -n mylv myvg — create a 20G logical volumelvextend -L +10G /dev/myvg/mylv — increase LV size by 10Glvextend on ext4: resize2fs /dev/myvg/mylv to grow the filesystemlvextend on XFS: xfs_growfs /mountpoint to grow the filesystem (XFS grow is online)lvreduce -L -5G /dev/myvg/mylv — decrease LV size (ext4 only, must unmount first)pvs / vgs / lvs — brief display of PV/VG/LV informationpvdisplay / vgdisplay / lvdisplay — detailed outputlvcreate -L 5G -s -n snap /dev/myvg/mylv — create a snapshot of an LVe2fsck -f → resize2fs to new smaller size → lvreduce. XFS cannot be shrunk at all. The exam frequently tests this order-of-operations for both grow and shrink scenarios.mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sd{b,c,d} — create RAID 5cat /proc/mdstat — view RAID status and rebuild progressmdadm --detail /dev/md0 — detailed RAID array infomdadm --add /dev/md0 /dev/sde — add a hot spare or replacement drivemdadm --fail /dev/md0 /dev/sdb — mark a drive as failed; mdadm --remove /dev/md0 /dev/sdb — remove it/etc/mdadm.conf or /etc/mdadm/mdadm.conf — persist RAID config across rebootsmkswap /dev/sdX2 — format a partition as swap spaceswapon /dev/sdX2 — activate swap; swapoff /dev/sdX2 — deactivateswapon -s (or swapon --show) — list active swap devices with priority and usage/etc/fstab: UUID=... none swap sw 0 0fallocate -l 2G /swapfile → chmod 600 /swapfile → mkswap /swapfile → swapon /swapfilecat /proc/sys/vm/swappiness — view swappiness (default 60); lower values reduce swap aggressivenesssysctl vm.swappiness=10 — set swappiness temporarily; persist in /etc/sysctl.d/99-swap.confcryptsetup luksFormat /dev/sdX1 — initialize a LUKS encrypted container (destroys data)cryptsetup luksOpen /dev/sdX1 cryptdata — unlock the container; creates /dev/mapper/cryptdatamkfs.ext4 /dev/mapper/cryptdata — create filesystem on the unlocked devicemount /dev/mapper/cryptdata /mnt/secure — mount the encrypted filesystemcryptsetup luksClose cryptdata — lock/close the containercryptsetup luksDump /dev/sdX1 — display LUKS header info (slots used, cipher)/etc/crypttab — maps LUKS devices to mapper names for auto-unlock at boot (with keyfile or passphrase prompt)/etc/crypttab and /etc/fstab, you must rebuild the initramfs (dracut --force on RHEL) so the initramfs includes the cryptsetup tools needed to unlock the device early in the boot process.ip command (from the iproute2 package) replaces deprecated tools: ifconfig, route, arp, netstatip addr show (or ip a) — display IP addresses on all interfacesip addr add 192.168.1.10/24 dev eth0 — assign an IP address (non-persistent)ip addr del 192.168.1.10/24 dev eth0 — remove an IP addressip link show — display network interface state; ip link set eth0 up/down — bring interface up/downip route show (or ip r) — display the routing tableip route add default via 192.168.1.1 — add a default gateway (non-persistent)ip route add 10.0.0.0/8 via 192.168.1.254 dev eth0 — add a static routeip neigh show — display the ARP/neighbor cacheip command are not persistent across reboots. For persistent configuration, use NetworkManager (nmcli) or edit interface config files in /etc/NetworkManager/system-connections/.nmcli connection show — list all configured network connectionsnmcli connection show --active — list only active connectionsnmcli connection up CONNECTION_NAME — activate a connectionnmcli connection down CONNECTION_NAME — deactivate a connectionnmcli connection modify CONNECTION_NAME ipv4.addresses 192.168.1.50/24 — set static IPnmcli connection modify CONNECTION_NAME ipv4.gateway 192.168.1.1 — set gatewaynmcli connection modify CONNECTION_NAME ipv4.dns "8.8.8.8 8.8.4.4" — set DNS serversnmcli connection modify CONNECTION_NAME ipv4.method manual — switch from DHCP to staticnmcli device wifi list — list available Wi-Fi networksnmtui — text-based interactive UI for NetworkManager; useful when no GUI is available/etc/NetworkManager/system-connections/ (keyfile format in RHEL 8+)nmcli connection reload then nmcli connection up CONNECTION/etc/hosts — static hostname-to-IP mappings; checked before DNS by default/etc/resolv.conf — specifies DNS servers (nameserver 8.8.8.8) and search domains (search example.com)/etc/nsswitch.conf — controls lookup order; the hosts: line (typically files dns) determines whether /etc/hosts is checked before DNSdig DOMAIN — detailed DNS query; dig @8.8.8.8 DOMAIN — query specific server; dig -x IP — reverse lookupnslookup DOMAIN — simple DNS query (older tool); interactive mode: nslookup then server 8.8.8.8host DOMAIN — quick DNS lookup; host IP — reverse DNSsystemd-resolve --status — show DNS configuration used by systemd-resolved/etc/nsswitch.conf, not /etc/resolv.conf. If the exam asks how to make /etc/hosts take precedence over DNS, the answer is to check the hosts: line in nsswitch.conf — it must list files before dns.iptables -L -n -v --line-numbers — list all rules with line numbers and packet countsiptables -A INPUT -p tcp --dport 22 -j ACCEPT — append rule to allow SSHiptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT — insert rule at position 1iptables -D INPUT 3 — delete rule by line numberiptables -A INPUT -s 10.0.0.5 -j DROP — drop all traffic from a source IPiptables -P INPUT DROP — set default policy to DROP (deny-all baseline)iptables-save > /etc/iptables/rules.v4; restore: iptables-restore < /etc/iptables/rules.v4ufw enable — enable the UFW firewall (Ubuntu/Debian); ufw allow 22/tcp — allow SSH; ufw deny 23 — block telnetfirewalld — zone-based firewall on RHEL/Fedora; firewall-cmd --list-all — show active zone configfirewall-cmd --permanent --add-service=http — allow HTTP; --reload applies permanent changes--line-numbers and -I (insert) for targeted rule placement.ssh-keygen -t ed25519 -C "comment" — generate an Ed25519 key pair (recommended over RSA for new keys)ssh-keygen -t rsa -b 4096 — generate 4096-bit RSA key pair~/.ssh/id_ed25519 (protect with chmod 600); Public key: ~/.ssh/id_ed25519.pubssh-copy-id user@host — copy public key to remote host's ~/.ssh/authorized_keys~/.ssh/authorized_keys on the server: must be chmod 600 and owned by the user~/.ssh/ directory: must be chmod 700 and owned by the userPasswordAuthentication no — disable password auth (force key-based only)PermitRootLogin no — prevent direct root login via SSHAllowUsers alice bob — whitelist specific users; all others deniedPort 2222 — change SSH port (security through obscurity; adjust firewall accordingly)ClientAliveInterval 300 / ClientAliveCountMax 2 — disconnect idle sessions after 10 minutes/etc/ssh/sshd_config: systemctl restart sshdping -c 4 HOST — test basic connectivity; ping -I eth0 HOST — send from specific interfacetraceroute HOST — show path packets take (hop-by-hop); tracepath HOST — similar but no root requiredss -tulnp — list listening TCP (t) and UDP (u) sockets with process names; replaces netstat -tulnptcpdump -i eth0 port 80 — capture HTTP traffic; tcpdump -i eth0 -w capture.pcap — write to filetcpdump -i eth0 host 10.0.0.5 and tcp — filter by host and protocolcurl -I https://example.com — fetch HTTP headers only; curl -v URL — verbose output showing TLS handshakewget -O /dev/null URL — test download speed; wget --spider URL — check URL without downloadingnc -zv HOST PORT — test if a TCP port is open (netcat); nc -l 8080 — listen on port 8080ss -tulnp is the modern replacement for netstat -tulnp. The flags: -t TCP, -u UDP, -l listening only, -n show numbers not names, -p show process info. The Linux+ exam may test either command.getenforce — display current mode (Enforcing/Permissive/Disabled)setenforce 0 — switch to Permissive (temporary, survives only until reboot)setenforce 1 — switch to Enforcing (temporary)/etc/selinux/config → set SELINUX=enforcing / permissive / disabledls -Z /var/www/html/ — show SELinux file context labelsrestorecon -Rv /var/www/html/ — restore default SELinux contexts recursively (fixes "wrong context" denials)chcon -t httpd_sys_content_t /new/file — change file context temporarily (overridden by restorecon)semanage fcontext -a -t httpd_sys_content_t "/newpath(/.*)?" — add a persistent context rulerestorecon -Rv /newpath — apply the newly added context rulegetsebool -a | grep httpd — list all SELinux booleans related to httpdsetsebool -P httpd_can_network_connect on — enable a boolean persistently (-P)audit2why < /var/log/audit/audit.log — explain why actions were deniedaudit2allow -M mypolicy < /var/log/audit/audit.log — generate a custom allow policy module from denialssemodule -i mypolicy.pp — install a custom SELinux policy modulechcon to change a file context, the change is temporary. A subsequent restorecon will reset it back to the default policy label. The correct permanent approach is semanage fcontext followed by restorecon. The exam tests this two-step workflow.aa-status — show AppArmor status: profiles loaded, enforcement mode per profileaa-enforce /etc/apparmor.d/usr.sbin.nginx — put a profile into enforce modeaa-complain /etc/apparmor.d/usr.sbin.nginx — put into complain (logging) mode/etc/apparmor.d/apparmor_parser -r /etc/apparmor.d/PROFILE — reload a profile after editingaa-genprof /path/to/binary — generate a new profile interactively by watching program behaviorgpg --gen-key — generate a new GPG key pair interactivelygpg --list-keys — list all keys in the public keyringgpg --export -a "User Name" > public.key — export public key to ASCII-armored filegpg --import public.key — import a public key from a filegpg --keyserver keyserver.ubuntu.com --recv-keys KEY_ID — download a key from a keyservergpg --encrypt -r "Recipient" file — encrypt file for recipient (produces file.gpg)gpg --decrypt file.gpg > file — decrypt a filegpg --sign file — create a signed version of a file (embedded signature)gpg --detach-sign file — create a separate file.sig signature filegpg --verify file.sig file — verify a detached signaturerpm -K package.rpm verifies the package signature/etc/pam.d/ — service-specific PAM configuration; system-auth and password-auth are key files on RHELpam_pwquality.so — enforces password complexity rules configured in /etc/security/pwquality.conffaillock — PAM module that locks accounts after N failed login attempts; check with faillock --user USERNAME; reset with faillock --user USERNAME --reset/etc/security/limits.conf — set per-user/group resource limits: nofile (open files), nproc (processes), memlock (locked memory)ulimit -n — show current shell's open file descriptor limit; ulimit -n 65536 — set for current sessionvisudo — validates syntax before saving, preventing lockoutsUSER HOST=(RUNAS) COMMANDS — e.g., alice ALL=(ALL) ALL%admins ALL=(ALL) ALLbob ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginxcarol ALL=(root) /usr/bin/dnf install, /usr/bin/dnf remove/etc/sudoers.d/ — add separate files here rather than editing /etc/sudoers directly/var/log/auth.log (Debian) or /var/log/secure (RHEL) — authentication events: logins, sudo usage, SSH attempts/var/log/messages (RHEL) or /var/log/syslog (Debian) — general system messagesjournalctl -u sshd --since "1 hour ago" — filter systemd journal by unit and timejournalctl _COMM=sshd — all journal entries from the sshd processjournalctl -p err — show only error-level messageslastb — list bad (failed) login attempts from /var/log/btmplast — list successful logins from /var/log/wtmpwho / w — currently logged-in usersauditd — the Linux audit daemon; writes security events to /var/log/audit/audit.logauditctl -w /etc/passwd -p wa -k passwd_changes — watch /etc/passwd for write and attribute changesausearch -k passwd_changes — search audit log by keyausearch -ua USERNAME — search audit events by useraureport --summary — summary of audit events by category/etc/audit/rules.d/audit.rulesaudit2allow generates allow rules from denial messages but always review the output — it may create overly permissive rules. Use the minimum necessary permissions and apply the principle of least privilege. The exam may test whether you know audit2why (explains denials) vs audit2allow (generates allow policy).#!/bin/bash (or #!/usr/bin/env bash for portability)chmod +x script.sh; run with ./script.sh or bash script.shNAME="Alice" (no spaces around =); reference with $NAME or ${NAME}DATE=$(date +%Y-%m-%d) — stores command output in variable$? (exit code of last command), $# (number of arguments), $@ (all arguments as separate strings), $0 (script name), $1-$9 (positional arguments)if [ "$VAR" = "value" ]; then ... elif [ condition ]; then ... else ... fifor FILE in /etc/*.conf; do echo "$FILE"; donewhile [ $COUNT -lt 10 ]; do ((COUNT++)); doneuntil ping -c1 HOST >/dev/null 2>&1; do sleep 5; donefunction check_service() { systemctl is-active "$1" || return 1; }-f (regular file), -d (directory), -e (exists), -r (readable), -w (writable), -x (executable), -s (non-empty)-z (zero length / empty), -n (non-zero length / not empty), = (equal), != (not equal)-eq, -ne, -lt, -le, -gt, -ge$? must be checked immediately after the command it refers to — the very next command overwrites it. A common pattern: command; RC=$?; if [ $RC -ne 0 ]; then .... Also: set -e at the top of a script causes it to exit immediately on any non-zero return code.grep -E "pattern" file — extended regex search; -i case-insensitive; -r recursive; -v invert match; -l filenames only; -c count matchesgrep -P "\d{3}-\d{4}" file — Perl-compatible regex for complex patternssed 's/old/new/g' file — substitute all occurrences; -i flag edits file in-place; sed -n '5,10p' file — print lines 5–10awk '{print $1, $3}' file — print fields 1 and 3; awk -F: '{print $1}' /etc/passwd — use colon as delimiterawk '$3 > 1000 {print $1}' /etc/passwd — conditional: print username if UID > 1000cut -d: -f1,3 /etc/passwd — cut fields 1 and 3 from colon-delimited filesort -k3 -n file — sort numerically by field 3; sort -r reverse order; sort -u unique linesuniq -c — count duplicate consecutive lines; always pipe through sort firsttr 'a-z' 'A-Z' — translate lowercase to uppercase; tr -d '\r' — remove carriage returnswc -l file — count lines; wc -w words; wc -c byteshead -n 20 file — first 20 lines; tail -n 20 file — last 20 lines; tail -f /var/log/syslog — follow a file livecat /etc/passwd | awk -F: '$3 >= 1000 {print $1}' | sort — list all regular users sorted alphabetically. Know how to chain grep | awk | sort | uniq pipelines.docker run -d -p 8080:80 --name webserver nginx — run nginx in background, map port 8080→80docker ps — list running containers; docker ps -a — all containers including stoppeddocker images — list local imagesdocker pull IMAGE:TAG — pull an image from registrydocker exec -it CONTAINER bash — interactive shell in a running containerdocker logs CONTAINER — view container logs; docker logs -f CONTAINER — followdocker stop CONTAINER — gracefully stop; docker rm CONTAINER — remove stopped containerdocker rmi IMAGE — remove an imagedocker run -v /host/path:/container/path IMAGE — bind mount a host directory into a containerpodman — drop-in Docker replacement; rootless and daemonless by design; commands are identical to Docker in most casesFROM ubuntu:22.04 — base imageRUN apt-get update && apt-get install -y nginx — execute commands during image buildCOPY ./app /var/www/html/ — copy files from build context into imageENV APP_ENV=production — set environment variableEXPOSE 80 — document which port the container listens on (does not publish)CMD ["nginx", "-g", "daemon off;"] — default command to run (can be overridden)ENTRYPOINT ["/entrypoint.sh"] — executable that always runs (CMD becomes its arguments)docker build -t myapp:1.0 . — build image from Dockerfile in current directorysudo). Docker requires the docker daemon running as root. The Linux+ exam specifically tests this architectural difference./etc/ansible/hosts or custom file with -i): groups of hosts in INI or YAML formatansible all -m ping — test connectivity to all hosts in inventoryansible webservers -m shell -a "df -h" — run shell command on webservers groupansible all -m copy -a "src=/etc/hosts dest=/tmp/hosts" — copy file to all hostsansible all -m service -a "name=nginx state=started" — ensure nginx is runningansible all -b -m dnf -a "name=httpd state=present" — install httpd (become=sudo)apt/dnf (package management), copy (copy files), template (Jinja2 templates), service (manage services), user (manage users), file (manage file permissions/ownership)ansible-playbook site.yml — run a playbookansible-playbook site.yml --check — dry run (shows what would change without changing it)ansible-playbook site.yml -v / -vvv — verbose output for debuggingansible-playbook site.yml --limit webservers — run only against a specific groupsystemctl status servicename — shows active/failed state, last 10 log lines, and exit codejournalctl -xe -u servicename — full journal with explanations; journalctl --boot -1 — previous boot logsdmesg | tail -50 — recent kernel messages; dmesg | grep -i errordf -h, du -sh /*), memory (free -h), CPU (top, vmstat 1 5), I/O (iostat -x 1 5)dmesg | grep -i "out of memory" or grep -i oom /var/log/kern.log — identifies memory-killed processessystemctl status and journalctl -xe for the exact error; often a config file syntax error or missing dependencydf -h to identify full filesystem; du -sh /var/log/* to find large log files; journalctl --vacuum-size=500M to trim journaltop sorted by CPU (P key); ps aux --sort=-%cpu | headfree -h; vmstat 1 to watch memory pressure; consider increasing swap or identifying memory leaks with ps aux --sort=-%memiptables -L or firewall-cmd --list-all), sshd status, SELinux (getenforce), ss -tlnp | grep 22dmesg or /var/log/kern.log, not just /var/log/messages.Challenge yourself with 60 CompTIA Linux+ practice questions — scenario-based, exam-realistic, and free.