Scroll down to see your responses and detailed results
Prepare for the CompTIA Linux+ XK0-005 exam with our free practice test. Randomly generated and customizable, this test allows you to choose the number of questions.
The command 'at' can be used to schedule a job for a specific time without the requirement for that to recur at regular intervals.
The statement is accurate
The statement is inaccurate
The 'at' command is indeed used for one-time task scheduling on Linux systems. It does not provide a way to schedule recurring jobs; that functionality is handled by 'cron'. Therefore, 'at' is suitable for tasks that need to be run once at a certain point in time in the future.
A system administrator notices that a Linux server is performing poorly and, upon investigation, discovers that the I/O wait time is consistently high, even under normal workload. The server hosts a database service that is critical for the company's operations. Which of the following actions should the administrator take FIRST to address the high I/O wait issue?
Upgrade to faster storage hardware, such as NVMe drives
Analyze disk I/O activity using utilities like iotop or iostat
Add additional RAM to the server to improve overall performance
Check for network issues that may be affecting storage access
The correct answer is 'Analyze disk I/O activity using utilities like iotop or iostat'. High I/O wait indicates that the CPU is spending significant time waiting for I/O operations to complete. Investigating disk I/O activity can help identify a potential bottleneck or excessive read/write operations that may be causing the high wait times. Upgrading the storage hardware may eventually be necessary, but initially, the administrator needs to pinpoint the problem. Adding RAM may reduce I/O by increasing the buffer cache, but it does not directly address I/O problems. Checking for network issues is unrelated to local I/O wait and does not help in this instance.
Which of the following commands is used to check and repair filesystem errors on a Linux system?
fdisk
mkfs
chmod
chown
dd
fsck
The fsck
command is used to check and repair Linux filesystem errors. This command can be applied to filesystems that are currently unmounted or in an unclean state to inspect them or rectify inconsistencies that are found during the scan. It is often used during system boot time or maintenance mode. Other tools like mkfs
are used to create filesystems, not check or repair them, and dd
is a command used for copying and converting data.
A system administrator wants to generate a report of disk usage by each user in the home directory and store the output to a file called disk_report.txt, overwriting any existing data in the file. Which command should they use to accomplish this task?
du -h /home/* >> disk_report.txt
du -h /home/* < disk_report.txt
du -h /home/* &> disk_report.txt
du -h /home/* > disk_report.txt
The correct answer is 'du -h /home/* > disk_report.txt' because the '>' operator will redirect the output of the 'du' command to 'disk_report.txt', overwriting its contents every time the command is run, thus only saving the latest disk usage report in the file.
The 'du -h /home/* >> disk_report.txt' is incorrect because using the '>>' operator would append to the file rather than overwriting it, leading to accumulation of data over time rather than maintaining a single report.
The 'du -h /home/* < disk_report.txt' is incorrect because the '<' operator is used for input redirection, which is not what is needed when intending to write to a file.
Lastly, 'du -h /home/* &> disk_report.txt' is incorrect as '&>' redirects both standard output and standard error to a file, which could include error messages in the report unnecessarily.
A system administrator has noticed that over time, a Linux server's available memory decreases, even when the workload on the server remains consistent. The 'top' command shows a particular process gradually increasing its memory usage without releasing it back to the system. Which of the following tools should the administrator use to further investigate this suspected memory leak in the problematic process?
free
mpstat
vmstat
valgrind
The valgrind
tool is used to detect memory leaks and memory management problems in programs. When a process is suspected of having a memory leak because it progressively consumes more memory without freeing it, valgrind
can be employed to analyze the process and identify where memory is not being appropriately released.
free
is a command that displays the amount of free and used memory in the system but does not detect memory leaks in processes.
vmstat
reports information about processes, memory, paging, block IO, traps, disks, and cpu activity, but does not specifically analyze memory leaks in individual processes.
mpstat
is used to monitor CPU utilization but does not analyze memory leaks in a process.
A Linux administrator needs to configure a Linux server to send its system logs to a remote log server at the IP address 192.168.150.50. Which configuration line should the administrator add to the rsyslog configuration file to accomplish this task?
. @@192.168.150.50
. >192.168.150.50
. #192.168.150.50
. @192.168.150.50
The correct answer is *.* @192.168.150.50
because the syntax specifies that logs of all facilities and all severities (*.*
) should be forwarded to the remote server at the specified IP address using the UDP protocol (denoted by a single @
sign). Other answers are incorrect because >
does not indicate remote logging, multiple @
signs or using #
are not valid for specifying a remote log server in rsyslog configuration, and the >
is reminiscent of shell redirection which has no context here.
Using single-threaded I/O operations on a Solid State Drive (SSD) will always result in optimal throughput.
False
True
This statement is false because SSDs are designed to perform optimally with multi-threaded I/O operations that can leverage the drive's capabilities for parallel data access and processing. Single-threaded operations do not fully utilize the SSD's performance potential, which can lead to suboptimal throughput. Additionally, the I/O scheduler and alignment of the file system and partitions can play significant roles in achieving optimal SSD performance. Other false answers may seem plausible but are inaccurate in suggesting a single-threaded approach is always optimal.
You are maintaining a script that updates system packages and restarts a critical service afterward, but only if the update succeeds. Which line of code correctly implements this behavior?
yum update -y || service httpd restart
yum update -y && service httpd restart
yum update -y & service httpd restart
yum update -y ; service httpd restart
The use of &&
ensures that the subsequent command (service httpd restart) is executed only if the preceding command (yum update -y) completes successfully with an exit status of 0. Using ;
does not check the success of the previous command. Using ||
only executes the subsequent command if the preceding one fails. Using &
will put the first command in the background and immediately run the second one regardless of the first one's result.
A colleague informs you that a new feature has been added to a project, and it's available on the 'feature-login' branch for preview before it's merged into the main codebase. You are currently on the 'main' branch and have made some local modifications that you don't want to commit yet. How would you switch to the 'feature-login' branch to review the new additions without losing your uncommitted changes?
git checkout feature-login --force
git commit -m 'Temp commit' and then use git checkout feature-login
git stash your changes and then use git checkout feature-login
git merge feature-login into your main branch
The correct answer is git stash your changes and then use git checkout feature-login
. This is because you can save your uncommitted changes with git stash
, which acts like a stack where you can push changes to be temporarily stored, and later you can pop them off. After stashing your changes, you can safely change branches using git checkout
. Using the other commands might either lead to a loss of local changes or are not correct commands for handling a change in branches.
A system administrator has noticed SELinux is preventing a web application from functioning properly on a production server running the 'targeted' policy. The administrator wants to temporarily relax SELinux enforcement to diagnose the issue without entirely disabling SELinux or making permanent policy changes. Which command should the administrator use to fulfill this requirement?
setsebool -P
setenforce enforcing
setenforce Disabled
setenforce 0
enforce 0
The setenforce 0
command sets SELinux to 'Permissive' mode. In 'Permissive' mode, SELinux continues to evaluate rules and log violations but does not enforce the policy, allowing the administrator to see what would be blocked without impacting the application. Once the evaluation is complete, using setenforce 1
would return SELinux to 'Enforcing' mode. 'setsebool -P' is used to make persistent changes to SELinux booleans, enforce 0
is invalid syntax, and setenforce enforcing
uses incorrect terminology. The term 'Disabled' does not apply to runtime changes and is only set in SELinux config files which requires a reboot.
An administrator wishes to grant a user, john
, the ability to restart the httpd
service without providing a password. Which line should be added to the /etc/sudoers
file to accomplish this?
john ALL=(ALL) NOPASSWD: systemctl restart httpd
john ALL=(ALL) /bin/systemctl restart httpd
john ALL=(ALL) NOPASSWD: ALL
john ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd
The correct line to add is john ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd
. This allows the user john
on all hosts (ALL
) to execute the specific command /bin/systemctl restart httpd
without being prompted for a password (NOPASSWD:
). The ALL=(ALL)
allows execution as all users and groups, although in this case, the specific command does not require changing to a different user or group. It's important to use full paths for commands in sudoers
for security. The other options are incorrect because they either omit NOPASSWD:
which would still prompt for a password, use ALL
which would undesirably allow all commands, or specify an incorrect command path.
What command would you use to display all the currently running container instances in the system?
docker inspect
docker running
docker ps
docker list
The docker ps
command is used to list all running containers. The option -a
or --all
can be added to show all containers, not just those that are running. The commands docker list
and docker running
are not valid Docker commands. While docker inspect
provides detailed information about one or more containers, it does not list all running containers.
An administrator has just completed the installation of a new kernel on a Linux system. After installing the kernel and related modules, they wish to update the GRUB2 bootloader configuration to ensure that the system will boot using this new kernel. Which of the following commands should the administrator run to correctly generate a new configuration and ensure the new kernel is bootable?
mkinitrd /boot/initrd.img
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install
grub2-update
The command 'grub2-mkconfig -o /boot/grub2/grub.cfg' generates a new GRUB2 configuration file and writes it to the default location for GRUB2's configuration. The '-o' option is used to specify the output file and is critical for actual application of changes. Other options shown might seem plausible, but they do not perform the task of updating the configuration.
An administrator notices that a recently mounted ext4 filesystem is not correctly recording the access times of files when they are read. The administrator suspects that a mount option may be causing this behavior. Which of the following mount options did the administrator most likely use when mounting the filesystem?
sync
dirsync
relatime
noatime
The correct answer is 'noatime'. This mount option disables the updating of access times on files when they are read, which can improve performance, especially on frequently accessed filesystems. The 'relatime' option updates access times only if the previous access time was earlier than the current modify or change time. 'sync' and 'dirsync' are not directly related to file access time updates; 'sync' makes all writes synchronous, and 'dirsync' ensures directory changes are written synchronously, but neither disables the update of access times.
A system administrator notices that a Linux server is experiencing slow performance, specifically in disk operations. Upon investigating, the administrator discovered that the I/O wait time is considerably high. Which of the following actions is the BEST course of action to reduce the high latency affecting the system?
Deploy additional network interfaces to balance the I/O load.
Replace the current I/O scheduler with one that is better optimized for the system's workload.
Decrease the amount of RAM in the system to reduce the memory available for disk caching.
Increase the CPU clock speed to process I/O operations faster.
In this scenario, the best course of action is to replace the current I/O scheduler with one that is optimized for the particular workload characteristics (e.g. CFQ, Deadline, NOOP). The I/O scheduler is responsible for ordering disk access to improve performance. Some schedulers are better suited for certain workloads than others, and so choosing the correct one can potentially reduce I/O wait times and thus lower latency.
Looks like thats it! You can go back and review your answers or click the button below to grade your test.