A Linux engineer needs to create a custom script, cleanup.sh, to run at boot as part of the system services. Which of the following processes would accomplish this task?
Answer : C
The process that will accomplish the task of creating a custom script to run at boot as part of the system services is:
Create a unit file in the /etc/systemd/system/ directory. A unit file is a configuration file that defines the properties and behavior of a systemd service. The systemd is a system and service manager that controls the startup and operation of Linux systems. The /etc/systemd/system/ directory is the location where the administrator can create and store custom unit files. The unit file should have a name that matches the name of the script, such as cleanup.service, and should contain the following sections and options:
[Unit]: This section provides the general information about the service, such as the description, dependencies, and conditions. The administrator should specify the following options in this section:
Description: A brief description of the service, such as ''Custom cleanup script''.
After: The name of another unit that this service should start after, such as ''network.target''.
ConditionPathExists: The path of the file or directory that must exist for the service to start, such as ''/opt/scripts/cleanup.sh''.
[Service]: This section defines how the service should be started and stopped, and what commands should be executed. The administrator should specify the following options in this section:
Type: The type of the service, such as ''oneshot'', which means that the service will run once and then exit.
ExecStart: The command that will start the service, such as ''/bin/bash /opt/scripts/cleanup.sh''.
RemainAfterExit: A boolean value that indicates whether the service should remain active after the command exits, such as ''yes''.
[Install]: This section defines how the service should be enabled and under what circumstances it should be started. The administrator should specify the following option in this section:
WantedBy: The name of another unit that wants this service to be started, such as ''multi-user.target'', which means that the service will be started when the system reaches the multi-user mode.
Run the commandsystemct1 enable cleanup. This command will enable the service and create the necessary symbolic links to start the service at boot.
Run the commandsystemct1 is-enabled cleanup. This command will check the status of the service and confirm that it is enabled.
This process will create a custom script, cleanup.sh, to run at boot as part of the system services. This is the correct process to use to accomplish the task. The other options are incorrect because they either use the wrong directory for the unit file (/etc/default/,/etc/skel/, or/etc/sysctl.d/) or do not create a unit file at all.:CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 15: Managing System Services, pages 457-459.
A user sends a request to access a virtual server via SSH. Which of the following commands is used to open the SSH standard port?
Answer : A
The correct way to open a port for SSH using firewalld is:
bash
firewalld-cmd --permanent --add-port=22/tcp
This command allows TCP traffic on port 22 (the default port for SSH).
Option B only displays saved rules and doesn't open the port.
Option C contains incorrect syntax: --dport sshd is invalid (sshd is a daemon, not a port number).
Option D removes the SSH service from the firewall, which is the opposite of the requirement.
''Use firewalld-cmd --permanent --add-port=22/tcp to allow SSH traffic through firewalld.''
A Linux administrator modified the SSH configuration file. Which of the following commands should be used to apply the configuration changes?
Answer : C
The systemct1 reload sshd command can be used to apply the configuration changes of the SSH server daemon without restarting it. This is useful to avoid interrupting existing connections. The systemct1 stop sshd command would stop the SSH server daemon, not apply the changes. The systemct1 mask sshd command would prevent the SSH server daemon from being started, not apply the changes. The systemct1 start sshd command would start the SSH server daemon if it is not running, but it would not apply the changes if it is already running.:CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 12: Secure Shell (SSH), page 415.
A Linux systems administrator is setting up a new web server and getting 404 - NOT FOUND errors while trying to access the web server pages from the browser. While working on the diagnosis of this issue, the Linux systems administrator executes the following commands:
Which of the following commands will BEST resolve this issue?
Answer : B
The commandrestorecon -R -v /var/www/htmlwill best resolve the issue. The issue is caused by the incorrect SELinux context of the web server files under the /var/www/html directory. The output ofls -Z /var/www/htmlshows that the files have the type user_home_t, which is not allowed for web content. The commandrestoreconrestores the default SELinux context of files based on the policy rules. The options-Rand-vare used to apply the command recursively and verbosely. This command will change the type of the files to httpd_sys_content_t, which is the correct type for web content. This will allow the web server to access the files and serve the pages to the browser. The other options are incorrect because they either disable SELinux entirely (sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configorsetenforce 0), which is not a good security practice, or enable an unnecessary boolean (setsebool -P httpd_can_network_connect_db on), which is not related to the issue.:CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 18: Securing Linux Systems, page 535.
A Linux system fails to start and delivers the following error message:
Which of the following commands can be used to address this issue?
Answer : A
The commandfsck.ext4 /dev/sda1can be used to address the issue. The issue is caused by a corrupted filesystem on the /dev/sda1 partition. The error message shows that the filesystem type is ext4 and the superblock is invalid. The commandfsck.ext4is a tool for checking and repairing ext4 filesystems. The command will scan the partition for errors and attempt to fix them. This command can resolve the issue and allow the system to start. The other options are incorrect because they either do not fix the filesystem (partprobeorfdisk) or destroy the data on the partition (mkfs.ext4).:CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 10: Managing Storage, page 325.
A Linux systems administrator is resolving a privileged access issue for users who are members of an admin group. Which of the following configuration files should the administrator update so the users in the admin group will have root privileged access to the Linux system?
Answer : A
To grant sudo/root privileges to a group (like admin), the correct file to edit is:
bash
/etc/sudoers
This is where privilege escalation rules are defined. A line such as:
bash
%admin ALL=(ALL) ALL
will grant all users in the admin group root privileges.
/etc/login.defs controls general login settings.
/etc/group defines group membership but does not assign privileges.
/etc/shadow holds encrypted passwords and is not relevant here.
''To allow members of a group to execute commands with root privileges, update the /etc/sudoers file using visudo.''
An administrator wants to execute a long-running script in the terminal while troubleshooting another issue. Which of the following options will achieve this goal?
Answer : A
A is correct: Appending & runs the script in the background, allowing the user to continue using the terminal.
Incorrect Options:
B: Executes in the current shell, not background.
C: Invalid use of jobs.
D: Changes priority but still runs in foreground.
CompTIA Linux+ XK0-005 Study Guide, Chapter 12
man bash