Free CompTIA Linux+ (XK0-006) Practice Questions
Test your knowledge with 49 free exam-style questions
XK0-006 Exam Facts
Questions
65
Passing
720/1000
Duration
130 min
A Linux administrator needs to configure a new RAID 5 array using four 2TB hard drives for a database server. The system requires fault tolerance and optimal read performance. Which command should the administrator use to create the RAID 5 array?
Frequently Asked Questions
These 20 sample questions let you experience the exact format, difficulty, and question styles you'll encounter on exam day. Use them to identify knowledge gaps and decide if our full practice exam package is right for your preparation strategy.
Our questions mirror the actual exam format, difficulty level, and topic distribution. Each question includes detailed explanations to help you understand the concepts.
The full package includes 7 complete practice exams with 455+ unique questions, detailed explanations, progress tracking, and lifetime access.
Yes! Our XK0-006 practice questions are regularly updated to reflect the latest exam objectives and question formats. All questions align with the current 2026 exam blueprint.
Sample XK0-006 Practice Questions
Browse all 49 free CompTIA Linux+ practice questions below.
A Linux administrator needs to configure a new RAID 5 array using four 2TB hard drives for a database server. The system requires fault tolerance and optimal read performance. Which command should the administrator use to create the RAID 5 array?
- mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- lvcreate --raid5 --stripes 4 -L 6TB -n raid5_lv vg0
- mkraid --level=5 /dev/md0 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- mdadm --create /dev/md0 --level=1 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
A system administrator notices that the system clock is consistently drifting and causing authentication issues with Kerberos. The server needs accurate time synchronization with multiple time sources for redundancy. Which command should be used to configure NTP time synchronization on a systemd-based Linux distribution?
- timedatectl set-ntp true
- chronyd --enable
- ntpdate -s pool.ntp.org
- hwclock --systohc
A Linux administrator needs to troubleshoot high I/O wait times on a database server. The system is experiencing slow query performance. Which commands should be used to identify the disk I/O bottleneck? (Select TWO)
- netstat -i
- iotop -o
- iostat -xz 1
- free -h
- lsof /var
A company needs to implement a centralized logging solution for compliance requirements. All Linux servers must forward system logs to a central log server. The solution must use encrypted transport and support structured logging. Which configuration should be implemented?
- Use syslog-ng with UDP forwarding to the log server on port 514
- Configure rsyslog with TLS encryption using @@logserver:514 and enable structured logging with templates
- Set up logrotate to copy logs to NFS share mounted on the central server
- Configure journald with ForwardToSyslog=yes and use netcat for log forwarding
An administrator is configuring a Linux server to boot from a specific kernel version due to hardware compatibility issues. The default GRUB timeout is too short for selection. Which file should be edited to set the kernel and increase the boot menu timeout to 10 seconds?
- /etc/default/grub - Set GRUB_DEFAULT and GRUB_TIMEOUT=10, then run update-grub or grub2-mkconfig
- /etc/grub.conf - Modify the timeout parameter and default kernel line
- /boot/grub/grub.cfg - Directly edit the timeout and default kernel entry
- /boot/grub2/grubenv - Use grub2-editenv to set timeout and default kernel
A DevOps team needs to configure SELinux to allow a custom application to bind to port 8443 for HTTPS traffic. The application is being blocked by SELinux. What is the correct approach to resolve this?
- semanage port -a -t http_port_t -p tcp 8443
- Edit /etc/selinux/config and set SELINUX=permissive
- setenforce 0 to disable SELinux
- chcon -t http_port_t /path/to/application
A Linux administrator needs to monitor real-time CPU usage per core and identify which processes are consuming the most CPU resources on a 16-core server. Which command provides this information most effectively?
- ps aux | grep CPU
- vmstat 1
- sar -u 1
- htop
A system administrator needs to configure a Linux server to automatically mount an NFS share at boot time with specific options: read-write access, version 4, and automatic retry on failure. Which /etc/fstab entry is correct?
- nfsserver:/share /mnt/data auto rw,noauto 0 0
- nfsserver:/share /mnt/data nfs defaults,vers=4 0 0
- //nfsserver/share /mnt/data cifs rw,vers=4.0 0 0
- nfsserver:/share /mnt/data nfs4 rw,_netdev,x-systemd.automount 0 0
An organization's security policy requires that all user passwords must be at least 12 characters long, contain mixed case, numbers, and special characters. Failed login attempts must be limited to 3 before account lockout. Which configuration files need to be modified? (Select TWO)
- /etc/pam.d/common-auth or /etc/pam.d/system-auth - Configure pam_faillock for account lockout
- /etc/security/pwquality.conf - Configure password complexity requirements
- /etc/shadow - Manually edit password hashes and lock accounts
- /etc/ssh/sshd_config - Set PasswordAuthentication and MaxAuthTries
- /etc/login.defs - Set PASS_MAX_DAYS and PASS_MIN_LEN
A developer reports that a systemd service fails to start after a server reboot, but works when started manually with 'systemctl start appservice'. The service requires network connectivity to a database server. What is the most likely cause and solution?
- SELinux blocking - Run 'setenforce 0' to disable SELinux
- Permission issue - Change service file ownership to root and set chmod 755
- Missing network dependency - Add 'After=network-online.target' and 'Wants=network-online.target' to the service unit file
- Service is disabled - Run 'systemctl enable appservice' to enable automatic startup
A Linux administrator needs to create a compressed archive of /var/log directory that preserves file permissions, ownership, and timestamps for backup purposes. The archive should use maximum compression. Which command achieves this?
- zip -r /backup/logs.zip /var/log
- gzip -r /var/log > /backup/logs.gz
- tar -czpf /backup/logs.tar.gz /var/log
- cp -rp /var/log /backup/logs && compress /backup/logs
A production server is experiencing random application crashes. The administrator needs to analyze core dumps to identify the cause. Which steps are required to enable and configure core dump generation? (Select TWO)
- Configure kernel.core_pattern in /etc/sysctl.conf to specify core dump location and naming
- Modify /etc/systemd/coredump.conf to enable core dumping
- Install gdb and run 'gdb --core' on the application
- Recompile the application with -g debug flag
- Set 'ulimit -c unlimited' or configure in /etc/security/limits.conf with '* soft core unlimited'
An administrator needs to configure a Linux firewall to allow incoming SSH connections only from the 192.168.1.0/24 network and drop all other incoming SSH attempts. The firewall should use firewalld. Which commands accomplish this?
- iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT && iptables -A INPUT -p tcp --dport 22 -j DROP
- firewall-cmd --add-service=ssh --zone=trusted --permanent
- firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept' && firewall-cmd --permanent --remove-service=ssh && firewall-cmd --reload
- firewall-cmd --permanent --add-service=ssh --add-source=192.168.1.0/24
A server's root filesystem is showing 100% usage, but when calculating directory sizes with 'du -sh /*', the total doesn't add up to the reported usage by 'df -h'. What is the most likely cause and solution?
- Filesystem corruption - Run 'fsck -f /dev/sda1' to repair the filesystem
- Deleted files still held open by running processes - Use 'lsof +L1' to find processes with deleted files, then restart or kill them
- Hidden files not counted - Use 'du -sh /.*' to include hidden files in the calculation
- Reserved blocks for root - Use 'tune2fs -m 0 /dev/sda1' to eliminate reserved space
A company is deploying a high-availability web application using multiple Linux servers behind a load balancer. The application requires shared session storage. Which solution provides the best performance for session management?
- Local filesystem on each web server with sticky sessions configured on the load balancer
- MySQL database with session data stored in a dedicated sessions table
- NFS share mounted on all web servers with session files stored in the shared directory
- Redis or Memcached running on a separate server with application configured to store sessions in the cache
An administrator needs to grant a user the ability to restart the Apache web server service without granting full sudo privileges. Which configuration in /etc/sudoers accomplishes this securely?
- webadmin ALL=(ALL) /usr/sbin/service httpd restart
- webadmin ALL=(ALL) NOPASSWD: ALL
- webadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl *
- webadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart httpd, /usr/bin/systemctl status httpd
A Linux administrator needs to troubleshoot a system that is experiencing high I/O wait times. The system has multiple processes waiting for disk operations to complete. Which combination of commands should the administrator use to identify the processes causing the high I/O wait? (Select TWO)
- netstat -tulpn
- vmstat 1
- uptime
- free -h
- iotop -o
A company requires automated configuration management for 50 Linux servers. The solution must be agentless, use SSH for communication, and support declarative configuration. Which tool best meets these requirements?
- Chef
- Puppet
- SaltStack
- Ansible
A security audit reveals that several user accounts have not changed their passwords in over a year. The administrator needs to enforce a maximum password age of 90 days for all users. Which command accomplishes this system-wide?
- Edit /etc/login.defs and set PASS_MAX_DAYS 90
- chmod 90 /etc/shadow
- passwd --maxdays=90 --all
- usermod -e 90 --all-users
An administrator needs to configure a Linux system to automatically mount an NFS share from 192.168.1.100:/data/shared to /mnt/nfs at boot time with read-only permissions. Which /etc/fstab entry correctly implements this?
- 192.168.1.100 /mnt/nfs nfs ro,_netdev 0 1
- 192.168.1.100:/data/shared /mnt/nfs nfs ro,defaults 0 0
- nfs://192.168.1.100/data/shared /mnt/nfs auto ro 0 0
- /data/shared /mnt/nfs nfs4 ro,noauto 0 0
A developer needs to run a Python script that requires elevated privileges but should not require entering the sudo password every time. The script is located at /opt/scripts/backup.py and should only be executable by the 'developers' group with sudo privileges. Which sudoers configuration is most secure?
- developers ALL=(root) /opt/scripts/backup.py
- %developers ALL=(ALL) NOPASSWD: ALL
- %developers ALL=(ALL) NOPASSWD: /opt/scripts/*
- %developers ALL=(ALL) NOPASSWD: /usr/bin/python3 /opt/scripts/backup.py
A system administrator notices that the system journal is consuming excessive disk space. The administrator needs to configure systemd-journald to limit journal size to 500MB and remove entries older than 30 days. Which configuration changes should be made to /etc/systemd/journald.conf? (Select TWO)
- Storage=500M
- RuntimeMaxUse=30d
- MaxFileSize=500M
- SystemMaxUse=500M
- MaxRetentionSec=30d
A Linux server is experiencing network connectivity issues. The administrator can ping the local gateway (192.168.1.1) but cannot reach external hosts like 8.8.8.8. Which command will help identify where packets are being dropped in the network path?
- traceroute 8.8.8.8
- ifconfig eth0
- route -n
- arp -a
An administrator needs to create a bash script that processes log files and sends email alerts when ERROR entries exceed 10 occurrences. Which script correctly implements this logic?
- #!/bin/bash\ngrep ERROR /var/log/app.log > 10 && mail admin@example.com\n
- #!/bin/bash\nerror_count=$(grep -c 'ERROR' /var/log/app.log)\nif [ $error_count -gt 10 ]; then\n echo 'Errors exceeded threshold' | mail -s 'Alert' admin@example.com\nfi
- #!/bin/bash\nerror_count=$(cat /var/log/app.log | wc -l)\nif [ $error_count > 10 ]; then\n mail -s 'Alert' admin@example.com\nfi
- #!/bin/bash\nif [ $(grep 'ERROR' /var/log/app.log) -eq 10 ]; then\n sendmail admin@example.com 'Alert'\nfi
A company uses Git for version control and needs to ensure that sensitive configuration files containing API keys are never committed to the repository. Which file should the administrator configure to prevent these files from being tracked?
- .gitconfig
- .gitignore
- .gitattributes
- .gitkeep
A Linux administrator needs to secure SSH access by disabling password authentication and allowing only key-based authentication. Which changes should be made to /etc/ssh/sshd_config? (Select TWO)
- AuthorizedKeysFile .ssh/authorized_keys
- ChallengeResponseAuthentication yes
- PubkeyAuthentication yes
- PermitRootLogin no
- PasswordAuthentication no
A system is running out of inodes on the /var partition despite having sufficient free disk space. Which command should the administrator use to identify which directories are consuming the most inodes?
- ls -laR /var | wc -l
- du -h /var | sort -rh
- df -i /var
- find /var -xdev -type f | cut -d / -f 2 | sort | uniq -c | sort -rn
An administrator needs to schedule a Python script to run every day at 2:30 AM using systemd timers instead of cron. Which combination of systemd units is required? (Select TWO)
- A .path unit monitoring /etc/cron.daily/
- A .timer unit with OnCalendar=*-*-* 02:30:00
- A .mount unit for the script location
- A .service unit defining ExecStart=/usr/bin/python3 /path/to/script.py
- A .target unit to group related timers
A security team requires all outbound HTTP traffic (port 80) to be blocked on a Linux server while allowing HTTPS (port 443). The server uses firewalld. Which command accomplishes this?
- firewall-cmd --zone=public --add-port=443/tcp --remove-port=80/tcp
- iptables -A OUTPUT -p tcp --dport 80 -j DROP
- firewall-cmd --add-rich-rule='rule family=ipv4 port port=80 protocol=tcp reject'
- firewall-cmd --permanent --remove-service=http && firewall-cmd --reload
An administrator is troubleshooting a service that fails to start. The command 'systemctl status myapp.service' shows 'Active: failed (Result: exit-code)'. Which command provides the most detailed error information about why the service failed?
- dmesg | grep myapp
- systemctl cat myapp.service
- systemctl list-units --failed
- journalctl -u myapp.service -n 50 --no-pager
A company is implementing an Ansible playbook to deploy web servers across multiple Linux distributions (Ubuntu and CentOS). The playbook needs to install the Apache web server using the appropriate package manager for each distribution. Which Ansible module should be used to handle this cross-platform requirement?
- The package module with appropriate state and name parameters, letting Ansible detect the package manager
- Separate tasks using apt module for Ubuntu and yum module for CentOS with when conditionals
- package module with name: httpd for CentOS and apache2 for Ubuntu using conditionals
- shell module with conditional commands: apt-get install apache2 || yum install httpd
A Linux administrator needs to extend an existing logical volume /dev/vg01/lv_data from 50GB to 100GB. The volume group vg01 has sufficient free space. Which commands should be executed in the correct order? (Select TWO)
- vgextend vg01 /dev/sdb1
- resize2fs /dev/vg01/lv_data (for ext4) or xfs_growfs /mnt/mountpoint (for XFS)
- mkfs.ext4 /dev/vg01/lv_data
- fdisk /dev/vg01/lv_data
- lvextend -L 100G /dev/vg01/lv_data
A system administrator receives alerts that the root filesystem is 95% full. After investigation, they find that deleted log files are still consuming space because processes have open file handles. Which command identifies processes with open file handles to deleted files?
- find / -name '*deleted*'
- ps aux | grep deleted
- du -sh /* | grep deleted
- lsof | grep deleted
An administrator needs to configure GRUB2 to boot with specific kernel parameters (e.g., 'quiet splash') permanently. Which file should be edited, and which command must be run afterward?
- Edit /boot/grub2/grub.cfg directly and save the file
- Edit /etc/default/grub, modify GRUB_CMDLINE_LINUX, then run grub2-mkconfig -o /boot/grub2/grub.cfg (or update-grub on Debian/Ubuntu)
- Edit /boot/grub/menu.lst and reboot the system
- Edit /etc/grub.conf and run grub-install /dev/sda
A company requires that all users in the 'developers' group have read and write access to files created in /opt/projects/, with files automatically inheriting group ownership. Which combination of settings achieves this? (Select TWO)
- chown developers:developers /opt/projects/
- chmod u+s /opt/projects/
- chmod g+s /opt/projects/
- chgrp developers /opt/projects/ && chmod 2775 /opt/projects/
- chmod 777 /opt/projects/
A Linux server needs to synchronize time with NTP servers to maintain accurate system time. The administrator wants to use chronyd instead of ntpd. Which command verifies that chronyd is synchronized with NTP servers?
- ntpq -p
- systemctl status chronyd
- timedatectl status
- chronyc tracking
An administrator is configuring a RAID 5 array with three disks (/dev/sdb, /dev/sdc, /dev/sdd) using mdadm. Which command correctly creates the RAID 5 array?
- mdadm --create /dev/md0 --level=5 --raid-devices=2 /dev/sdb /dev/sdc
- mdadm --assemble /dev/md0 /dev/sdb /dev/sdc /dev/sdd
- mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
- mdadm --create /dev/md0 --level=1 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
A security policy requires that failed SSH login attempts be logged and monitored. Which log file on most Linux distributions contains authentication attempts including failed SSH logins?
- /var/log/ssh.log
- /var/log/syslog
- /var/log/messages
- /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL/CentOS)
An administrator needs to find all files larger than 100MB in the /home directory to free up disk space. Which command accomplishes this task?
- ls -lh /home | awk '$5 > 100M'
- locate -s 100M /home
- find /home -type f -size +100M
- du -h /home | grep 100M
A Docker container needs to persist data beyond container lifecycle. The administrator wants to mount a host directory /data/app into the container at /app/data. Which docker run option accomplishes this?
- --link /data/app:/app/data
- -d /data/app:/app/data
- -v /data/app:/app/data or --mount type=bind,source=/data/app,target=/app/data
- --volume-from /data/app:/app/data
A user reports that they cannot execute a shell script even though they are the owner. The file permissions show -rw-r--r--. What is the issue and how can it be fixed?
- The file lacks execute permission. Fix with: chmod +x scriptname.sh
- The shebang line is missing. Fix with: Add #!/bin/bash to first line
- The file has immutable attribute. Fix with: chattr -i scriptname.sh
- The file ownership is incorrect. Fix with: chown user:user scriptname.sh
An administrator needs to change the default systemd target from graphical.target to multi-user.target to boot into console mode. Which command accomplishes this persistently?
- Edit /etc/inittab and change runlevel to 3
- systemctl isolate multi-user.target
- systemctl enable multi-user.target
- systemctl set-default multi-user.target
A company uses Ansible to manage server configuration. The administrator needs to run an Ansible playbook in 'check mode' to preview changes without actually applying them. Which command accomplishes this?
- ansible-playbook playbook.yml --check
- ansible-playbook playbook.yml --simulate
- ansible-playbook playbook.yml --test
- ansible-playbook playbook.yml --dry-run
A Linux administrator needs to investigate why the system load average is consistently high. The command 'uptime' shows load averages of 8.50, 7.25, 6.80 on a 4-core system. Which tools should the administrator use to identify the source of the load? (Select TWO)
- top or htop
- ping localhost
- df -h
- iostat -x 1
- free -m
An organization needs to implement centralized user authentication for Linux servers using LDAP. The administrator configures /etc/nsswitch.conf to include LDAP. Which line correctly configures passwd, group, and shadow lookups to check local files first, then LDAP?
- passwd: files ldap\ngroup: files ldap\nshadow: files ldap
- passwd: ldap files\ngroup: ldap files\nshadow: ldap files
- auth: files ldap\naccount: files ldap
- passwd: compat ldap\ngroup: compat ldap\nshadow: compat ldap
A bash script needs to check if a file exists before processing it. Which conditional statement correctly implements this check?
- if [ -f /path/to/file ]; then\n echo 'File exists'\nfi
- if [ -d /path/to/file ]; then\n echo 'File exists'\nfi
- if [ /path/to/file ]; then\n echo 'File exists'\nfi
- if [ -e /path/to/file ]; then\n echo 'File exists'\nfi
A Linux administrator needs to configure a system to use a static IP address 192.168.10.50/24 with gateway 192.168.10.1 and DNS servers 8.8.8.8 and 8.8.4.4 using NetworkManager. Which command accomplishes this for interface eth0?
- ifconfig eth0 192.168.10.50 netmask 255.255.255.0 && route add default gw 192.168.10.1
- ip addr add 192.168.10.50/24 dev eth0 && ip route add default via 192.168.10.1
- nmcli con mod eth0 ipv4.addresses 192.168.10.50/24 ipv4.gateway 192.168.10.1 ipv4.dns '8.8.8.8 8.8.4.4' ipv4.method manual
- nmcli con add type ethernet ifname eth0 ip4 192.168.10.50/24 gw4 192.168.10.1
A system administrator needs to configure a RAID 5 array using four 2TB drives. Which mdadm command creates the array with the correct configuration?
- mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- mdadm --create /dev/md0 --level=1 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- mdadm --create /dev/md0 --level=0 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
An organization requires that all sudo commands are logged to a remote syslog server at 192.168.100.50 for compliance auditing. Which configuration accomplishes this?
- Install sudo-ldap package and configure LDAP server at 192.168.100.50
- Set 'SYSLOG_SERVER=192.168.100.50' in /etc/environment
- Add 'local2.* @@192.168.100.50:514' to /etc/rsyslog.conf and configure sudo to log to local2 facility
- Configure /etc/sudoers with 'Defaults log_host=192.168.100.50'