Back to exam

XK0-006 Cheatsheet

CompTIA Linux+

Download free PDF

System Management (23%)

Boot and filesystem hierarchy

  • **Boot sequence:** firmware starts the bootloader, which loads the kernel and initial RAM filesystem. **initrd/initramfs** supplies early drivers and tools needed to reach the real root filesystem; systemd then starts userspace services.
  • **/boot** holds boot files; **/etc** holds host configuration; **/dev** exposes devices. **/proc** presents live process and kernel information, while **/sys** exposes kernel device information. These virtual filesystems are not ordinary persistent data stores.
  • **/bin** contains essential commands and may link into /usr/bin on merged systems. **/usr/share** holds architecture-independent resources, including documentation; **/var** holds changing data such as logs; **/home** holds user data.

Hardware and kernel modules

  • **lscpu** describes CPUs; **lsblk** lists block devices; **lspci** and **lsusb** identify buses and devices. **lshw** provides broad hardware inventory; **dmidecode** reads firmware-provided SMBIOS data, which may be incomplete.
  • **lsmod** lists loaded modules; **modinfo module** shows metadata such as version when supplied. **modprobe** loads modules with dependencies; **depmod** rebuilds dependency metadata.
  • **dmesg** displays the kernel ring buffer, including device discovery and hardware errors. **sensors** from lm-sensors reports supported thermal sensors; **ipmitool sensor** can query a supported management controller.

Disks, filesystems and mounts

  • **Partitioning** defines disk regions; formatting creates a filesystem. Inspect with **lsblk -f**, **blkid** and a partition-table tool before selecting a device. **mkfs.ext4 /dev/sdX1** creates ext4 and destroys existing filesystem contents on that target.
  • **Disk labels** such as GPT describe partition-table formats; **filesystem labels** name filesystems. **mkfs.ext4 -L data /dev/sdX1** sets a filesystem label; mount persistently through **/etc/fstab**, preferably using a stable UUID.
  • **mount** attaches a filesystem to a directory; **findmnt** shows mounted sources and options. **noexec** blocks direct executable launches from that mount; **nosuid** suppresses set-ID effects; **nodev** prevents device-file interpretation.
  • **LVM** layers physical volumes, volume groups and logical volumes. Use **pvs**, **vgs** and **lvs** to inspect them. Metadata backups in /etc/lvm/backup and /etc/lvm/archive support recovery; **vgcfgrestore** restores metadata, not overwritten user data.

Files, links and text tools

  • **Symbolic links** store a target path and can cross filesystems or reference directories: **ln -s /usr/local/myfile /var/tmp/myfile**. Hard links share an inode, normally cannot target directories, and cannot cross filesystems.
  • **rm -r directory** removes a directory tree; **rmdir** removes empty directories. **find ~ -type d -exec chmod 700 {} \;** restricts directories to their owner; distinguish directories from files before applying recursive modes.
  • **grep** selects matching lines; **cut** extracts delimited fields; **awk** processes fields and records. **sed -i 's/old/new/g' file** edits all matches per line in place; **diff** shows line differences and **file** identifies content format.

Archives, copies and recovery

  • **tar -cf backup.tar -C /home ann** creates an uncompressed archive; **tar -xf backup.tar -C /restore** extracts it. **-z** uses gzip, **-j** bzip2 and **-J** xz; inspect with **tar -tf** before restoring and verify ownership afterward.
  • **cpio** consumes file lists when archiving and reads archives on standard input when extracting. **unzip** handles ZIP; **7z x archive** preserves archived paths, while **7z e archive** extracts into one directory. Choose tools by format, not filename suffix.
  • **dd if=/dev/sdX of=disk.img bs=4M status=progress** copies raw blocks, including filesystem metadata and partition tables when the whole disk is selected. Reversing input and output can overwrite the original; keep the source unchanged and verify copy hashes.
  • **sfdisk --dump /dev/sdX** exports a partition layout; **sgdisk --backup=table.bin /dev/sdX** backs up GPT structures. A partition-table backup, LVM metadata backup and file backup protect different layers; test restoration of the required data.

Network configuration and resolution

  • **ip link**, **ip address** and **ip route** inspect interface state, addresses and routes. A local subnet needs a correct prefix; off-subnet traffic normally needs a usable route through a reachable gateway. DHCP failures may leave an interface without its expected address.
  • **/etc/resolv.conf** describes resolver nameservers and search domains, but NetworkManager or systemd-resolved may generate it. Change the owning network configuration for persistence; **/etc/nsswitch.conf** controls lookup-source order and **/etc/hosts** supplies local mappings.
  • **Search domains** let short names expand into FQDNs. **dig host.example.org** queries DNS; **dig MX example.org** checks mail routing. NXDOMAIN means the queried name does not exist; a timeout indicates no timely response.
  • **netplan try** applies a candidate configuration with a confirmation timeout and rollback behavior; **netplan apply** applies it directly. **sysctl net.ipv4.ip_forward=1** enables IPv4 forwarding at runtime; use a sysctl configuration file for persistence.

Services and User Management (20%)

Service lifecycle and startup

  • **systemctl start/stop** changes current service state; **enable/disable** changes boot activation. Disabling does not stop a running service or prevent manual starts. **mask** blocks activation; **unmask** removes that block.
  • **systemctl status app.service** summarizes state and recent messages. **systemctl list-units --type=service --all** lists loaded service units; **list-unit-files --type=service** lists installed unit files and enablement states.
  • After editing **unit files**, run **systemctl daemon-reload**, then restart the affected service when needed. Editing an application configuration usually requires that application's supported reload or restart; daemon-reload alone does not reload application settings.
  • **systemd-analyze blame** lists measured unit activation durations; **critical-chain** shows timing along dependencies. Long activation time and a boot-blocking dependency are different findings.

Accounts, groups and sessions

  • **getent passwd accounting** returns the account record through configured identity sources: name, UID, primary GID, home and shell. **id accounting** shows identity and groups; **/etc/shadow** stores local password hashes and aging fields.
  • **useradd -m alice** creates an account with a home directory. **usermod -aG project alice** appends a supplementary group; **-g** changes the primary group and **-G** without -a replaces supplementary membership.
  • **id user** checks directory membership; existing sessions can retain old group credentials until a new login. **w -i** shows logged-in sessions with numeric remote addresses when available; commands run through sudo may otherwise describe root's context.

Processes, scheduling and job control

  • **ps** and **top** inspect processes; **jobs** lists jobs in the current shell. **command &** launches a background job; **fg %1** foregrounds it and **bg %1** resumes a stopped job in the background.
  • **nohup command &** makes a command ignore hangup and redirects terminal output as needed. It does not create a persistent terminal session; **fg** works only while the launching shell still tracks the job.
  • **nice** sets initial niceness; **renice** changes an existing process. A higher nice value means lower CPU scheduling priority for ordinary tasks. Niceness redistributes CPU contention; it does not add CPU capacity.
  • **SIGTERM** requests orderly shutdown; **SIGKILL** forces termination. **pkill -u testuser** targets processes by effective user. **Z** is a zombie awaiting its parent's wait call; **D** is uninterruptible sleep, often I/O; **S** sleeps and **T** is stopped.

Packages and repositories

  • **APT/dpkg** manage Debian-family packages; **DNF/RPM** serve RPM-based systems. Repositories supply package metadata and signed packages. Review repository configuration, connectivity, signatures and trust errors before changing package sources.
  • **dnf repolist --all** lists configured repositories, including disabled ones; **dnf history** shows transactions. **dnf update package** upgrades an installed package; **dnf check-update** checks availability without installing updates. yum commands may map to DNF on newer systems.
  • **apt-mark hold python3-openssl** holds a package; **apt-mark unhold** releases it and **showhold** lists holds. A hold can preserve compatibility while delaying security fixes; track the dependency and plan a supported upgrade.
  • **Vendor advisories** identify fixed packages and applicable releases; distributions may backport fixes without adopting the newest upstream version. Repair CA trust or repository configuration when broken rather than disabling verification.

Containers and virtual machines

  • **docker pull debian** downloads an image; **docker run -it ubuntu /bin/bash** creates and starts an interactive container. **start** reuses a stopped container; **exec -it container /bin/sh** launches a command inside a running one.
  • **docker ps** shows running containers; **docker ps -a** includes stopped ones; **docker images** lists images. **docker logs** and **docker inspect** help examine startup failures, ports and mounts. Container execution alone does not publish an application port.
  • **Dockerfile FROM** selects a base image; **ENTRYPOINT** specifies the executable and **CMD** supplies a default command or arguments. **EXPOSE** documents a port; **-p host:container** publishes it. Podman offers similar image and container workflows.
  • **Bridged networking** gives a VM connectivity on the physical network through a bridge; **NAT** translates through a host-side network and **host-only** limits connectivity. Live migration needs compatible CPU features, adequate resources, connectivity and accessible storage; identical storage paths alone are insufficient.
  • **qemu-img info** inspects virtual disk metadata; **qemu-img convert -O qcow2 input.raw output.qcow2** converts a disk image. Use an offline or properly coordinated image source to preserve consistency.

Security (18%)

Permissions and shared directories

  • **r/w/x** mean read, write and execute on files; on directories they mean list entries, modify entries and traverse. Parent-directory traversal matters. **chmod**, **chown** and **chgrp** change modes, owner and group.
  • **chmod 2770 /shared** sets group inheritance with setgid and grants owner/group access. New files inherit the directory group, but **umask** or default ACLs must also allow group writing. Setgid alone does not make every new file writable.
  • **getfacl** inspects ACLs; **setfacl** adds named-user/group permissions and default directory ACLs. The **ACL mask** limits effective permissions for named users and the group class; inspect it when mode bits appear to allow access.
  • **Sticky bit** on a shared directory restricts deletion or renaming to the file owner, directory owner or privileged users. **Setuid** on an executable changes its effective user ID; it is not a general shared-directory collaboration control.
  • **lsattr** displays supported file attributes. **chattr +i file** makes a file immutable; **chattr +a file** permits append-only writes. An authorized administrator can clear them with -i or -a; ordinary chmod changes do not remove these attributes.

Account policy and delegated access

  • **passwd -l user** locks password authentication; existing sessions, keys and other authentication paths require separate handling. A shell such as **/sbin/nologin** prevents ordinary interactive shell login and suits service accounts.
  • **chage -M 90 user** sets maximum password age; **chage -m** sets minimum age and **chage -l user** reports policy. Minimum age can discourage cycling through history; expiry does not itself enforce complexity or prevent reuse.
  • **PAM** composes authentication, account, password and session checks. **pam_faillock** can enforce failed-login lockouts; older systems may use pam_tally2. **pam_limits** sets resource limits rather than password attack detection.
  • **sudoers** grants selected commands to users or groups. Edit with **visudo** or **visudo -f /etc/sudoers.d/team** for syntax checking; grant only required commands. sudo or wheel group authority depends on distribution policy.
  • **Strong passwords** emphasize length, uniqueness and resistance to guessing. Combine appropriate password policy with MFA and compromised-credential response; visual complexity alone does not establish strength.

SSH and directory authentication

  • **ssh-keygen** creates a key pair; **ssh-copy-id user@server** installs the public key for the remote account. Protect the private key with a passphrase; **ssh-agent** and **ssh-add** manage unlocked keys for client use.
  • **~/.ssh/authorized_keys** holds accepted public keys. Common safe modes are 700 for .ssh and 600 for authorized_keys with correct ownership. Check sshd policy, home permissions and SELinux labels when key authentication falls back to a password.
  • **LDAP** queries hierarchical directory information; **Kerberos** uses tickets for authentication. **SSSD**, configured in /etc/sssd/sssd.conf, integrates supported domain identity/authentication services; **Samba** supplies SMB services and related Windows integration.

SELinux and service confinement

  • **getenforce** reports Enforcing, Permissive or Disabled; **sestatus** gives more detail. SELinux mandatory access control applies in addition to normal permissions. **ls -Z** shows labels; inspect denial records before modifying policy.
  • **restorecon** restores labels from policy mappings. **semanage fcontext** defines persistent path-label mappings; **chcon** changes a current label and may be undone by relabeling. Repair the expected SSH or service context rather than disabling enforcement.
  • **semanage port -a -t http_port_t -p tcp 1234** labels a previously unassigned port for an eligible web service; modify an existing assignment with -m when appropriate. **setsebool -P** persists supported boolean changes; it does not assign port types.

Firewall direction and persistence

  • **INPUT** filters traffic destined for the host; **OUTPUT** filters locally generated traffic and **FORWARD** filters routed traffic. Match protocol, source network and destination port; rule order, zone and default policy determine the final result.
  • **ufw allow from 10.0.0.0/24 to any port 53 proto tcp** permits scoped inbound DNS TCP. DNS also commonly uses UDP 53. SSH uses TCP 22, HTTPS TCP 443, and IPP/CUPS commonly TCP 631; permit only needed sources and services.
  • **firewall-cmd --permanent --add-service=http** updates persistent configuration in the selected zone; **firewall-cmd --reload** loads it into runtime. A runtime-only rule normally disappears after a reload or reboot; inspect both views and the interface's zone.
  • **iptables -A INPUT -s 192.168.100.0/24 -p tcp --dport 631 -j ACCEPT** permits matching inbound printing traffic if reached. Other traffic needs an appropriate deny policy or rule; saving rules for reboot depends on the distribution's firewall manager.

Encryption, hardening and audit

  • **LUKS/dm-crypt** protects block storage at rest; unlocked volumes remain accessible to authorized running processes. **GPG** protects files and messages, while TLS protects network sessions through certificate-based trust.
  • **TLS validation** checks hostname, validity period, chain and trust anchors. Protect private keys with minimal service-readable access. Fix expired certificates, missing intermediates or an approved CA trust chain; disabling verification conceals trust failures.
  • **CIS Benchmarks** provide configuration guidance; **OpenSCAP** evaluates supported compliance and vulnerability content. **AIDE** detects file changes against a trusted baseline; **auditd** records configured security-relevant activity. A CVE identifies a vulnerability, not a hardening standard.
  • **Nmap** discovers exposed services; remove unused daemons such as Telnet and prefer SSH for remote administration. Firewall restrictions supplement service hardening. Keep packages patched and verify the installed vendor fix.
  • **Deletion** normally removes references, not all recoverable data. **shred** overwrites supported files or devices but cannot guarantee sanitization on SSDs, snapshots, copy-on-write storage or backups; use media-appropriate secure erase or cryptographic erasure.

Automation, Orchestration, and Scripting (17%)

Shell expansion and command lookup

  • **name=value** assigns a shell variable; **export ENABLE_AUTH=1** makes it available to child processes. Children do not change the parent's environment. Double quotes allow expansion; single quotes keep text literal; **${name}** clearly delimits a variable name.
  • **$(command)** substitutes command output; it is different from variable expansion. Quote expansions such as **"$file"** to prevent unintended word splitting and globbing when passing one value.
  • **export PATH="$PATH:$HOME/.local/bin"** adds a command-search directory for the current shell. Bash interactive settings commonly belong in **~/.bashrc**; login shells use profile files. Select the startup file actually read by the target session.
  • **>** replaces a file, **>>** appends, and **|** connects stdout to the next command. **tail -f log | tee copy.log** displays and copies a growing log; **tee -a** appends. Use **2>** for stderr or **2>&1** to combine streams.

Bash tests and control flow

  • **Exit status 0** means success; **$?** is the preceding command's status. **command1 && command2** runs the second only after success; **||** runs it after failure. Check errors before reporting completion.
  • **[ -f "$file" ]** tests for a regular file; **-e** tests existence. **if ...; then ...; else ...; fi** branches; **for ...; do ...; done** iterates and **while** repeats while a condition succeeds.
  • **-eq, -ne, -gt, -lt** compare integers in test expressions. **grep -c FAIL log** counts matching lines, not occurrences; **grep -o FAIL log | wc -l** counts separate matching occurrences. Decide which measure the task requires.
  • **for username in alice bob charles; do useradd -m "$username"; done** iterates fixed simple names. For records from a file, **while IFS= read -r username** preserves each line; validate names before using them in privileged operations.

Cron and systemd timers

  • **User crontab** fields are minute, hour, day-of-month, month and day-of-week, followed by the command. **0 15 * * 0 /path/testBack.sh** runs at 15:00 each Sunday; ***/15** in the minute field runs every fifteen minutes.
  • **System crontabs** also include a user field. Cron has a limited environment: use absolute paths, provide required variables and capture output. Check local time settings and permissions when a schedule appears correct but execution fails.
  • **systemd timers** trigger associated services using calendar or elapsed-time conditions. After editing a timer unit, use **systemctl daemon-reload** and restart that timer; **systemctl list-timers --all** shows upcoming activations.

Python and configuration automation

  • **Python 3** is extensible through modules loaded with **import**. **PEP 8** describes Python style conventions. Match interpreter and dependency versions; Python 3 does not promise complete compatibility with Python 2 code.
  • **python3 -m venv .venv** creates an isolated package environment; **source .venv/bin/activate** adjusts the shell. **python -m pip install -r requirements.txt** installs listed dependencies into the selected interpreter's environment.
  • **Ansible inventory** defines hosts, groups and associated variables. A **YAML playbook** maps ordered plays and tasks to hosts; modules perform actions, facts describe discovered host state, and handlers run when notified by changes.
  • **Configuration management** aims for repeatable desired state; prefer idempotent modules over arbitrary shell commands. Validate YAML, review inventory scope and test changes on limited hosts before broad deployment.
  • **Webhooks** are event-driven HTTP callbacks; authenticate senders and validate payloads. **SNMP** exposes network management data; threshold alerts and service health checks provide different monitoring signals.

Git recovery and responsible AI

  • **git init** creates a local repository; **clone** copies an existing one. **status** and **diff** inspect changes; **add** stages them, **commit** records local history and **push** sends commits to a remote branch.
  • **fetch** downloads remote history; **pull** also integrates it. **stash** temporarily saves eligible local changes; **stash -u** includes untracked files. Review differences and choose merge or rebase deliberately when integrating work.
  • **restore** can discard selected working-tree changes. **reset** moves a branch and/or updates staging and working state depending on its mode; **reset --hard** discards tracked changes. **revert** creates a new inverse commit and is useful for shared history.
  • **Responsible AI use** starts with organizational policy and approved tools. Sanitize sensitive data, protect proprietary code and credentials, and use anonymized examples when appropriate. Review, lint and test generated scripts or infrastructure code before execution.

Troubleshooting (22%)

Logs, startup and observability

  • **systemd-journald** collects system and service messages; it is separate from filesystem journaling. **journalctl -u app.service** filters by unit, **-b** selects the current boot, **-k** shows kernel messages and **-f** follows new entries.
  • **Log aggregation** centralizes records across hosts and applications; secure transport, access and retention. **Log rotation** bounds local file growth. **Auditing** records selected security-relevant operations rather than merely summarizing service health.
  • **Thresholds** trigger alerts when metrics cross defined limits; they do not inherently restart services. Correlate metrics and logs with timestamps and a baseline. A successful process check alone does not prove the application serves requests.

CPU, memory and storage pressure

  • **uptime/top** show load averages; compare them with CPU count. Load includes runnable tasks and uninterruptible sleepers, so high load does not prove CPU saturation. **pidstat** helps attribute CPU, memory and I/O activity to processes.
  • **free -h** distinguishes available memory from free memory; filesystem cache is often reclaimable. **vmstat** shows paging and run queues; **iostat -xz** helps assess device latency, queues and utilization. Interpret CPU I/O wait alongside storage evidence.
  • **OOM** messages in kernel logs identify memory pressure and killed processes. Sustained growth in a process's resident memory can indicate a leak; inspect trends and workload limits. Extra RAM or swap may postpone symptoms without fixing the leak.
  • **df -h** checks filesystem capacity; **df -i** checks inodes; **du** finds directory usage. Quotas, inode exhaustion and open deleted files can block writes even when a superficial capacity check looks acceptable.

Busy filesystems and execution failures

  • **lsof +f -- /data** or **fuser -vm /data** identifies users of a mounted filesystem. Open files, working directories and nested mounts can keep it busy. Stop dependent workloads and leave the mount before unmounting.
  • **fuser -km /data** can kill processes using that filesystem and disrupt unrelated work; inspect first. Forced or lazy unmounts do not substitute for safely quiescing application writes.
  • **Permission denied** when executing a script may involve mode bits, parent-directory traversal, ACLs, SELinux or a **noexec** mount. Check **ls -l**, **namei -l**, **getfacl**, **findmnt** and denial logs before changing access.
  • **Command not found** points toward PATH, filename or interpreter problems. Use an absolute path to distinguish lookup from execution failures; verify the shebang, interpreter availability and executable permission for direct script launches.

Network and application fault isolation

  • **Troubleshoot in layers:** link and address, local subnet, route, DNS, remote port, then application protocol. A missing gateway differs from a down NIC; an FQDN working while a short name fails suggests search-domain configuration.
  • **ss -lntp** shows local listening TCP sockets and associated processes when permitted. **nc -vz db.example.org 3306** tests a remote TCP connection; it does not prove database authentication or a successful query. A local listener check cannot establish remote reachability.
  • **ping** tests ICMP reachability; blocked ICMP does not prove TCP is unavailable. **tracepath/traceroute** help inspect paths and **tcpdump** captures packets. Distinguish a timeout from a connection refusal and inspect firewall policy at each relevant hop.
  • **ethtool interface** checks negotiated speed, duplex and driver/link details; **ip -s link** shows errors and drops. 100 Mb/s is roughly 12.5 MB/s before overhead. MTU mismatches can break larger transfers even when small packets succeed.
  • **Service connection failures** may involve a wrong bind address, unpublished container port, firewall zone, DNS record or TLS trust. Validate configuration and logs, apply the narrow fix, then retest through the client's actual path.