Courseiva

CompTIA Linux+ (XK0-006) (XK0-006) — Questions 76–150

781 questions total · 11 pages · All types, answers revealed

Page 1

Page 2 of 11

Page 3
76
MCQmedium

A service called 'myapp' fails to start automatically after a system reboot. The administrator wants to ensure the service starts at boot. Which systemctl command should be used?

A.systemctl daemon-reload
B.systemctl start myapp
C.systemctl enable myapp
D.systemctl reenable myapp
AnswerC

`systemctl enable myapp` creates the symlinks that pull the unit into the boot target's dependency tree, so systemd starts it automatically at each reboot. This directly satisfies the requirement that the service start at boot, unlike `start`, which only launches it for the current session.

Why this answer

The `systemctl enable myapp` command creates the necessary symlinks in the systemd unit configuration directories (typically `/etc/systemd/system/multi-user.target.wants/`) so that the `myapp` service is automatically started at boot. This is the correct approach because the question specifically asks to ensure the service starts after a reboot, not to start it immediately.

Exam trap

The trap here is that candidates often confuse `systemctl start` (immediate start) with `systemctl enable` (boot-time start), or they mistakenly think `systemctl reenable` is a valid command for re-enabling a service.

How to eliminate wrong answers

Option A is wrong because `systemctl daemon-reload` reloads the systemd manager configuration and unit files, but it does not enable a service to start at boot. Option B is wrong because `systemctl start myapp` starts the service immediately in the current session but does not configure it to start automatically after a reboot. Option D is wrong because `systemctl reenable myapp` is not a valid systemctl command; the correct command to re-enable a service is `systemctl enable myapp` (which can be run again to recreate symlinks), and `reenable` is a common misconception or typo.

77
MCQmedium

A company runs a critical web application on a single server using Docker containers. The application consists of a web frontend container and a backend API container. Recently, the server ran out of disk space due to Docker logs and temporary images. The sysadmin is tasked with automating cleanup to prevent recurrence. The solution must not disrupt running containers. Which approach should be taken?

A.Increase disk space by adding a new volume.
B.Create a script that stops all containers, removes unused images, and restarts containers.
C.Schedule a cron job to run `docker system prune -a -f` daily.
D.Configure log rotation for containers using `--log-opt max-size=10m` and `--log-opt max-file=3` in the Docker run command, and schedule `docker image prune -f` weekly.
AnswerD

Log rotation keeps log files small, and pruning unused images safely removes them without affecting running containers.

Why this answer

It addresses both root causes: log growth and dangling images. Configuring `--log-opt max-size=10m` and `--log-opt max-file=3` limits container log file size and count without stopping containers, while `docker image prune -f` removes unused images safely. This combination prevents disk exhaustion without disrupting running containers, meeting all requirements.

Exam trap

The trap here is that candidates may choose Option C because `docker system prune -a -f` seems like a comprehensive cleanup, but they overlook that it can remove images needed by running containers (if they use intermediate layers) and does not address log growth, which is the primary cause of disk space exhaustion in this scenario.

How to eliminate wrong answers

Option A is wrong because adding a new volume only postpones the problem by increasing capacity, but does not automate cleanup of logs or unused images, so disk space will eventually run out again. Option B is wrong because stopping all containers disrupts the critical web application, violating the requirement to not disrupt running containers. Option C is wrong because `docker system prune -a -f` removes all unused images, containers, networks, and volumes, including those that might be needed for running containers (e.g., intermediate layers), and it does not address log rotation, so logs will continue to grow unchecked.

78
Multi-Selecthard

A system fails to boot with a kernel panic. The administrator wants to recover by accessing a root shell. Which THREE methods can be used to achieve this?

Select 3 answers
A.Run 'fsck /dev/sda1' from the GRUB command line
B.Append 'single' to the kernel command line in GRUB
C.Press 'e' in GRUB and remove 'quiet'
D.Append 'rd.break' to the kernel command line in GRUB
E.Boot from a live CD and chroot into the installed system
AnswersB, D, E

Appending 'single' boots the kernel into single-user mode, which starts a root shell without launching the full init sequence. This bypasses the failing services that caused the panic, directly satisfying the requirement to reach a root shell for recovery.

Why this answer

Option B is correct because appending 'single' (or '1') to the kernel command line in GRUB boots the system into single-user/rescue mode, which starts a root shell without requiring the normal login and is a standard recovery method. Option D is correct because appending 'rd.break' to the kernel command line interrupts the boot process in the initramfs (dracut) before the root filesystem is mounted, dropping the administrator into a root shell where the real root can be mounted and repaired. Option E is correct because booting from a live CD/USB and then chrooting into the installed system's root filesystem gives a root shell with access to the broken system's files and tools, allowing repairs such as reinstalling GRUB or fixing /etc/fstab.

Option A is incorrect because 'fsck /dev/sda1' is not a valid GRUB command-line operation for obtaining a root shell; GRUB's command line is for bootloader commands, not for running filesystem checks as a recovery shell. Option C is incorrect because pressing 'e' in GRUB only opens the menu entry for editing and removing 'quiet' merely changes console verbosity; it does not by itself provide a root shell.

Exam trap

The trap here is that candidates may confuse the GRUB command line with a Linux shell, mistakenly thinking filesystem repair commands like fsck can be run directly from GRUB, or they may think removing 'quiet' alone grants root access when it only affects verbosity.

79
MCQeasy

An administrator needs to schedule a backup script located at '/usr/local/bin/backup.sh' to run every Sunday at 2:30 AM. The server uses cron for task scheduling. The administrator currently has the following crontab entry: '30 2 * * 0 /usr/local/bin/backup.sh'. However, the administrator wants to verify that the cron job is configured correctly and will run as expected. Which of the following commands should the administrator use to list the current user's cron jobs and verify the entry?

A.cat /var/spool/cron/crontabs/root
B.systemctl status cron
C.cron -l
D.crontab -l
AnswerD

crontab -l lists the invoking user's current crontab entries, letting the administrator confirm the '30 2 * * 0 /usr/local/bin/backup.sh' line is present and correctly formed. It reads the schedule without modifying it, satisfying the verification requirement.

Why this answer

The 'crontab -l' command lists the current user's crontab entries. Option D is correct. 'cron -l' is not a valid command. 'cat /var/spool/cron/crontabs/root' might work for root but not for a regular user, and the path varies. 'systemctl status cron' shows the cron service status, not the job list.

80
Matchingmedium

Match each Linux package manager to its distribution family.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Debian/Ubuntu

RHEL/CentOS 7

Fedora/RHEL 8+

openSUSE/SLES

Arch Linux

Why these pairings

Different Linux distributions use different package managers: apt is for Debian-based, yum/dnf for Red Hat-based, and pacman for Arch Linux. Common confusions include mixing apt with Red Hat or yum with Arch.

81
MCQeasy

A Linux administrator needs to ensure that all user passwords meet a minimum length of 12 characters and include at least one uppercase letter, one lowercase letter, one digit, and one special character. Which file should be edited to enforce these password complexity requirements?

A./etc/security/pwquality.conf
B./etc/pam.d/system-auth
C./etc/login.defs
D./etc/shadow
AnswerA

The /etc/security/pwquality.conf file is used by the pam_pwquality module to enforce password complexity rules such as minimum length (minlen), required character classes (ucredit, lcredit, dcredit, ocredit), and other checks. Editing this file allows the administrator to set these requirements system-wide for all users, ensuring compliance with the security policy.

Why this answer

Password complexity requirements are enforced by the pam_pwquality module, which reads its configuration from /etc/security/pwquality.conf. This file allows setting parameters like minlen, ucredit, lcredit, dcredit, and ocredit to require specific character types and lengths. The other files serve different purposes and cannot enforce these rules.

Exam trap

The trap here is assuming that /etc/login.defs handles all password policies, but it only covers aging and minimum length, not character complexity.

82
MCQhard

A server fails to boot with a kernel panic after a system update. The administrator suspects a corrupt initramfs. Which GRUB boot parameter should be added temporarily to boot into an emergency shell where the filesystem can be repaired?

A.rd.break
B.emergency
C.single
D.nomodeset
AnswerA

rd.break interrupts boot before the initramfs hands control to systemd, dropping into a switch_root emergency shell with the real root mounted read-only at /sysroot. This lets the administrator remount it read-write and repair the corrupt initramfs, satisfying the temporary-boot-parameter constraint.

Why this answer

rd.break is a kernel boot parameter that interrupts the boot process before the initramfs switches control to the real root filesystem, dropping the administrator into a debug shell (switch_root prompt). From there, the root filesystem can be mounted read-write and repaired, or the initramfs regenerated. This is the standard RHEL/CentOS method for recovering from a corrupt initramfs or forgotten root password.

Exam trap

XK0-006 often tests the distinction between rd.break (initramfs-stage break) and emergency/single (systemd-stage targets), so candidates must recognize that a corrupt initramfs requires breaking before switch_root.

How to eliminate wrong answers

Option B is wrong because emergency is a systemd target (emergency.target) that is reached after the initramfs has already handed off to the real root — if the initramfs is corrupt, the system may not reach it. Option C is wrong because single (or single-user mode) also requires a functioning initramfs to mount the root filesystem and start systemd in rescue mode. Option D is wrong because nomodeset only disables kernel mode setting for graphics drivers and has nothing to do with initramfs repair or emergency shell access.

83
MCQmedium

A technician needs to check the current memory usage on a Linux system, including buffers and cache. Which command provides the most user-friendly output?

A.free -h
B.cat /proc/meminfo
C.iostat -m
D.vmstat -s
AnswerA

free -h reports total, used, free, shared, buffer/cache and available memory, with the -h flag scaling values into human-readable units. That satisfies the user-friendly requirement while still exposing buffers and cache, which plain free shows only in kilobytes.

Why this answer

The `free -h` command displays memory usage in a human-readable format (e.g., KiB, MiB, GiB) and explicitly breaks down total, used, free, shared, buffers/cache, and available memory. This makes it the most user-friendly option for quickly assessing current memory usage including buffers and cache.

Exam trap

The trap here is that candidates may choose `cat /proc/meminfo` because it contains all the raw data, but the question specifically asks for the 'most user-friendly' output, which `free -h` provides with its human-readable scaling and clear summary columns.

How to eliminate wrong answers

Option B is wrong because `cat /proc/meminfo` provides raw, detailed memory statistics in a machine-readable format without any human-friendly scaling or summary, making it less user-friendly for a quick check. Option C is wrong because `iostat -m` reports CPU and I/O statistics (in megabytes), not memory usage, buffers, or cache. Option D is wrong because `vmstat -s` displays a summary of virtual memory statistics (including paging, swapping, and CPU events) but does not present buffers/cache in a clear, human-readable layout like `free -h`.

84
MCQeasy

A Linux administrator needs to locate all files in /var/log that were modified more than 7 days ago. Which command should be used?

A.find /var/log -mtime +7
B.grep -mtime +7 /var/log
C.ls -mtime +7 /var/log
D.locate -mtime +7 /var/log
AnswerA

The +7 argument to -mtime matches files whose modification time is greater than seven 24-hour periods ago, exactly the age threshold the stem specifies. The minus form would instead select files modified within the last seven days.

Why this answer

The find command with -mtime +7 finds files modified more than 7 days ago. locate uses a database and does not support -mtime; grep is for text search; ls does not filter by modification time.

85
MCQhard

An administrator is troubleshooting a service that fails to start. They want to trace the system calls made by the service binary. Which command should they use?

A.ltrace
B.dmesg
C.strace
D.lsof
AnswerC

strace attaches to the process and prints each system call with arguments and return values, exposing where startup fails, such as a missing file or denied permission. It satisfies the requirement to trace system calls made by the service binary.

Why this answer

strace traces system calls and signals. It is used to debug what a program is doing at the kernel level.

86
MCQmedium

Refer to the exhibit. A Docker container using a bind mount fails to start with a permission error. What is the most likely cause?

A.The container is running in privileged mode.
B.The Docker daemon is not running as root.
C.SELinux is blocking the mount.
D.The volume path on the host does not exist.
AnswerC

SELinux labels govern container access to host paths; a bind-mounted directory lacking the container_file_t label is denied even when Unix permissions look correct. The AVC denial in the audit log confirms SELinux, not ownership or mount syntax, blocks the mount.

Why this answer

When a Docker container uses a bind mount and fails with a permission error, SELinux is a common cause because it enforces mandatory access controls that can block container processes from accessing host files. By default, SELinux labels container processes with a confined domain (e.g., container_t), and if the bind-mounted host directory lacks the proper SELinux context (e.g., container_file_t), the mount is denied. This is resolved by adding the `:Z` or `:z` flag to the bind mount in the Docker run command to relabel the host directory appropriately.

Exam trap

CompTIA often tests the distinction between filesystem permission errors (e.g., user ID mismatch) and SELinux denials, where candidates mistakenly choose 'privileged mode' or 'daemon not root' because they overlook SELinux as the underlying cause in a bind mount context.

How to eliminate wrong answers

Option A is wrong because running the container in privileged mode grants all capabilities and bypasses most security restrictions, but it does not automatically resolve SELinux denials; in fact, privileged mode may still be blocked by SELinux unless SELinux is disabled or the context is set. Option B is wrong because the Docker daemon typically runs as root, and even if it did not, the permission error from a bind mount is more likely related to SELinux or filesystem permissions, not the daemon's user ID. Option D is wrong because if the volume path on the host did not exist, Docker would create it as a directory (unless a file is expected), and the error would be a 'no such file or directory' message, not a permission error.

87
MCQeasy

A Linux administrator needs to add a new user named 'jdoe' with a home directory and a bash shell. Which command accomplishes this?

A.usermod -m -s /bin/bash jdoe
B.adduser jdoe --home /home/jdoe --shell /bin/bash
C.useradd -m -s /bin/bash jdoe
D.passwd -m jdoe
AnswerC

The -m flag creates the home directory and -s /bin/bash sets the login shell, satisfying both stated requirements in one command. Without -m, useradd leaves no home directory; without -s, the system default shell applies.

Why this answer

The useradd command with -m creates the home directory and -s /bin/bash sets the login shell, so 'useradd -m -s /bin/bash jdoe' creates user jdoe with a home directory and bash shell in one step. This is the canonical low-level command on RHEL/CentOS and other systemd-based distributions for non-interactive user creation.

Exam trap

The trap is confusing useradd (create) with usermod (modify) and mixing Debian's adduser syntax with RHEL's useradd — candidates who don't check the distro context pick the wrong command.

How to eliminate wrong answers

Option A is wrong because usermod modifies an existing user; it will fail if jdoe does not already exist, and it does not create a home directory from scratch for a new account. Option B is wrong because the adduser syntax with --home and --shell flags is Debian/Ubuntu-specific (and even there, adduser uses --home and --shell but the option ordering and behavior differ); on RHEL-family systems adduser is a symlink to useradd and does not accept those long options. Option D is wrong because passwd only sets or changes a user's password and has no -m option for home directory creation.

88
MCQhard

A Linux administrator is troubleshooting a service that fails to start. The service's unit file has a dependency on another service, but the dependent service is not running. The administrator wants to view the dependency tree of the failing service to understand the ordering and requirements. Which command should be used?

A.systemctl list-dependencies failing.service
B.systemctl cat failing.service
C.journalctl -u failing.service
D.systemctl status failing.service
AnswerA

systemctl list-dependencies displays a tree of the specified unit's dependencies, including requires, wants, and after/before relationships. This directly shows the administrator which services the failing unit depends on and their current state, helping identify the missing dependency.

Why this answer

systemctl list-dependencies is specifically designed to show the dependency tree of a unit, including which units are required or wanted and their current states. It provides a clear hierarchical view that helps diagnose why a service fails due to unmet dependencies. Other commands show status or logs but not the dependency structure.

Exam trap

The trap here is assuming that systemctl status or journalctl will show the full dependency tree; they only show symptoms or configuration, not the runtime dependency hierarchy.

89
MCQhard

A system administrator needs to install a package from a local RPM file without resolving dependencies automatically. Which command should be used?

A.rpm -i package.rpm
B.rpm -U package.rpm
C.yum localinstall package.rpm
D.dnf install ./package.rpm
AnswerA

The rpm -i command installs a local package file directly without contacting repositories or resolving dependencies, matching the requirement to skip automatic dependency resolution. Tools like dnf or yum would instead fetch and resolve dependencies.

Why this answer

The `rpm -i package.rpm` command installs the specified RPM package without automatically resolving dependencies. The `-i` flag stands for 'install' and, unlike `-U` (upgrade) or higher-level tools like `yum` or `dnf`, it does not attempt to fetch or satisfy missing dependencies from configured repositories. This is the correct choice when the requirement is to install a local RPM file while explicitly avoiding automatic dependency resolution.

Exam trap

The trap here is that candidates often confuse `rpm -i` with `rpm -U` or assume that higher-level tools like `yum` or `dnf` can be used to install local RPMs without dependency resolution, but those tools are designed to automatically resolve dependencies, which directly violates the question's constraint.

How to eliminate wrong answers

Option B is wrong because `rpm -U package.rpm` performs an upgrade or install, but it still does not resolve dependencies automatically; however, the question specifically asks for a command that installs without resolving dependencies, and `-U` is semantically an upgrade operation, not a pure install. Option C is wrong because `yum localinstall package.rpm` is a higher-level command that resolves and installs dependencies from repositories, which contradicts the requirement to avoid automatic dependency resolution. Option D is wrong because `dnf install ./package.rpm` also resolves dependencies automatically using DNF's dependency solver, making it unsuitable for the stated requirement.

90
MCQhard

A Linux administrator needs to parse a structured configuration file and extract the value of a specific key. The file format is JSON, and the administrator wants to use a command-line tool that is commonly preinstalled on modern Linux distributions. Which command should the administrator use?

A.jq
B.awk
C.grep
D.sed
AnswerA

jq is a lightweight command-line JSON processor that is widely available in distribution repositories and is often preinstalled on modern systems. It can parse JSON, filter with expressions such as .key, and output the value, which directly satisfies the requirement to extract a specific key from a structured JSON file.

Why this answer

jq is purpose-built for JSON, understands the format's structure, and is commonly available on modern Linux distributions. It can extract a specific key with a simple filter and correctly handles nested data, escaping, and type conversions, making it the appropriate choice for parsing a JSON configuration file.

Exam trap

The trap here is assuming that general-purpose text tools like sed, awk, or grep can reliably parse JSON, when their line-oriented nature breaks on nested or formatted JSON.

91
Drag & Dropmedium

Drag and drop the steps to mount a new filesystem in the correct order.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4

Why this order

Mounting a filesystem requires creating a mount point and using the mount command with the device and mount point.

92
MCQhard

A company requires that all systems be configured to log all authentication attempts, both successful and failed. Which configuration file and directive should be used to ensure all auth messages are logged to /var/log/secure?

A.In /etc/rsyslog.conf: *.info /var/log/secure
B.In /etc/rsyslog.conf: auth.* /var/log/secure
C.In /etc/rsyslog.conf: authpriv.* /var/log/secure
D.In /etc/rsyslog.conf: kern.* /var/log/secure
AnswerC

The `authpriv.*` facility with wildcard priority captures every authentication message, including both successful and failed attempts, across all severity levels. Directing this to `/var/log/secure` satisfies the requirement that all auth events be logged there. The `authpriv` facility is specifically designated for security and authorisation messages, making it the precise match.

Why this answer

In rsyslog, the `authpriv` facility covers authentication and authorization messages, including both successful and failed login attempts. The directive `authpriv.* /var/log/secure` directs all messages from this facility to `/var/log/secure`, which is the standard secure log file on RHEL/CentOS systems. This meets the requirement to log all authentication attempts.

Exam trap

The trap here is that candidates confuse the `auth` and `authpriv` facilities, assuming `auth.*` is correct because it sounds like 'authentication', but `authpriv` is the actual facility used by modern Linux authentication subsystems like PAM and sshd.

How to eliminate wrong answers

Option A is wrong because `*.info` selects all messages with severity info or higher, which would flood `/var/log/secure` with non-authentication messages (e.g., cron, mail, daemon logs), not specifically auth messages. Option B is wrong because `auth.*` uses the `auth` facility, which is typically used for legacy or non-privileged authentication; on modern Linux systems, authentication logs are generated under the `authpriv` facility, so `auth.*` would miss many auth-related messages. Option D is wrong because `kern.*` selects kernel messages only, which are unrelated to authentication attempts and are typically logged to `/var/log/kern.log` or `/var/log/messages`.

93
MCQmedium

An administrator needs to prevent a specific user 'bob' from logging in via SSH while allowing other users. Which configuration directive should be added to /etc/ssh/sshd_config?

A.AllowUsers alice charlie
B.PermitRootLogin no
C.DenyUsers bob
D.AllowUsers bob
AnswerC

DenyUsers bob blocks only the named account at authentication, leaving all other users unaffected, which satisfies the stem's requirement to prevent 'bob' specifically while permitting everyone else. Applied in sshd_config and reloaded, it is evaluated before AllowUsers, so no broader access rule is needed.

Why this answer

The DenyUsers directive in /etc/ssh/sshd_config explicitly blocks specific usernames from logging in via SSH. By specifying 'DenyUsers bob', only user bob is denied, while all other users remain allowed. This matches the requirement to prevent bob without affecting others.

AllowUsers with a whitelist would also block bob but would require listing every other user, which is impractical and not the intended solution.

Exam trap

The trap is that candidates may choose AllowUsers with a whitelist (like option A) thinking it blocks bob, but it also blocks all other users not in the list. The question's requirement to 'prevent bob while allowing other users' is best met by a blacklist approach using DenyUsers. This tests understanding of whitelist vs. blacklist logic.

How to eliminate wrong answers

Option B is wrong because PermitRootLogin no only prevents the root user from logging in via SSH; it has no effect on regular users like 'bob'. Option C is wrong because DenyUsers bob would explicitly block 'bob', but the question asks for a directive that prevents 'bob' while allowing other users; while DenyUsers works, the correct answer is AllowUsers as it is the more direct and commonly tested approach for this scenario. Option D is wrong because AllowUsers bob would permit only 'bob' to log in, blocking all other users including alice and charlie, which is the opposite of the requirement.

94
MCQmedium

A Bash script contains the following line: set -e. What is the effect of this command?

A.It enables debugging by printing commands and their arguments as they are executed.
B.It prevents the script from overwriting existing files.
C.It causes the script to exit if any command fails.
D.It treats unset variables as an error and exits.
AnswerC

The set -e option sets errexit, so Bash terminates the script immediately when any command returns a non-zero exit status. This satisfies the requirement to halt execution on failure rather than continuing through subsequent commands.

Why this answer

set -e causes the script to exit immediately if any command exits with a non-zero status. This is useful for catching errors early.

95
MCQmedium

A Linux administrator is investigating why a scheduled backup job did not run overnight. The job is defined in the root user's crontab. Which command should the administrator use to review the cron daemon's log entries for the relevant time period?

A.crontab -l -u root
B.atq
C.journalctl -u cron --since "yesterday"
D.systemctl list-timers --all
AnswerC

On systems using systemd, the cron daemon runs as a unit, so journalctl -u cron retrieves its log entries. Adding --since "yesterday" limits output to the relevant window. This shows whether cron attempted to start the job, any errors it logged, and whether the job was skipped. It directly addresses why the scheduled backup did not execute.

Why this answer

To determine why a cron job did not execute, the administrator must examine the cron daemon's logs for the relevant period. On systemd-based distributions, cron is managed as a unit, so journalctl -u cron with a time filter surfaces start attempts, command errors, and skipped jobs. Listing the crontab or checking unrelated schedulers does not provide execution history.

Exam trap

The trap here is verifying the crontab definition instead of checking daemon logs, which is where evidence of whether the job actually ran and any errors it produced is recorded.

96
MCQeasy

In bash, what is the difference between single quotes and double quotes?

A.Single quotes prevent variable expansion, double quotes allow it.
B.Both allow variable expansion, but double quotes also allow globbing.
C.Single quotes allow variable expansion, double quotes do not.
D.There is no difference; they are interchangeable.
AnswerA

Single quotes treat every character literally, so a variable such as $HOME is passed unchanged, whereas double quotes permit parameter and variable expansion, command substitution and escape sequences. This quoting distinction determines whether the shell interprets the enclosed text before passing it to the command.

Why this answer

Single quotes preserve the literal value of each character, while double quotes allow variable expansion and command substitution.

97
MCQeasy

A new employee needs a user account on a Linux server. The administrator runs 'useradd -m jdoe' and then 'passwd jdoe'. After setting the password, the employee reports that they cannot log in via SSH. The administrator verifies the password is correct. Which file should the administrator check to ensure the account is not locked?

A./etc/login.defs
B./etc/shadow
C./etc/group
D./etc/passwd
AnswerB

The /etc/shadow file contains the encrypted password and account aging information. A locked account is typically indicated by a '!' or '*' prefix in the password field. The administrator should inspect this file to see if the account is locked, which would prevent SSH login even with the correct password.

Why this answer

The /etc/shadow file holds the password hash and lock indicator. A locked account often has an exclamation mark or asterisk prepended to the password hash, which prevents authentication. Since the password was set correctly, the next step is to verify the account is not locked in /etc/shadow, for example by checking for a '!' prefix.

Exam trap

The trap here is assuming that a correct password guarantees login, overlooking that an account can be locked in /etc/shadow.

98
MCQmedium

A user reports that a service fails to start with the error 'Permission denied'. The service runs under a non-root user. Which command should the administrator use to check if the service has the correct file permissions?

A.namei -l /path/to/service
B.ls -l /path/to/service
C.getfacl /path/to/service
D.stat /path/to/service
AnswerA

`namei -l /path/to/service` resolves every path component and prints each one's owner, group and permission bits, exposing exactly where the non-root service account lacks execute or read access. This directly satisfies the stem's requirement to verify correct file permissions along the full path, not just the final binary.

Why this answer

The error 'Permission denied' when starting a service under a non-root user often involves not just the file's own permissions but also the permissions of each directory in the path leading to the service binary. The `namei -l` command recursively lists the permissions of every component in the path, revealing if any parent directory lacks execute (search) permission for the service user, which would block access even if the binary itself is correctly set. This makes it the most comprehensive tool for diagnosing path-based permission issues.

Exam trap

The trap here is that candidates assume `ls -l` or `stat` on the service binary alone is sufficient, overlooking that the 'Permission denied' error often originates from a missing execute bit on a parent directory in the path, which only `namei -l` can reveal by checking every component.

How to eliminate wrong answers

Option B is wrong because `ls -l` only shows the permissions of the final file or directory, not the intermediate directories in the path, so it cannot detect a missing execute permission on a parent directory that causes the 'Permission denied' error. Option C is wrong because `getfacl` displays only the ACL entries for a single file or directory, not the recursive path permissions, and ACLs are an extended permission mechanism that may not be the root cause if standard Unix permissions are misconfigured on a parent directory. Option D is wrong because `stat` provides detailed metadata (inode, timestamps, permissions) for a single file or directory but, like `ls -l`, does not traverse and display permissions for each component in the path, missing the common scenario where a parent directory lacks the execute bit.

99
MCQmedium

An administrator wants to restrict SSH access to only users in the 'sshusers' group. Which configuration directive should be added to /etc/ssh/sshd_config?

A.AllowUsers sshusers
B.Match Group sshusers
C.AllowGroups sshusers
D.DenyGroups all
AnswerC

AllowGroups restricts SSH logins to members of the named group, so only users in sshusers may authenticate. Unlike AllowUsers, which lists individual accounts, this directive scales by group membership, directly satisfying the requirement to limit access to that group.

Why this answer

The AllowGroups directive in /etc/ssh/sshd_config explicitly permits SSH login only for users who are members of the specified group(s). When AllowGroups sshusers is set, any user not in the 'sshusers' group is denied access, regardless of other settings. This is the correct and direct way to restrict SSH access to a specific group.

Exam trap

The trap here is confusing AllowUsers with AllowGroups, or thinking Match Group restricts access when it only applies conditional settings.

How to eliminate wrong answers

Option A is wrong because AllowUsers expects a list of usernames, not group names; using 'sshusers' would be interpreted as a username, not a group. Option B is wrong because Match Group is used to apply conditional configuration blocks for users in a group, but it does not by itself restrict access; it only sets the context for subsequent directives. Option D is wrong because DenyGroups all would deny access to all groups, effectively blocking everyone, which is the opposite of the intended restriction.

100
MCQmedium

A system administrator wants to view the last 10 lines of a log file and also save those lines to another file for analysis. Which command should the administrator use?

A.head -n 10 file | tee output.txt
B.cat file | tee output.txt
C.tail -n 10 file | tee output.txt
D.tee output.txt < tail -n 10 file
AnswerC

tail -n 10 extracts the final ten lines, and piping into tee writes them to output.txt while also displaying them on stdout. Redirection with > would suppress terminal output, and tee -a would append rather than create, so this pipeline satisfies both viewing and saving.

Why this answer

The command 'tail -n 10 file | tee output.txt' displays the last 10 lines of the file and simultaneously writes those lines to output.txt. The tail command extracts the last 10 lines, and tee duplicates the output to both the terminal and the specified file.

Exam trap

XK0-006 often tests the difference between head and tail, and the correct usage of tee with pipes; candidates may confuse head with tail or misuse redirection syntax.

How to eliminate wrong answers

Option A is wrong because 'head -n 10' displays the first 10 lines, not the last 10. Option B is wrong because 'cat file | tee output.txt' outputs the entire file, not just the last 10 lines. Option D is wrong because the syntax 'tee output.txt < tail -n 10 file' is invalid; input redirection cannot be used with a command as a file, and tee expects input from stdin, not from a command substitution in that form.

101
Multi-Selectmedium

An administrator is troubleshooting a Pod in a Kubernetes cluster that is not starting. Which TWO kubectl commands are most useful for diagnosing the issue? (Choose TWO.)

Select 2 answers
A.kubectl get nodes
B.kubectl apply -f pod.yaml
C.kubectl delete pod <pod-name>
D.kubectl logs <pod-name>
E.kubectl describe pod <pod-name>
AnswersD, E

`kubectl logs <pod-name>` retrieves stdout/stderr from the Pod's containers, exposing application-level failures such as crash loops, misconfiguration or missing dependencies that block startup. When a Pod is running but not Ready, or restarting repeatedly, container output pinpoints the fault directly, satisfying the need to diagnose why the Pod fails to start.

Why this answer

kubectl describe pod provides detailed event and status information, and kubectl logs retrieves container logs.

102
MCQmedium

A container is running a database service that requires persistent storage. The administrator wants to ensure that data persists even if the container is removed. Which volume mount type should be used in the Docker run command?

A.--mount type=volume
B.--mount type=bind
C.COPY in Dockerfile
D.--mount type=tmpfs
AnswerA

A named volume is stored outside the container's writable layer, so Docker preserves the database files when the container is deleted. Bind mounts tie data to a host path, but type=volume is the mechanism that guarantees persistence across container removal.

Why this answer

Docker volumes are the preferred mechanism for persisting data generated by and used by Docker containers. Volumes are completely managed by Docker, are independent of the container lifecycle, and can be backed up easily. They persist even after the container is removed, making them ideal for database services.

While bind mounts (option B) also provide persistence by mapping a host directory, they are less portable and have security considerations. Since the question does not specify a need for host directory mapping, volumes are the recommended choice.

Exam trap

The trap is that candidates might think bind mounts are the only way to achieve persistence, but Docker volumes also persist data and are actually the recommended approach for persistent storage. The key is that volumes are managed by Docker and are more portable.

How to eliminate wrong answers

Option A is wrong because `--mount type=volume` creates a Docker-managed volume that persists data, but the question specifies the administrator wants data to persist even if the container is removed; while volumes also persist, the correct answer for the given scenario is bind mount, as the question implies a direct host path mapping. Option C is wrong because `COPY` in a Dockerfile only copies files into the image at build time, not at runtime, and does not provide persistent storage that survives container removal. Option D is wrong because `--mount type=tmpfs` mounts a temporary filesystem stored in memory, which is volatile and data is lost when the container stops or is removed.

103
Multi-Selecthard

A Linux administrator is writing a Bash script that must parse command-line options, accept a required input file argument, and provide a help message when invoked with -h. The script will be run on several distributions. Which TWO practices should the administrator follow? (Choose two.)

Select 2 answers
A.Hard-code the input file path inside the script so the required argument is always available.
B.Use getopts to process short options and validate that required arguments are present before proceeding.
C.Rely on the positional parameters $1 and $2 directly and check only that $# is greater than zero.
D.Use getopt (the external utility) with the long-option form and eval to reorder arguments before parsing.
E.Define a usage function that prints to standard error and exits with a non-zero status when arguments are invalid.
AnswersB, E

getopts is a POSIX shell builtin that parses short options consistently across shells and distributions. It sets OPTARG for options that take a value and OPTIND for the next argument, so the script can detect missing required arguments and print usage before doing any work. This meets the portability and validation goals in the scenario.

Why this answer

Portable option parsing and clear error handling are the two practices that make the script usable across distributions. getopts handles short options and required arguments in a POSIX-compliant way, while a dedicated usage function standardizes the help and error output. Together they ensure -h works, missing arguments are detected, and failures are reported through exit status.

Exam trap

The trap here is assuming the external getopt utility is fully portable and safe to eval, when the shell builtin getopts is the portable standard for short options.

104
MCQhard

An administrator is troubleshooting a service that fails to start. The administrator wants to view the last 50 lines of the service's journal log entries from the current boot. Which journalctl command should be used?

A.journalctl -f -n 50 -u service
B.journalctl -u service --since today
C.journalctl -x -n 50 -u service
D.journalctl -u service -b -n 50
AnswerD

Filtering with `-u service` isolates that unit's entries, `-b` restricts output to the current boot, and `-n 50` returns only the last 50 lines — satisfying every constraint in the stem simultaneously. Omitting any flag would show other units, previous boots, or the entire journal.

Why this answer

The command journalctl -u service -b -n 50 filters by unit (-u), restricts to the current boot (-b), and shows the last 50 lines (-n 50), which exactly matches the requirement. The -b flag is the key differentiator because it limits output to the current boot session, avoiding entries from prior boots.

Exam trap

XK0-006 often tests flag combinations that look similar — candidates confuse -f (follow) with -n (number of lines) and forget that -b is required to scope to the current boot, picking options that filter by time instead.

How to eliminate wrong answers

Option A is wrong because -f follows the journal in real time (like tail -f) and does not restrict to the current boot; it also blocks the terminal, which is not what the administrator asked for. Option B is wrong because --since today filters by time, not by boot session, so it may include entries from earlier boots that occurred today and does not guarantee the last 50 lines. Option C is wrong because -x adds explanatory/catalog context to messages but does not restrict to the current boot, so it may return entries from previous boots.

105
MCQeasy

A Linux administrator needs to write a Bash script that runs a series of commands and stops immediately if any command fails. Which directive should be included at the beginning of the script?

A.#!/bin/bash
B.trap ... ERR
C.set -e
D.set -x
AnswerC

set -e makes Bash exit immediately when any command returns a non-zero status, so the script halts on the first failure. Placed at the top, it satisfies the requirement to stop immediately rather than continue executing subsequent commands.

Why this answer

The set -e directive (also written set -o errexit) instructs Bash to exit immediately if any command returns a non-zero exit status. Placing it at the top of a script ensures the script halts on the first failure rather than continuing with potentially harmful subsequent commands. This is the standard idiom for fail-fast Bash scripts.

Exam trap

The trap is confusing set -e (exit on error) with set -x (trace commands) or with trap ERR (custom error handler) — candidates must remember that only set -e provides the immediate-exit behavior the question requires.

How to eliminate wrong answers

Option A is wrong because #!/bin/bash is the shebang line that specifies the interpreter; it does not affect error handling. Option B is wrong because trap ... ERR sets a handler to run on error but does not by itself cause the script to exit — it requires additional logic such as 'trap "exit 1" ERR'.

Option D is wrong because set -x enables command tracing for debugging, printing each command before execution, but does not stop execution on failure.

106
MCQeasy

Based on the exhibit, what is the most likely cause of the sshd service failure?

A.The SSH configuration file has a syntax error.
B.The privilege separation directory /var/empty/sshd does not exist.
C.The sshd PID file cannot be written.
D.The SSH port is already in use by another service.
AnswerB

The sshd daemon requires its privilege separation directory to exist before dropping privileges; if /var/empty/sshd is missing, systemd reports the unit as failed immediately on start. This directly satisfies the exhibit's constraint, where sshd exits at launch rather than rejecting connections, confirming the missing directory as the cause.

Why this answer

The error message 'Privilege separation directory /var/empty/sshd does not exist' directly indicates that the required chroot directory for the unprivileged sshd process is missing. Without this directory, sshd cannot drop privileges after authentication, causing it to fail on startup. This is a common issue after a partial installation or cleanup of OpenSSH.

Exam trap

CompTIA often tests the specific error message 'Privilege separation directory /var/empty/sshd does not exist' to trap candidates who assume the failure is due to a configuration syntax error or port conflict, rather than recognizing the missing chroot directory as a distinct startup prerequisite.

How to eliminate wrong answers

Option A is wrong because a syntax error in the SSH configuration file would typically produce a specific parse error message (e.g., 'Bad configuration option' or 'line X: syntax error'), not a missing directory error. Option C is wrong because the inability to write the PID file would generate a 'Could not create PID file' or 'Permission denied' message, not a privilege separation directory error. Option D is wrong because if the SSH port were already in use, the error would be 'Address already in use' or 'bind: Address in use', which is a socket binding failure, not a missing directory.

107
MCQhard

A Kubernetes administrator needs to expose a deployment named 'web-app' running on port 80 internally within the cluster. Which kubectl command creates a service of type ClusterIP that maps port 80 to the target port 8080 on the pods?

A.kubectl create service nodeport web-app --tcp=80:8080
B.kubectl expose deployment web-app --port=80 --target-port=8080
C.kubectl expose pod web-app --port=80 --target-port=8080
D.kubectl create service clusterip web-app --tcp=80:8080
AnswerB

`kubectl expose deployment web-app --port=80 --target-port=8080` generates a ClusterIP service, the default type, satisfying the internal-only requirement. The `--port` flag sets the service port to 80, while `--target-port=8080` directs traffic to the container's listening port, correctly mapping the mismatch between service and pod ports.

Why this answer

The command 'kubectl expose deployment web-app --port=80 --target-port=8080' creates a Service of type ClusterIP (the default) that exposes the deployment 'web-app'. The --port flag sets the Service port to 80, and --target-port sets the container port to 8080, correctly mapping Service port 80 to pod port 8080.

Exam trap

XK0-006 often tests the difference between exposing a deployment vs. a pod, and between ClusterIP/NodePort/LoadBalancer service types — candidates pick 'create service nodeport' or expose a pod, missing that the default type is ClusterIP and that deployments should be exposed for scalability.

How to eliminate wrong answers

Option A is wrong because 'kubectl create service nodeport' creates a NodePort service (exposing the service on each node's IP at a static port), not a ClusterIP service, and it uses the --tcp flag syntax rather than --port/--target-port. Option C is wrong because it exposes a pod named 'web-app' rather than the deployment; while it might work if a pod with that name exists, the question specifies exposing the deployment, and exposing a pod directly bypasses the deployment's replica management and load balancing across pods. Option D is wrong because 'kubectl create service clusterip' creates a ClusterIP service but uses the --tcp=<port>:<targetPort> syntax and does not reference the deployment's selector automatically — it requires manual selector specification and does not tie to the deployment by name.

108
MCQeasy

A Linux administrator needs to grant a user the ability to run a specific command as root without being prompted for a password, while restricting all other commands. Which file should be edited to configure this using sudo?

A./etc/security/access.conf
B./etc/sudoers
C./etc/sudo.conf
D./etc/pam.d/sudo
AnswerB

The /etc/sudoers file is the primary configuration file for sudo. It allows administrators to define which users or groups can run which commands, and with what options. To grant a user passwordless execution of a specific command, an entry such as username ALL=(ALL) NOPASSWD: /path/to/command is added. This file should be edited with visudo to prevent syntax errors.

Why this answer

The /etc/sudoers file is the standard configuration file for sudo, where administrators define user privileges and command restrictions. To allow a user to run a specific command without a password, an entry with NOPASSWD is added. This file should be edited with visudo to ensure syntax correctness.

Other files like sudo.conf or PAM configurations serve different purposes and do not control command authorization.

Exam trap

The trap here is confusing sudo configuration files with PAM or access control files, which handle authentication and login restrictions rather than sudo command permissions.

109
MCQmedium

The output of df -h shows the root filesystem at 100% capacity. Which of the following commands should the administrator run NEXT to identify the cause?

A.fdisk -l /dev/sda
B.fsck /dev/sda1
C.ls -la /
D.du -sh /*
AnswerD

du -sh /* reports the total disk usage of each top-level directory, revealing which directory consumes the root filesystem. This identifies the cause of the 100% capacity shown by df -h, which only reports filesystem-level totals, not per-directory breakdown.

Why this answer

The `du -sh /*` command calculates and displays the disk usage of each top-level directory in the root filesystem. When `df -h` shows 100% capacity, the next logical step is to identify which directories are consuming the most space, so the administrator can drill down further. This command is the standard tool for pinpointing space hogs before taking corrective action.

Exam trap

CompTIA often tests the distinction between listing files (`ls`) and measuring disk usage (`du`), trapping candidates who think `ls -la /` will reveal space consumption when it only shows metadata and not recursive sizes.

How to eliminate wrong answers

Option A is wrong because `fdisk -l /dev/sda` is used to list partition tables, not to identify which files or directories are consuming disk space; it provides no insight into filesystem usage. Option B is wrong because `fsck /dev/sda1` checks and repairs filesystem integrity, but running it on a mounted, full filesystem can cause data corruption and does not address the root cause of capacity exhaustion. Option C is wrong because `ls -la /` lists the contents of the root directory with metadata but does not aggregate sizes recursively, so it cannot show which subdirectories are using the most space.

110
MCQmedium

A Linux administrator needs to grant the user 'jsmith' the ability to restart the httpd service without entering a password, while preventing all other sudo commands. The administrator creates the file /etc/sudoers.d/jsmith with the line: jsmith ALL=(root) NOPASSWD: /usr/bin/systemctl restart httpd. After saving the file, jsmith reports that sudo still prompts for a password. Which command should the administrator run to diagnose the issue?

A.journalctl -u sudo
B.sudo -l -U jsmith
C.visudo -c
D.grep jsmith /etc/sudoers
AnswerB

The sudo -l -U jsmith command lists the sudo privileges for the specified user, showing exactly which commands jsmith may run and whether NOPASSWD applies. This directly reveals whether the sudoers.d file is being parsed correctly and whether the rule matches the intended command path, helping diagnose why a password is still requested.

Why this answer

The sudo -l -U jsmith command displays the sudo privileges for jsmith, including whether NOPASSWD is applied to the specified command. This directly shows if the rule in /etc/sudoers.d/jsmith is being read and matched, which is essential for troubleshooting why a password is still required.

Exam trap

The trap here is assuming that syntax checking alone confirms that a sudo rule is active for a user, when in fact you must inspect the effective privileges.

111
MCQeasy

What does the output in the exhibit indicate about the /etc/shadow file?

A.The file has an SELinux context.
B.The file is encrypted.
C.The file has an ACL applied.
D.The file is compressed.
AnswerA

An SELinux context label, such as `system_u:object_r:shadow_t:s0`, confirms mandatory access control enforcement on /etc/shadow. This satisfies the stem's requirement to identify SELinux metadata, since the context field appears in extended attributes rather than standard Unix permissions, distinguishing it from traditional owner/group/mode output.

Why this answer

The output in the exhibit shows the SELinux context for the /etc/shadow file, which is indicated by the string 'system_u:object_r:shadow_t:s0' appended to the file's permissions. This is the SELinux security context, consisting of user, role, type, and sensitivity level. The `ls -Z` command displays this context, confirming that the file has an SELinux label applied.

Exam trap

The trap here is that candidates confuse the SELinux context (displayed by `ls -Z`) with file encryption or ACLs, because the output shows a colon-separated string that looks like an ACL or encrypted data, but it is actually the SELinux security label.

How to eliminate wrong answers

Option B is wrong because the /etc/shadow file stores password hashes, but the output shown is from `ls -Z`, which displays SELinux contexts, not encryption status; the file itself is not encrypted, only the password fields within it are hashed. Option C is wrong because an ACL (Access Control List) would be indicated by a '+' sign at the end of the permission string (e.g., `-rw-------+`), but the output shows a '.' (or no special character) after the permissions, meaning no ACL is applied. Option D is wrong because a compressed file would typically have a different extension (e.g., .gz, .xz) or be indicated by the `ls` output showing a different size or attribute, and the `ls -Z` output does not show any compression indicator.

112
MCQmedium

A Linux server hosts a web application that must be able to bind to TCP port 443. The administrator has already installed the application and configured it to listen on 443. However, when the service starts, it fails with a 'Permission denied' error. The administrator confirms that no other process is using port 443 and that the service runs as the non-root user 'webapp'. Which command should the administrator use to grant the necessary capability to the service binary without giving it full root privileges?

A.chmod u+s /usr/local/bin/webapp
B.firewall-cmd --add-port=443/tcp --permanent
C.setcap 'cap_net_bind_service=+ep' /usr/local/bin/webapp
D.usermod -aG root webapp
AnswerC

This command assigns the cap_net_bind_service capability to the webapp binary, allowing it to bind to privileged ports (below 1024) without running as root. The +ep flags set the effective and permitted capability sets, enabling the process to use the capability. This is the least-privilege approach and directly resolves the permission denied error for a non-root user.

Why this answer

The service runs as a non-root user and needs to bind to a privileged port (443). Linux capabilities allow fine-grained privilege assignment. The setcap command with cap_net_bind_service grants exactly the needed capability, enabling the binary to bind to low-numbered ports without full root privileges.

This follows the principle of least privilege and is the standard solution for this scenario.

Exam trap

The trap here is assuming that opening the firewall port or adding the user to a group will resolve a bind permission error, when the issue is about Linux capabilities.

113
MCQeasy

A Docker container is running in the background. Which command allows the administrator to execute an interactive bash shell inside the running container named 'webapp'?

A.docker start -i webapp
B.docker run -it webapp bash
C.docker exec -it webapp bash
D.docker attach webapp
AnswerC

docker exec runs a new process inside an already running container; -it allocates an interactive TTY and keeps stdin open, and bash specifies the shell. This satisfies the requirement without restarting or attaching to the main process.

Why this answer

docker exec -it runs an interactive command in a running container. The other commands are for different purposes.

114
MCQmedium

A Linux administrator needs to ensure that a new service, `myapp.service`, starts automatically at boot and is also started immediately, without rebooting. The service unit file is already installed in `/etc/systemd/system/`. Which sequence of commands should the administrator run?

A.systemctl start myapp.service && systemctl enable myapp.service
B.systemctl link /etc/systemd/system/myapp.service && systemctl start myapp.service
C.systemctl daemon-reload && systemctl enable myapp.service
D.systemctl enable --now myapp.service
AnswerD

This command both enables the unit to start at boot and starts it immediately. The `--now` flag combines `enable` and `start`, which is exactly what the administrator needs without rebooting. It is the most efficient and correct way to satisfy both requirements in a single command.

Why this answer

The administrator must both enable the service for automatic startup at boot and start it immediately. The `systemctl enable --now` command accomplishes both tasks in one step, making it the correct choice. Other options either omit the immediate start, omit enabling, or use unnecessary commands like `daemon-reload` or `link` that do not address the requirements.

Exam trap

The trap here is assuming that enabling a service also starts it immediately, or that starting a service also enables it for boot.

115
MCQhard

A system administrator notices that a cron job runs every 5 minutes but should run only on weekdays. The current crontab entry is: */5 * * * * /usr/local/bin/script.sh. Which change to the time fields will restrict execution to Monday through Friday?

A.*/5 9-17 * * 1-5 /usr/local/bin/script.sh
B.*/5 * * * 1-6 /usr/local/bin/script.sh
C.*/5 * * * 1-5 /usr/local/bin/script.sh
D.5 * * * 1-5 /usr/local/bin/script.sh
AnswerC

Runs every 5 minutes, every hour, every day of month, every month, on weekdays (1-5).

Why this answer

The fifth field in a crontab entry specifies the day of the week, where 1 represents Monday and 5 represents Friday. By setting this field to `1-5`, the cron job will only execute on weekdays, while the `*/5` in the minute field ensures it still runs every 5 minutes. The other fields remain as `*` to allow execution at any hour and any day of the month.

Exam trap

The trap here is that candidates may confuse the day-of-week field with the day-of-month field, or incorrectly assume that `1-5` excludes weekends without realizing that cron's day-of-week numbering starts with Sunday as 0, so `1-5` correctly maps to Monday-Friday.

How to eliminate wrong answers

Option A is wrong because it adds a range `9-17` in the hour field, which restricts execution to business hours (9 AM to 5 PM) instead of only weekdays, and this is not required by the question. Option B is wrong because it uses `1-6` for the day-of-week field, which includes Saturday (6) in addition to weekdays, causing the job to run on Saturdays as well. Option D is wrong because it changes the minute field from `*/5` to `5`, meaning the job would run only at minute 5 of every hour, not every 5 minutes, thus altering the frequency requirement.

116
MCQhard

An AppArmor profile for a web server is in complain mode. After testing, the administrator wants to enforce the profile. Which command accomplishes this?

A.apparmor_parser -r /etc/apparmor.d/usr.sbin.httpd
B.aa-enforce /etc/apparmor.d/usr.sbin.httpd
C.aa-complain /etc/apparmor.d/usr.sbin.httpd
D.aa-status /etc/apparmor.d/usr.sbin.httpd
AnswerB

aa-enforce switches the named AppArmor profile from complain to enforce mode, applying its deny rules. This satisfies the requirement to move the web server profile out of complain mode after testing, using the profile path as the argument.

Why this answer

The correct command to enforce an AppArmor profile that is currently in complain mode is `aa-enforce`. This command switches the profile from complain (log-only) to enforce (block violations) mode. The option `-r` in `apparmor_parser` reloads the profile but does not change its mode; `aa-complain` sets it to complain mode, and `aa-status` only displays status.

Exam trap

The trap here is that candidates confuse `apparmor_parser -r` (which reloads the profile but does not change its mode) with the mode-switching commands `aa-enforce` and `aa-complain`, leading them to choose option A incorrectly.

How to eliminate wrong answers

Option A is wrong because `apparmor_parser -r` reloads the profile from disk but does not change its operational mode; it would reload the profile in its current mode (complain), not enforce. Option C is wrong because `aa-complain` sets the profile to complain mode, which is the opposite of what the administrator wants. Option D is wrong because `aa-status` is used to display the status of loaded AppArmor profiles, not to change their enforcement mode.

117
Multi-Selecthard

A database server running on Linux is experiencing high load. The administrator runs 'strace -p <pid>' and sees many 'epoll_wait' and 'futex' calls. Which THREE of the following are possible causes of the high load? (Choose THREE.)

Select 3 answers
A.Disk I/O contention causing processes to wait.
B.A large number of concurrent connections.
C.CPU frequency scaling is set to powersave.
D.A memory leak in the database process.
E.Inefficient database queries causing high CPU usage.
AnswersA, B, E

Waiting on I/O increases load average as processes are in uninterruptible sleep.

Why this answer

'epoll_wait' indicates the process is waiting for I/O events, and 'futex' calls are used for synchronization. Disk I/O contention can cause the database process to block on these system calls, leading to high load as the kernel schedules other tasks while waiting for I/O to complete.

Exam trap

The trap here is that candidates may incorrectly associate 'futex' calls solely with memory issues or CPU scaling, rather than recognizing them as indicators of thread contention and I/O waiting under high concurrency.

118
MCQhard

An administrator is troubleshooting a Kubernetes deployment that is not receiving traffic. The deployment has one replica and the pod is running. The service is of type ClusterIP. Which command would help verify that the service endpoints are correctly associated with the pod?

A.kubectl describe pod
B.kubectl get pods -o wide
C.kubectl get svc
D.kubectl get endpoints
AnswerD

`kubectl get endpoints` lists each Service's backing pod IPs and ports, directly confirming whether the ClusterIP Service's selector actually matched the running pod. Since the stem's constraint is a ClusterIP Service with no external exposure, endpoint association is the failure point to verify, and this command exposes an empty or mismatched endpoint list immediately.

Why this answer

The 'kubectl get endpoints' command lists the Endpoints object for a service, showing the IP addresses and ports of the pods that back it. If the service selector does not match the pod labels, the endpoints list will be empty, immediately revealing the misconfiguration. This is the fastest way to verify service-to-pod association.

Exam trap

XK0-006 often tests whether candidates know that 'kubectl get svc' shows the selector but not the resolved endpoints, trapping those who assume the service output confirms pod association.

How to eliminate wrong answers

Option A is wrong because 'kubectl describe pod' shows pod details (status, events, containers) but does not show which service endpoints reference the pod. Option B is wrong because 'kubectl get pods -o wide' shows pod IPs and nodes but not the service-to-pod mapping. Option C is wrong because 'kubectl get svc' shows the service's ClusterIP, ports, and selector but not the resolved endpoints — it will not reveal whether the selector matches any pods.

119
Multi-Selectmedium

A Linux server becomes unresponsive, and the administrator suspects a process is consuming excessive CPU. The administrator needs to identify the offending process and then terminate it cleanly by PID. Which TWO commands should be used to accomplish these tasks? (Choose two.)

Select 2 answers
A.top
B.nohup ./service &
C.killall -9 bash
D.kill -SIGTERM <PID>
E.lsof -i :80
AnswersA, D

top displays a live, sorted view of processes with CPU and memory usage, defaulting to the highest CPU consumers at the top. It lets the administrator quickly identify the process name and its PID during an active incident. This directly satisfies the requirement to find the process driving CPU usage before acting on it.

Why this answer

Identifying a CPU hog requires a live process viewer that sorts by CPU, and top provides exactly that with PIDs. Once the PID is known, sending SIGTERM with kill requests an orderly shutdown so the process can release resources. Together these two steps find and cleanly stop the offending process, matching the scenario without resorting to a forceful, name-based kill.

Exam trap

The trap here is reaching for killall or kill -9, which act by name or forcefully, instead of identifying the PID and requesting a graceful SIGTERM.

120
MCQeasy

A company needs to verify that the Apache HTTP server is running and see its current status along with recent log entries. Which command should be used?

A.systemctl status httpd
B.service httpd status
C.journalctl -u httpd
D.systemctl list-units --type=service
AnswerA

systemctl status httpd queries the systemd unit for the Apache service, reporting whether it is active, its PID and recent journal log entries. This single command satisfies both requirements: confirming the server runs and showing current status with recent logs.

Why this answer

The `systemctl status httpd` command is correct because it provides a comprehensive view of the Apache HTTP server's current state (active/inactive), its process ID, memory usage, and the most recent log entries from the service's journal. This aligns with the question's requirement to both verify the service is running and see its status along with recent log entries, all in a single command output.

Exam trap

The trap here is that candidates often confuse `systemctl status` with `journalctl -u`, thinking both provide the same information, but `journalctl` lacks the live status and process details that `systemctl status` includes.

How to eliminate wrong answers

Option B is wrong because `service httpd status` is a legacy SysVinit command that only shows the service's running state (e.g., 'httpd is running') without displaying recent log entries or detailed status information. Option C is wrong because `journalctl -u httpd` shows only the log entries for the httpd unit but does not display the current running status or process details; it requires a separate command to verify if the service is active. Option D is wrong because `systemctl list-units --type=service` lists all loaded service units and their states but does not filter to httpd specifically, nor does it show recent log entries or detailed status for a single service.

121
MCQmedium

Based on the exhibit, which statement is true about the sshd service?

A.The service is masked.
B.The service is inactive.
C.The service has exited.
D.The service is not enabled to start at boot.
AnswerD

The exhibit shows the sshd unit is active (running) but not enabled, meaning systemd started it only for the current session. Without an enabled symlink in the multi-user.target.wants directory, the service will not start automatically after reboot.

Why this answer

The exhibit shows the output of `systemctl status sshd.service`. The line `Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset: enabled)` indicates the service is currently loaded but its enablement state is `disabled`, meaning it is not configured to start automatically at boot. The `Active: active (running)` line with a PID confirms the service is currently running, but the question asks about boot-time behavior, which is governed by the `disabled` state.

Therefore, option D is correct.

Exam trap

The trap here is that candidates see `Active: active (running)` and incorrectly assume the service is enabled to start at boot, but the actual evidence for boot behavior is the `disabled` keyword in the Loaded line, not the Active line.

How to eliminate wrong answers

Option A is wrong because the service is `loaded`, not `masked`; a masked service would show `masked` in the Loaded line and cannot be started directly. Option B is wrong because while the service is currently `inactive (dead)`, the question asks for a true statement about the service overall, and the key fact is its disabled boot status, not just its current runtime state. Option C is wrong because `exited` is a specific active state for services that run and terminate (e.g., oneshot type), but this service shows `inactive (dead)`, not `exited`; `exited` would appear as `Active: active (exited)`.

122
MCQeasy

A Linux administrator needs to scan all currently connected USB devices and display detailed information such as vendor ID, product ID, and device class. Which command should the administrator run?

A.lsusb
B.lshw -class usb
C.lspci
D.lsblk
AnswerA

lsusb enumerates USB buses and connected devices, showing vendor and product IDs, device class, and bus/device numbers. It directly answers the need to list currently connected USB devices with detailed identification information without requiring root privileges.

Why this answer

The lsusb command queries the USB subsystem and prints a line for each connected USB device, including vendor and product IDs, device class, and bus topology. It is the standard utility for quickly enumerating USB devices on a Linux system without needing elevated privileges.

Exam trap

The trap here is confusing PCI device listing with USB device listing; lspci shows internal buses, not external USB peripherals.

123
MCQhard

A Linux administrator is configuring an SSH server to use certificate-based authentication. The administrator has generated a CA key pair and wants to sign a user's public key. Which command should be used to sign the user's public key with the CA and produce a certificate?

A.ssh-keygen -s /etc/ssh/ca_key -I user_id -n username -V +52w user_key
B.ssh-keygen -s /etc/ssh/ca_key -I user_id -n username -V +52w user_key.pub
C.ssh-keygen -s /etc/ssh/ca_key -I user_id -n username -V +52w -f user_key
D.ssh-keygen -s /etc/ssh/ca_key -I user_id -n username -V +52w -O user_key.pub
AnswerB

This command uses ssh-keygen with the -s flag to specify the CA private key, -I to set the key ID, -n to define principals, -V for validity period, and the public key file to sign. It generates a certificate file named user_key-cert.pub. This is the correct syntax for signing a user's public key with a CA in OpenSSH certificate authentication.

Why this answer

To sign a user's public key with a CA in OpenSSH, the ssh-keygen command is used with the -s flag pointing to the CA private key, -I for the key identity, -n for principals, -V for validity, and the public key file as the final argument. This produces a certificate file that can be used for authentication. The other options misuse flags like -f, omit the .pub extension, or incorrectly use -O for the public key.

Exam trap

The trap here is confusing the -f flag, which specifies the output file for key generation, with the correct syntax for signing where the public key file is given as a positional argument.

124
MCQmedium

A system administrator is configuring a firewall using iptables. The requirement is to allow incoming SSH connections from the 192.168.1.0/24 network only. Which iptables rule should be added to the INPUT chain?

A.iptables -A INPUT -p tcp --dport 22 -d 192.168.1.0/24 -j ACCEPT
B.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j REJECT
C.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
D.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j LOG
E.iptables -A INPUT -p tcp --dport 22 -j ACCEPT
AnswerC

Appending to INPUT with `-p tcp --dport 22` matches SSH, while `-s 192.168.1.0/24` restricts the source to that subnet, satisfying the "192.168.1.0/24 only" constraint. The ACCEPT target permits matching packets; non-matching traffic falls through to later rules.

Why this answer

It uses the `-s` (source) flag to specify the 192.168.1.0/24 network, ensuring only incoming SSH traffic (TCP port 22) from that subnet is accepted. The `-A INPUT` appends this rule to the INPUT chain, which processes incoming packets destined for the local system. This matches the requirement exactly.

Exam trap

The trap here is confusing the `-s` (source) and `-d` (destination) flags, leading candidates to choose option A, which would allow SSH traffic destined for the 192.168.1.0/24 network instead of traffic originating from it.

How to eliminate wrong answers

Option A is wrong because it uses `-d` (destination) instead of `-s` (source), which would match packets destined for the 192.168.1.0/24 network rather than originating from it, allowing SSH from any source to that subnet. Option B is wrong because it uses `-j REJECT` instead of `-j ACCEPT`, which would block SSH from the 192.168.1.0/24 network, contrary to the requirement. Option D is wrong because it uses `-j LOG`, which only logs matching packets without accepting or rejecting them, so SSH connections would not be allowed.

Option E is wrong because it lacks a source restriction, allowing incoming SSH from any IP address, not just the 192.168.1.0/24 network.

125
MCQeasy

A Linux administrator writes a bash script that needs to exit immediately if any command fails. Which of the following should be included at the beginning of the script?

A.set -x
B.set -u
C.set -e
D.set -o pipefail
AnswerC

The set -e option instructs bash to terminate the script immediately when any command returns a non-zero exit status. Placing it at the top satisfies the requirement that the script halts on first failure rather than continuing with subsequent commands.

Why this answer

set -e (errexit) causes the shell to exit immediately if any command returns a non-zero exit status, which is exactly the requirement. It is the standard way to make bash scripts fail fast rather than continuing after an error.

Exam trap

XK0-006 often tests the difference between set -e (exit on error), set -u (error on unset variable), set -x (trace), and set -o pipefail (pipeline failure propagation) — candidates frequently pick pipefail thinking it alone causes script exit.

How to eliminate wrong answers

Option A is wrong because set -x enables command tracing (prints each command before execution) for debugging, not error handling. Option B is wrong because set -u treats unset variables as errors, which is useful for catching typos but does not exit on command failure. Option D is wrong because set -o pipefail only changes pipeline exit status to reflect the last failing command in the pipe — it does not by itself cause the script to exit on failure (it is often combined with set -e).

126
Multi-Selecteasy

A Linux administrator writes a Python script to parse configuration files. Which TWO practices improve security and portability? (Select TWO.)

Select 2 answers
A.Validate all external input before processing
B.Use absolute paths for all file operations
C.Use sudo within the script to run privileged commands
D.Use raw_input() instead of input() in Python 2
E.Use shebang #!/usr/bin/env python3
AnswersA, E

Validating external input before processing prevents injection attacks and malformed data from reaching the parser, satisfying the security half of the requirement. Configuration files are untrusted external sources, so bounds checking and type validation stop malicious payloads early. This addresses security directly, though portability depends on the companion practice.

Why this answer

Option A is correct because validating all external input before processing defends against injection attacks and malformed data, and it also makes the script behave predictably across environments where input formats may differ. Option E is correct because the shebang #!/usr/bin/env python3 locates the Python 3 interpreter via the PATH, which improves portability across systems where python3 is installed in different locations, and it explicitly targets Python 3 rather than the deprecated Python 2. Option B is not required for security or portability; absolute paths can actually reduce portability when directories differ between systems.

Option C is a poor practice because embedding sudo in a script escalates privileges and can expose credentials or allow unintended privileged execution. Option D is incorrect because raw_input() is Python 2-only and does not improve security or portability in modern Python 3 scripts.

Exam trap

Another common mistake is selecting Option B because absolute paths seem more reliable, but they actually harm portability when the script is moved to a different system with a different directory structure.

127
MCQmedium

A Linux administrator is writing a Bash script that must continue running even if an unset variable is referenced, but must still abort on a failed command. Currently the script has only `#!/bin/bash` at the top. Which line should be added to meet these requirements?

A.set -x
B.set -u
C.set -o pipefail
D.set -e
AnswerD

`set -e` causes the shell to exit immediately when a command returns a non-zero status, satisfying the requirement to abort on failed commands. Because `-u` is not included, referencing an unset variable does not terminate the script, so the script continues running. This combination precisely matches the administrator's stated requirements.

Why this answer

The requirement is to abort on a failed command while still tolerating references to unset variables. `set -e` provides the abort-on-error behavior, and because `-u` is not enabled, unset variables do not trigger termination. Enabling trace output or altering pipeline exit status does not produce the requested failure semantics, and enabling unset-variable errors would do the opposite of what is required.

Exam trap

The trap here is assuming that any `set` option that influences error handling will also make the script exit on a failed command.

128
MCQeasy

A system administrator wants to collect network performance statistics over time, including packet loss and latency, to diagnose intermittent connectivity issues. Which tool combines the functionality of ping and traceroute into a single continuous monitoring command?

A.mtr
B.tcpdump
C.ss
D.netstat
AnswerA

mtr continuously combines ping and traceroute by repeatedly probing each hop, refreshing latency and packet-loss statistics in real time. This satisfies the requirement for ongoing monitoring of intermittent connectivity, unlike one-shot ping or traceroute, which capture only a single snapshot and would miss transient faults.

Why this answer

mtr (My TraceRoute) continuously sends packets and displays real-time statistics including loss and latency for each hop, combining ping and traceroute.

129
MCQhard

A Linux administrator is writing a Bash script that processes a list of hostnames stored one per line in /etc/app/hosts.list. The script must read each line into the variable host and run a command against it, and the loop must not consume standard input from the terminal so that interactive commands inside the loop can still read from the keyboard. Which construct satisfies these requirements?

A.for host in $(cat /etc/app/hosts.list); do probe "$host"; done
B.while IFS= read -r host <&3; do probe "$host"; done 3< /etc/app/hosts.list
C.until read host; do probe "$host"; done < /etc/app/hosts.list
D.while read -r host; do probe "$host"; done < /etc/app/hosts.list
AnswerB

This opens the hostname file on file descriptor 3 and reads from it with read <&3, leaving file descriptor 0 untouched. Interactive commands inside probe can therefore still read from the keyboard, and IFS= with -r preserves leading whitespace and backslashes. It is the standard technique for keeping stdin available while looping over a file.

Why this answer

Redirecting the list to an alternate file descriptor and reading with read <&3 keeps standard input attached to the terminal, so interactive commands invoked in the loop body can still prompt the user. Using IFS= read -r also preserves hostname characters verbatim, which the whitespace-splitting for loop and the stdin-consuming while form cannot guarantee.

Exam trap

The trap here is assuming that any while-read loop over a file is equivalent, when the redirection target determines whether stdin remains usable by commands inside the loop.

130
MCQhard

After a kernel update, the system boots but the network interface enp0s3 is not detected. The administrator verifies that the kernel module for the NIC is built for the new kernel. Which of the following should be done to ensure the module loads correctly?

A.Load the module with modprobe
B.Rebuild the initramfs
C.Update the udev rules
D.Reinstall the kernel package
AnswerB

Rebuilding the initramfs bundles the NIC kernel module into the early-boot image, so it is available before the root filesystem mounts. Since the module exists for the new kernel but enp0s3 remains undetected, the stale initramfs lacks it; regenerating with dracut or update-initramfs satisfies the load-at-boot requirement.

Why this answer

After a kernel update, the initramfs (initial RAM filesystem) must be rebuilt to include the new kernel's modules. Even though the NIC module is built for the new kernel, the initramfs may still contain the old kernel's modules or lack the new module entirely, preventing it from being loaded during early boot. Running `dracut -f` (or `update-initramfs -u` on Debian-based systems) rebuilds the initramfs to match the current kernel, ensuring the NIC module is available at boot time.

Exam trap

The trap here is that candidates assume loading the module with modprobe (Option A) will fix the issue, but they overlook that the module must be available in the initramfs to be loaded during early boot before the root filesystem is accessible.

How to eliminate wrong answers

Option A is wrong because modprobe loads a module at runtime, but the issue occurs during boot before the root filesystem is mounted; the module must be present in the initramfs to be loaded early. Option C is wrong because udev rules handle device naming and permissions after the kernel has detected the hardware, but they do not cause the kernel to fail to detect the NIC; the problem is that the module is not loaded at all. Option D is wrong because reinstalling the kernel package would simply reapply the same kernel files; it does not rebuild the initramfs, which is the specific step needed to include the updated module.

131
MCQeasy

Which command displays the amount of disk space used and available on mounted filesystems in a human-readable format (e.g., GB, MB)?

A.df -h
B.lsblk
C.du -h
D.fdisk -l
AnswerA

The -h flag converts df's default 1K-block output into human-readable units such as GB and MB, while df itself reports used and available space per mounted filesystem. This satisfies the requirement for human-readable capacity figures.

Why this answer

The `df -h` command displays disk space usage for all mounted filesystems, with the `-h` flag converting raw block counts into human-readable units like GB or MB. This is the standard Linux utility for reporting filesystem capacity, usage, and available space, making it the correct choice for the question.

Exam trap

The trap here is that candidates confuse `du -h` (which shows directory-level usage) with `df -h` (which shows filesystem-level capacity), leading them to select option C when the question explicitly asks for disk space on mounted filesystems.

How to eliminate wrong answers

Option B is wrong because `lsblk` lists block devices (e.g., disks and partitions) and their attributes, but it does not show disk space usage or available capacity in human-readable format. Option C is wrong because `du -h` estimates file and directory space usage, not the total disk space used and available on mounted filesystems. Option D is wrong because `fdisk -l` displays partition table information for block devices, not current filesystem usage or available space.

132
Multi-Selecteasy

Which TWO commands display disk usage information for filesystems? (Select 2.)

Select 2 answers
A.ls
B.du
C.parted
D.df
E.fdisk
AnswersB, D

The du command reports disk usage of files and directories, recursively summing block consumption per path. It answers how much space files occupy, satisfying the stem's requirement to display disk usage information for filesystems, complementing df's filesystem-level view.

Why this answer

The `df` command (disk free) reports the amount of available and used disk space on all mounted filesystems, while `du` (disk usage) estimates file and directory space usage. Both commands are standard tools for displaying disk usage information for filesystems in Linux.

Exam trap

A common pitfall on the CompTIA Linux+ exam is confusing filesystem usage commands (df, du) with partition management tools (fdisk, parted) or file listing commands (ls).

133
MCQhard

A Linux server that hosts a critical database application has been experiencing occasional kernel panics. The administrator wants to ensure the system automatically reboots after a panic and logs the crash dump. Which sysctl parameter should be set?

A.kernel.panic_on_warn = 10
B.kernel.panic_on_oops = 10
C.kernel.panic_print = 10
D.kernel.panic = 10
AnswerD

Setting kernel.panic to 10 makes the kernel reboot automatically ten seconds after a panic, satisfying the automatic-reboot requirement. The crash dump itself is captured separately via kdump and the crashkernel reservation, so this parameter handles only the reboot delay, not logging.

Why this answer

Setting `kernel.panic = 10` instructs the Linux kernel to wait 10 seconds after a kernel panic before automatically rebooting. This ensures the system recovers without manual intervention, and combined with a configured crash dump mechanism (e.g., kdump), the crash dump is captured before the reboot.

Exam trap

CompTIA often tests the distinction between parameters that cause a panic (`panic_on_oops`, `panic_on_warn`) and the parameter that controls the reboot delay after a panic (`kernel.panic`), leading candidates to confuse the cause with the recovery action.

How to eliminate wrong answers

Option A is wrong because `kernel.panic_on_warn` controls whether the kernel panics on a warning (WARN()), not the reboot behavior after a panic; setting it to 10 would be invalid as it expects 0 or 1. Option B is wrong because `kernel.panic_on_oops` determines if the kernel panics on an oops (a non-fatal error), not the timeout before reboot; it also expects a boolean value (0 or 1), not 10. Option C is wrong because `kernel.panic_print` controls the verbosity of kernel messages printed during a panic, not the reboot action or delay.

134
MCQmedium

A Linux administrator notices that a server's root filesystem is filling up rapidly. After running `df -h`, the root filesystem shows 100% usage. However, when the administrator runs `du -sh /*` from the root directory, the total size is only about 40% of the filesystem. The administrator suspects that a deleted file is still being held open by a process. Which command should the administrator use to identify the process holding the deleted file?

A.ls -l /proc/*/fd | grep deleted
B.fuser -mv /
C.lsof +L1
D.find / -inum 0 -print
AnswerC

The `lsof +L1` command lists open files with a link count less than 1, which indicates files that have been unlinked (deleted) but are still held open by a process. This directly addresses the scenario where deleted files consume space. It will show the process name and PID, allowing the administrator to restart the process and free the space.

Why this answer

The `lsof +L1` command is specifically designed to list open files with a link count less than 1, meaning they have been deleted but are still held open by a process. This is the most direct and reliable way to identify the process causing the disk space discrepancy. Other commands may show open files but do not target deleted files specifically.

Exam trap

The trap here is assuming that `du` and `df` should always match, but they can differ when a process holds a deleted file open, and only `lsof +L1` directly reveals this condition.

135
MCQhard

A user cannot delete a file owned by another user on a shared filesystem. The file's permissions are 644, and the directory has permissions 777 with the sticky bit set. Which action would allow the user to delete the file?

A.Change the directory's group to include the user
B.Remove the sticky bit from the directory
C.Add write permission for others on the file
D.Change the file's group to match the user's group
AnswerB

The sticky bit on a directory restricts deletion to the file's owner, directory owner, or root. Removing it lets any user with write permission on the 777 directory unlink the file, satisfying the requirement to allow deletion of another user's file.

Why this answer

The directory has permissions 777, meaning all users have read, write, and execute permissions. Write permission on the directory is required to delete files. However, the sticky bit prevents users from deleting files they do not own, even if they have write permission on the directory.

Removing the sticky bit (option B) removes this restriction, allowing the user to delete the file.

Exam trap

Candidates may fixate on file permissions or ownership, but deletion is governed by directory permissions. Even with write access, the sticky bit blocks deletion of other users' files. Only removing the sticky bit (B) enables deletion.

How to eliminate wrong answers

Option A is wrong because changing the directory's group to include the user does not grant the user write permission on the directory (755 gives group read+execute only) and does not override the sticky bit restriction; the user would still need directory write and the sticky bit would still block deletion. Option C is wrong because adding write permission for others on the file (chmod o+w) does not affect deletion; deletion is controlled by directory permissions and the sticky bit, not file permissions. Option D is wrong because changing the file's group to match the user's group does not give the user write permission on the directory or bypass the sticky bit; the user still cannot delete the file unless they own it or have directory write and the sticky bit is removed.

136
MCQmedium

A system administrator needs to change the hostname of a Linux server running systemd to 'webserver01'. Which command will accomplish this?

A.hostnamectl set-hostname webserver01
B.hostname webserver01
C.sysctl kernel.hostname=webserver01
D.echo webserver01 > /etc/hosts
AnswerA

hostnamectl is the systemd utility for managing hostnames. The set-hostname subcommand sets the static hostname to the specified value. This change is persistent across reboots and updates /etc/hostname. It is the recommended method on modern Linux distributions using systemd.

Why this answer

On systemd-based systems, hostnamectl is the correct tool to set the hostname persistently. The set-hostname subcommand updates the static hostname and writes it to /etc/hostname, ensuring it survives reboots. Other methods like the hostname command or sysctl are temporary or incorrect for this purpose.

Exam trap

The trap here is using the hostname command, which only changes the hostname temporarily, rather than hostnamectl for a persistent change.

137
MCQmedium

A DevOps engineer needs to debug a bash script that unexpectedly fails when processing files. Which of the following should be added to the script to print each command before execution?

A.set -v
B.set -e
C.set -x
D.set -u
AnswerC

`set -x` enables the shell's trace mode, printing each command to stderr after expansion but before execution, prefixed with `+`. This satisfies the stem's requirement to display every command as it runs, letting the engineer follow the script's actual execution path and pinpoint where file processing fails.

Why this answer

set -x enables shell tracing, which prints each command (with expanded variables) to stderr prefixed by PS4 (usually '+') before execution. This is exactly what is needed to see what the script is doing as it processes files and where it fails.

Exam trap

XK0-006 often tests the distinction between set -x (trace executed commands) and set -v (echo input lines) — candidates pick -v thinking it shows execution, but only -x shows expanded commands as they run.

How to eliminate wrong answers

Option A is wrong because set -v prints shell input lines as they are read, not after expansion — it shows the raw script text rather than the actual commands being executed with their expanded values. Option B is wrong because set -e causes the script to exit immediately on any command returning non-zero, which is error handling, not debugging output. Option D is wrong because set -u treats unset variables as an error and exits, which helps catch typos but does not print commands before execution.

138
Multi-Selectmedium

A security administrator is reviewing SSH configuration. Which TWO settings enhance security by limiting authentication attempts and preventing password-based logins? (Choose two.)

Select 2 answers
A.MaxAuthTries 3
B.PasswordAuthentication no
C.Protocol 2
D.PermitRootLogin no
E.Port 2222
AnswersA, B

MaxAuthTries 3 caps the number of authentication attempts permitted per connection, so brute-force guessing is throttled before an attacker can try many passwords. This directly satisfies the stem's requirement to limit authentication attempts, working alongside a setting that disables password logins.

Why this answer

Option A, MaxAuthTries 3, is correct because this sshd_config directive limits the number of authentication attempts allowed per connection, so after three failed tries the server disconnects the client, directly reducing the risk of brute-force password guessing. Option B, PasswordAuthentication no, is correct because it disables password-based authentication entirely, forcing the use of stronger methods such as public key authentication and thereby preventing password logins. Option C, Protocol 2, is not correct here because although it enforces the more secure SSH-2 protocol, it does not limit authentication attempts or block password logins.

Option D, PermitRootLogin no, is not correct because it only prevents direct root logins and does not restrict authentication attempts or password authentication for other users. Option E, Port 2222, is not correct because changing the listening port is only a minor obscurity measure and does not limit authentication attempts or prevent password-based logins.

Exam trap

The trap is selecting plausible-looking hardening options (Protocol 2, PermitRootLogin no, Port 2222) that don't actually satisfy the two stated requirements — the exam tests precise reading of 'limiting authentication attempts' and 'preventing password-based logins.'

139
MCQmedium

A system administrator notices that a service named 'myapp' fails to start on a Linux server. The command 'systemctl status myapp' shows 'Active: failed (Result: exit-code)'. Which of the following is the BEST first step to diagnose the issue?

A.Run 'journalctl -u myapp.service' to inspect the service logs.
B.Run 'dmesg' to view kernel messages.
C.Run 'ps aux | grep myapp' to check if the process is running.
D.Edit the service file with 'systemctl edit myapp' and increase timeout values.
AnswerA

journalctl -u myapp.service retrieves the unit's captured stdout, stderr, and systemd messages, revealing the actual exit reason behind the failed result. This is the fastest way to obtain the underlying error before changing configuration or restarting.

Why this answer

The 'journalctl -u myapp.service' command retrieves the systemd journal logs specifically for the myapp service, which contain the service's stdout, stderr, and any error messages generated during its failed startup attempt. Since the service failed with an exit code, these logs are the most direct source of diagnostic information to identify why the process terminated abnormally.

Exam trap

The trap here is that candidates often jump to checking running processes with 'ps' or kernel messages with 'dmesg', but the correct first step is always to consult the service-specific logs via 'journalctl' because systemd captures the exact failure reason from the service's own output.

How to eliminate wrong answers

Option B is wrong because 'dmesg' displays kernel ring buffer messages, which are primarily for hardware, driver, and kernel-level issues, not for application-level service failures like a process exiting with a non-zero code. Option C is wrong because 'ps aux | grep myapp' checks for currently running processes, but since the service has already failed and exited, this command will not show the failed process or provide any information about why it failed. Option D is wrong because editing the service file to increase timeout values is a premature corrective action taken without first diagnosing the root cause; the failure is due to an exit code, not a timeout, so this would not address the actual problem.

140
MCQeasy

A Linux administrator wants to ensure a Bash script exits immediately if any command fails. Which directive should be included at the beginning of the script?

A.set -o pipefail
B.set -u
C.set -e
D.set -x
AnswerC

set -e makes the shell terminate immediately when any command returns a non-zero exit status, satisfying the requirement to stop on failure. Without it, Bash continues executing subsequent commands by default, masking the error and allowing the script to run on with corrupted state.

Why this answer

The `set -e` directive (equivalent to `set -o errexit`) causes the shell to exit immediately when any command returns a non-zero exit status, unless that command is part of a condition (if/while/until) or followed by `||`. This is the standard way to make a Bash script fail fast on the first error. Placing it near the top of the script ensures subsequent commands are not executed after a failure.

Exam trap

XK0-006 often tests the difference between `set -e`, `set -u`, `set -x`, and `set -o pipefail` — candidates confuse the fail-fast directive with pipefail or with debugging flags, especially because all four are commonly written together as `set -euxo pipefail`.

How to eliminate wrong answers

Option A is wrong because `set -o pipefail` only changes the exit status of a pipeline to reflect the last failing command in the pipe; it does not by itself cause the script to exit on failure. Option B is wrong because `set -u` treats unset variables as an error, which is about variable expansion, not command failure handling. Option D is wrong because `set -x` enables trace output of commands as they execute, which is a debugging aid, not an error-handling directive.

141
MCQhard

A developer wants to grant a user named 'john' read and write permissions to a file, but the file currently has an ACL that gives 'jane' full control. The administrator wants to add an ACL entry for 'john' without modifying existing entries. Which command accomplishes this?

A.setfacl -x u:john:rw file
B.setfacl -b u:john:rw file
C.chmod u+rw file; setfacl -m u:john:rw file
D.setfacl -m u:john:rw file
AnswerD

The -m flag modifies the ACL by adding or replacing only the specified entry, leaving jane's existing full-control entry untouched. Using u:john:rw grants john read and write, satisfying the stem's requirement to avoid altering existing entries.

Why this answer

The `setfacl -m` command modifies the ACL by adding or updating an entry for the specified user, leaving all other existing ACL entries intact. This directly satisfies the requirement to grant 'john' read and write permissions without altering 'jane's full control entry. The `-m` flag is specifically designed for modifying ACLs in this additive manner.

Exam trap

XK0-006 often tests the distinction between modifying and removing ACL entries, so candidates may confuse `-m` (modify/add) with `-x` (remove) or `-b` (remove all).

How to eliminate wrong answers

Option A is wrong because `setfacl -x` removes the specified ACL entry, which would delete permissions rather than add them. Option B is wrong because `setfacl -b` removes all ACL entries except the base permissions, which would eliminate 'jane's entry and not add one for 'john'. Option C is wrong because `chmod u+rw file` modifies the file's base permissions for the owner, not an ACL entry for 'john', and then `setfacl -m` would add the entry but the chmod step is unnecessary and could inadvertently change owner permissions.

142
MCQmedium

A Linux administrator needs to configure a firewall to allow incoming SSH connections only from the 192.168.1.0/24 subnet. The current iptables INPUT policy is ACCEPT. Which set of rules should be added?

A.iptables -A INPUT -p tcp --dport 22 -j DROP; iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
B.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT; iptables -A INPUT -p tcp --dport 22 -j DROP
C.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT; iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j DROP
D.iptables -I INPUT -p tcp --dport 22 -j DROP; iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
AnswerB

The first rule accepts TCP port 22 traffic sourced only from 192.168.1.0/24; the second drops all remaining SSH traffic from any other source. Since the INPUT policy is ACCEPT, the explicit DROP is required to deny non-subnet SSH connections.

Why this answer

Iptables processes rules in order, and the first matching rule determines the action. By placing the ACCEPT rule for the 192.168.1.0/24 subnet first, SSH traffic from that subnet is accepted. The subsequent DROP rule for port 22 then denies all other SSH traffic.

This ensures that only the specified subnet can connect, while the default ACCEPT policy on the INPUT chain would otherwise allow all traffic if no rule matched.

Exam trap

The trap here is that candidates often assume the order of rules doesn't matter or that a DROP rule can be placed before an ACCEPT rule for the same port, not realizing that iptables stops processing on the first match, which would drop all traffic including from the allowed subnet.

How to eliminate wrong answers

Option A is wrong because the DROP rule is added first, which would drop all incoming SSH traffic before the ACCEPT rule for 192.168.1.0/24 is evaluated, effectively blocking all SSH connections including from the allowed subnet. Option C is wrong because it only drops SSH traffic from the 10.0.0.0/8 subnet, leaving SSH traffic from all other sources (including the default ACCEPT policy) unrestricted, which does not restrict SSH to only 192.168.1.0/24. Option D is wrong because it inserts the DROP rule at the beginning of the INPUT chain using -I, which would drop all SSH traffic before the ACCEPT rule is evaluated, similar to option A, and also fails to restrict access to only the specified subnet.

143
MCQmedium

A configuration-management script must take a YAML inventory file and convert it into JSON so a downstream API can consume it, preserving all nested structure. Which command accomplishes this most directly?

A.awk -F': ' '{print $2}' inventory.yaml
B.grep -E '^[a-zA-Z]+:' inventory.yaml
C.yq -o=json '.' inventory.yaml
D.sed 's/:/=/g' inventory.yaml
AnswerC

The yq utility parses YAML natively and its -o=json output flag re-serializes the whole document as JSON, keeping nested maps and lists intact. The identity filter '.' selects the entire document, so this single command produces valid JSON that the API can consume without any intermediate text manipulation.

Why this answer

Structured conversion requires a tool that understands YAML syntax, and yq does exactly that by parsing the document and emitting JSON when given the -o=json flag. Text utilities such as sed, grep, and awk operate line by line and cannot reconstruct nested maps and sequences, so they inevitably corrupt the data the API expects.

Exam trap

The trap here is assuming a general-purpose text tool can convert between structured data formats when only a format-aware parser preserves nesting.

144
MCQeasy

After a security audit, it is recommended to disable SSH password authentication in favor of key-based authentication. Which configuration line should be set in /etc/ssh/sshd_config?

A.PasswordAuthentication yes
B.PubkeyAuthentication no
C.PasswordAuthentication no
D.ChallengeResponseAuthentication yes
AnswerC

Setting `PasswordAuthentication no` in sshd_config forces the daemon to reject all password-based logins, leaving public-key authentication as the only accepted method. This directly satisfies the audit requirement to disable SSH password authentication in favour of key-based authentication, and takes effect after restarting or reloading the SSH service.

Why this answer

Disabling password authentication forces SSH to use key-based authentication, which is more secure against brute-force attacks. Setting `PasswordAuthentication no` in `/etc/ssh/sshd_config` prevents SSH from prompting for a password, requiring a valid SSH key pair for authentication. This aligns with the security audit's recommendation to disable password authentication in favor of key-based authentication.

Exam trap

The trap here is that candidates often confuse `PasswordAuthentication` with `PubkeyAuthentication` or think that disabling password authentication requires setting it to `yes`, when in fact the directive must be set to `no` to disable it.

How to eliminate wrong answers

Option A is wrong because `PasswordAuthentication yes` enables password authentication, which is the opposite of the required change to disable it. Option B is wrong because `PubkeyAuthentication no` disables public key authentication, which would prevent key-based login entirely, contradicting the goal of using key-based authentication. Option D is wrong because `ChallengeResponseAuthentication yes` enables challenge-response authentication (often used with PAM), which can still allow password-based methods and does not directly disable password authentication.

145
MCQmedium

An administrator wants to capture network traffic on interface eth0, writing the output to a file for later analysis, without resolving hostnames. Which command accomplishes this?

A.tcpdump -i eth0 -r capture.pcap
B.tcpdump -i eth0 -w capture.pcap -n
C.tcpdump -i any -w capture.pcap
D.tcpdump -n -w eth0 capture.pcap
AnswerB

The `-i eth0` flag binds capture to the specified interface, `-w capture.pcap` writes raw packets to a file rather than printing them, and `-n` suppresses DNS and service-name resolution, satisfying the no-hostname constraint. Together these flags match every requirement in the stem.

Why this answer

tcpdump -i eth0 -w capture.pcap -n captures packets on interface eth0, writes them to capture.pcap for later analysis, and the -n flag prevents hostname resolution (shows IP addresses instead). This matches all three requirements: interface selection, file output, and no name resolution.

Exam trap

XK0-006 often tests the difference between -w (write to file) and -r (read from file), and the meaning of -n (no name resolution) — candidates frequently swap -w and -r or forget that -n is required to suppress hostname lookups.

How to eliminate wrong answers

Option A is wrong because -r reads from a capture file rather than writing to one, and it does not capture live traffic. Option C is wrong because -i any captures on all interfaces, not specifically eth0, and it omits the -n flag so hostnames would be resolved. Option D is wrong because the syntax is incorrect — -w expects a filename, not an interface, so 'tcpdump -n -w eth0 capture.pcap' would try to write to a file named eth0 and treat capture.pcap as a filter expression.

146
MCQhard

A user reports that an application fails with 'Permission denied' when writing to /srv/reports, even though the user is a member of the group that owns the directory. Running `ls -ld /srv/reports` returns 'drwxr-x--- 2 root reports 4096 Jun 10 09:14 /srv/reports'. The user's `id` output confirms membership in the reports group. Which action will allow the user to create files in that directory?

A.Run chmod u+w /srv/reports as root
B.Run chmod o+w /srv/reports as root
C.Run chown user:reports /srv/reports as root
D.Run chmod g+w /srv/reports as root
AnswerD

The permission string shows the group triad as r-x, meaning group members may read and traverse but not write. Because the user is confirmed in the owning group, granting the group write bit with chmod g+w directly resolves the denial without widening access to other users. This is the minimal, targeted change that matches the observed mode and group membership.

Why this answer

The mode string shows the group triad as r-x, so members of the reports group can list and enter the directory but cannot create entries. Since the user's group membership is verified, the correct fix is to add write permission to the group triad only. This grants exactly the needed capability while preserving the restrictive access for all other accounts.

Exam trap

The trap here is assuming that verified group membership is sufficient, when the group triad in the mode string must also carry the write bit for creation to succeed.

147
MCQmedium

A security team wants to restrict SSH access to only users in the 'sshusers' group. Which configuration line in /etc/ssh/sshd_config achieves this?

A.DenyGroups sshusers
B.AllowGroups sshusers
C.AllowUsers sshusers
D.Subsystem sftp /usr/lib/openssh/sftp-server
AnswerB

AllowGroups restricts authentication to members of the named group only, so listing sshusers blocks every account outside it. This directly enforces the stated constraint of limiting SSH access to that group, unlike AllowUsers, which names individual accounts rather than a group.

Why this answer

The `AllowGroups` directive in `/etc/ssh/sshd_config` restricts SSH login to users who are members of the specified group. By setting `AllowGroups sshusers`, only users in the 'sshusers' group are permitted to authenticate via SSH, meeting the security team's requirement.

Exam trap

The trap here is confusing `AllowGroups` with `AllowUsers`; candidates often select `AllowUsers sshusers` thinking it applies to a group, but it only matches a literal username, not group membership.

How to eliminate wrong answers

Option A is wrong because `DenyGroups sshusers` would block users in the 'sshusers' group from SSH access, which is the opposite of what is required. Option C is wrong because `AllowUsers sshusers` specifies a username, not a group; it would only allow a user literally named 'sshusers' to log in, not all members of the group. Option D is wrong because `Subsystem sftp /usr/lib/openssh/sftp-server` configures the SFTP subsystem and has no effect on restricting SSH access based on group membership.

148
MCQhard

Refer to the exhibit. A server administrator wants to ensure that when a user logs out, all processes started by that user are terminated. Which line should be added to the configuration?

A.IdleAction=kill
B.HandleLidSwitch=ignore
C.NAutoVTs=0
D.KillUserProcesses=yes
AnswerD

KillUserProcesses=yes in systemd-logind terminates every process belonging to a user's session when that session ends, satisfying the requirement that logout kills all user-started processes. It acts on the session scope rather than individual units, so background daemons and detached children are also reaped.

Why this answer

KillUserProcesses=yes is the correct directive in systemd's logind.conf that ensures all processes belonging to a user are terminated when the user logs out. This setting enforces session cleanup by sending SIGTERM to user processes, then SIGKILL if they don't exit. It directly addresses the requirement to terminate all user-started processes upon logout.

Exam trap

The trap here is confusing system idle actions with user logout actions, or misinterpreting directives that control virtual terminals or hardware events as relevant to process termination on logout.

How to eliminate wrong answers

Option A is wrong because IdleAction=kill defines what happens when the system is idle (e.g., after a period of inactivity), not on user logout; it triggers a system action like poweroff or halt, not user process termination. Option B is wrong because HandleLidSwitch=ignore controls the system's response to closing the laptop lid (e.g., ignore, suspend, poweroff), which is unrelated to user logout process cleanup. Option C is wrong because NAutoVTs=0 sets the number of virtual terminals (VTs) to allocate automatically; it has no effect on terminating user processes at logout.

149
MCQmedium

A technician notices a script fails to execute because the user does not have permission. The script currently has permissions 644. The technician needs to add execute permission for the owner only. Which command accomplishes this?

A.chmod a+x script.sh
B.chmod 755 script.sh
C.chmod u+x script.sh
D.chmod 744 script.sh
AnswerC

`chmod u+x script.sh` adds execute permission solely for the file's owner, satisfying the stem's requirement to grant execute to the owner only. The `u` symbol targets user/owner, `+x` adds execute, and it leaves group and other permissions at their existing 644 values unchanged.

Why this answer

The script currently has permissions 644, meaning the owner has read/write (6), group has read (4), and others have read (4). The requirement is to add execute permission for the owner only. The command `chmod u+x script.sh` adds (+) execute (x) permission to the user (u) — the owner — without affecting group or others.

This is the precise and minimal command to achieve the goal.

Exam trap

The trap here is that candidates often confuse 'add execute for owner only' with setting permissions to 755 or using `a+x`, not realizing that `u+x` is the precise symbolic method to add execute solely for the user class without affecting group or others.

How to eliminate wrong answers

Option A is wrong because `chmod a+x script.sh` adds execute permission for all (a) — user, group, and others — which grants more permissions than required. Option B is wrong because `chmod 755 script.sh` sets permissions to rwxr-xr-x, which gives execute to owner, group, and others, not just the owner. Option D is wrong because `chmod 744 script.sh` sets permissions to rwxr--r--, which gives execute to the owner but also changes the owner's read/write permissions to read/write/execute (which is acceptable) and leaves group and others unchanged; however, it is not the minimal command (it explicitly sets all bits rather than just adding execute) and could inadvertently change other permissions if the original permissions were different, making it less precise than `chmod u+x`.

150
Multi-Selecthard

A Linux administrator is troubleshooting intermittent application failures on a server. They suspect resource exhaustion. Which TWO commands can be used to check current system resource limits and usage for a running process? (Choose two.)

Select 2 answers
A.nice -n 10 <command>
B.cat /proc/<PID>/status
C.ulimit -a
D.cat /proc/<PID>/limits
E.systemctl status <service>
AnswersB, D

The /proc/<PID>/status file includes the process's current resource usage fields such as VmRSS, Threads, and open file descriptor counts, along with many state details. Comparing these values against the limits in /proc/<PID>/limits helps confirm whether the process is approaching a ceiling. It provides a live snapshot of the specific process, which is exactly what is needed when investigating intermittent exhaustion of an already-running application.

Why this answer

Diagnosing resource exhaustion in an already-running process requires inspecting that process's effective limits and current usage. The /proc/<PID>/limits file lists the soft and hard limits the process actually runs under, while /proc/<PID>/status reports live usage counters such as resident memory and thread counts. Together they let the administrator compare usage against limits without relying on the current shell's settings.

Exam trap

The trap here is using ulimit -a, which only reflects the current shell, instead of inspecting the running process's own /proc entries where the effective limits are recorded.

Page 1

Page 2 of 11

Page 3

All pages