Linux+
System Administration, Networking, Security, Scripting & Containers for Linux
Exam: XK0-005
40 + 4 Questions & Verified Answers
CompTIA Linux+ — 40 + 4 Exam Questions
Covers all exam domains: System Management, Security, Scripting, Containers & Automation, and
Troubleshooting.
Q01. What is the Linux filesystem hierarchy and what does the root '/' directory represent?
A. The home directory of the root user
B. A partition mounted on /root
C. The root user's personal files
D. The top-level directory of the entire Linux filesystem from which all other directories branch
— containing essential subdirectories like /etc (configs), /var (variable data), /usr (user
programs), /home (user homes), /bin (essential binaries)
Answer: D. Top-level directory of the entire Linux filesystem — contains /etc, /var, /usr,
/home, /bin and all other directories
FHS (Filesystem Hierarchy Standard): defines the directory structure for Linux.
Key directories: /etc (system configuration files), /var (logs, spool, mail — variable data), /usr
(installed programs and libraries), /tmp (temporary files), /proc (virtual filesystem of kernel/process
data).
Root user home: /root (different from / — the root directory of the entire filesystem).
Mounting: attach other filesystems to directories — mount a disk to /mnt, /media, or any directory.
Q02. What is the difference between absolute and relative paths in Linux?
A. Absolute paths use ~ for home; relative paths use /
B. Absolute path starts from the root directory (/home/user/docs/file.txt); relative path starts
from the current directory (docs/file.txt or ../sibling/file.txt) — no leading /
C. Relative paths are faster than absolute paths
D. They are identical in Linux
Answer: B. Absolute = starts from / (full path); relative = starts from current directory (no
leading /)
, Absolute: /etc/nginx/nginx.conf — always the same regardless of where you are in the filesystem.
Relative: ../config/nginx.conf — relative to current working directory. Changes meaning as you
navigate.
Special symbols: . (current directory), .. (parent directory), ~ (home directory of current user).
pwd: print working directory — shows your current absolute path.
Q03. What does the 'chmod' command do and how do numeric permissions work?
A. Changes file ownership to a different user
B. Displays file permission details
C. A command to move files between directories
D. Changes file permissions — numeric mode uses octal: read=4, write=2, execute=1 —
combined per user class (owner/group/other): 755 = rwxr-xr-x, 644 = rw-r--r--
Answer: D. Changes file permissions — numeric octal: read=4, write=2, execute=1 —
combined per class: 755=rwxr-xr-x, 644=rw-r--r--
Octal calculation: 7 = 4+2+1 (rwx), 5 = 4+1 (r-x), 4 = 4 (r--).
755: owner (rwx), group (r-x), other (r-x) — standard for executables and directories.
644: owner (rw-), group (r--), other (r--) — standard for regular files.
Symbolic mode: chmod u+x file (add execute for owner), chmod go-w file (remove write for group
and other).
Q04. What is the purpose of the 'sudo' command?
A. Switch to the superuser account permanently
B. Delete system files safely
C. Run a command as the superuser (root) or another user, with the permission being
controlled by the /etc/sudoers file — providing privilege escalation with audit logging
D. Create a new user account
Answer: C. Run command as root or another user — permissions controlled by /etc/sudoers,
with audit logging
sudo logs every command to syslog/journald — full audit trail of privileged actions.
sudoers file (/etc/sudoers): configure which users can run which commands — edit with 'visudo'
(validates syntax).
sudo -l: list what sudo commands the current user is allowed to run.
su vs sudo: su switches to root shell (no logging per command); sudo runs one command as root
(logged).
Q05. What does the 'grep' command do?
A. Delete lines matching a pattern from a file
B. Display the count of files in a directory
C. Search for patterns in files or input — outputting lines that match the regular expression
pattern
D. Replace text in files globally
Answer: C. Search for patterns in files or input — outputs matching lines
Basic usage: grep 'error' /var/log/syslog — show all lines containing 'error'.
, Common flags: -i (case-insensitive), -r (recursive search in directory), -n (show line numbers), -v
(invert — show non-matching lines), -l (list only filenames), -E (extended regex).
Pipe usage: tail -f /var/log/auth.log | grep 'Failed' — live stream of failed auth attempts.
grep vs egrep vs fgrep: egrep = grep -E (extended regex), fgrep = grep -F (fixed string, no regex).
Q06. What is a Linux daemon and how is it managed with systemd?
A. A graphical user interface process
B. A temporary process that runs once and exits
C. A user-logged-in interactive session
D. A background process that runs continuously providing system services — managed with
systemctl: start, stop, restart, enable (start at boot), disable, status, and journalctl for logs
Answer: D. Background service process — managed with systemctl
(start/stop/enable/disable/status) and journalctl for logs
systemctl start nginx: start the nginx web server.
systemctl enable nginx: configure nginx to start automatically at boot.
systemctl status nginx: view running status, recent log entries, and PID.
journalctl -u nginx: view all logs for the nginx service.
systemd unit files: /etc/systemd/system/ — define how services start, their dependencies, and
restart behavior.
Q07. What is the purpose of SSH and how do you generate SSH keys?
A. A file transfer protocol only
B. A web server protocol
C. A database connection protocol
D. Secure Shell — an encrypted protocol for remote command-line access; generate keys with
'ssh-keygen -t ed25519 -C ' — private key stays on client, public key goes
to ~/.ssh/authorized_keys on the server
Answer: D. Encrypted remote command-line access — generate keys with ssh-keygen,
private key on client, public key on server
SSH key types: ed25519 (recommended, modern), RSA 4096, ECDSA. Avoid RSA 1024.
Copy public key: ssh-copy-id user@server — copies public key to server's authorized_keys
automatically.
SSH config (~/.ssh/config): define Host aliases, IdentityFile, User, Port — simplify connections.
Disable password auth: in /etc/ssh/sshd_config set PasswordAuthentication no — keys only.
Q08. What is the 'ps' command and how does it differ from 'top'?
A. ps lists files; top lists processes
B. ps creates processes; top kills processes
C. ps displays a static snapshot of current processes; top provides a real-time, dynamically-
updating view of processes sorted by CPU/memory usage
D. They are identical commands
Answer: C. ps = static snapshot of processes; top = real-time dynamically updating process
view
ps aux: all processes, all users, with detailed columns (USER, PID, %CPU, %MEM, COMMAND).