ExamGecko
Home Home / CompTIA / XK0-005

CompTIA XK0-005 Practice Test - Questions Answers, Page 21

Question list
Search
Search

List of questions

Search

Related questions











A systems administrator is tasked with changing the default shell of a system account in order to disable iterative logins. Which of the following is the best option for the administrator to use as the new shell?

A.
/sbin/nologin
A.
/sbin/nologin
Answers
B.
/bin/ sh
B.
/bin/ sh
Answers
C.
/sbin/ setenforce
C.
/sbin/ setenforce
Answers
D.
/bin/bash
D.
/bin/bash
Answers
Suggested answer: A

Explanation:

The /sbin/nologin shell is a special shell that prevents the user from logging into an interactive session. It is commonly used for system accounts that are not meant to be accessed by users, such as daemon or service accounts. When a user tries to log in with this shell, they will see a message like ''This account is currently not available'' and the login will fail.

The /sbin/nologin shell is listed as one of the valid shells in the /etc/shells file1.

The CompTIA Linux+ Certification Exam Objectives mention that the candidate should be able to ''configure and manage system accounts and groups, including password aging and restricted shells'' as part of the Hardware and System Configuration domain2.

The usermod command can be used to change the user's login shell with the -s or --shell option3. For example, to change the shell of a user named daemon to /sbin/nologin, the command would be:sudo usermod -s /sbin/nologin daemon

An administrator needs to increase the system priority of a process with PID 2274. Which of the following commands should the administrator use to accomplish this task?

A.
renice ---n ---15 2274
A.
renice ---n ---15 2274
Answers
B.
nice -15 2274
B.
nice -15 2274
Answers
C.
echo '---15' > /proc/PID/2274/priority
C.
echo '---15' > /proc/PID/2274/priority
Answers
D.
ps ---ef I grep 2274
D.
ps ---ef I grep 2274
Answers
Suggested answer: A

Explanation:

The renice command is used to change the priority of a running process by specifying its PID and the new nice value. The -n flag indicates the amount of change in the nice value, which can be positive or negative. A lower nice value means a higher priority, so -15 will increase the priority of the process with PID 2274. The administrator needs to have root privileges to do this.

The renice command is listed as one of the commands to manipulate process priority in the web search result1.

The renice command is also explained with examples in the web search result2.

The CompTIA Linux+ Certification Exam Objectives mention that the candidate should be able to ''manage process execution priorities'' as part of the System Operation and Maintenance domain1.

A junior systems administrator recently installed an HBA card in one of the servers that is deployed for a production environment. Which of the following commands can the administrator use to confirm on which server the card was installed?

A.
lspci | egrep 'hba| fibr'
A.
lspci | egrep 'hba| fibr'
Answers
B.
lspci | zgrep 'hba | fibr'
B.
lspci | zgrep 'hba | fibr'
Answers
C.
lspci | pgrep 'hba| fibr'
C.
lspci | pgrep 'hba| fibr'
Answers
D.
lspci | 'hba | fibr'
D.
lspci | 'hba | fibr'
Answers
Suggested answer: A

Explanation:

The best command to use to confirm on which server the HBA card was installed is

A). lspci | egrep 'hba| fibr'. This command will list all the PCI devices on the server and filter the output for those that match the pattern 'hba' or 'fibr', which are likely to be related to the HBA card. The egrep command is a variant of grep that supports extended regular expressions, which allow the use of the '|' operator for alternation. The other commands are either invalid or will not produce the desired output. For example:

B) lspci | zgrep 'hba | fibr' will try to use zgrep, which is a command for searching compressed files, not standard output.

C) lspci | pgrep 'hba| fibr' will try to use pgrep, which is a command for finding processes by name or other attributes, not text patterns.

D) lspci | 'hba | fibr' will try to use 'hba | fibr' as a command, which is not valid and will cause an error.

Users in the human resources department are trying to access files in a newly created directory. Which of the following commands will allow the users access to the files?

A.
chattr
A.
chattr
Answers
B.
chgrp
B.
chgrp
Answers
C.
chage
C.
chage
Answers
D.
chcon
D.
chcon
Answers
Suggested answer: B

Explanation:

The chgrp command is used to change the group ownership of files and directories. By using this command, the administrator can assign the files in the newly created directory to the human resources group, which will allow the users in that group to access them. The other commands are not relevant for this task. For example:

chattr is used to change the file attributes, such as making them immutable or append-only1.

chage is used to change the password expiration information for a user account2.

chcon is used to change the security context of files and directories, which is related to SELinux3.

The CompTIA Linux+ Certification Exam Objectives mention that the candidate should be able to ''manage file and directory ownership and permissions'' as part of the Hardware and System Configuration domain4.

The web search result2explains how to use the chgrp command with examples.

The web search result3compares the chmod and chgrp commands and their effects on file permissions.

A User on a Linux workstation needs to remotely start an application on a Linux server and then forward the graphical display of that application back to the Linux workstation. Which of the following would enable the user to perform this action?

A.
ssh -X user@server application
A.
ssh -X user@server application
Answers
B.
ssh -y user@server application
B.
ssh -y user@server application
Answers
C.
ssh user@server application
C.
ssh user@server application
Answers
D.
ssh -D user@server application
D.
ssh -D user@server application
Answers
Suggested answer: A

Explanation:

The ssh -X option enables X11 forwarding, which allows the user to run graphical applications on the remote server and display them on the local workstation. The user needs to specify the username, the server address, and the application name after the ssh -X command. The remote server also needs to have X11Forwarding enabled and xauth installed for this to work.

The web search result8explains how to run a GUI application through SSH by configuring both the SSH client and server.

The web search result6provides a detailed answer on how to forward X over SSH to run graphics applications remotely, with examples and troubleshooting tips.

The CompTIA Linux+ Certification Exam Objectives mention that the candidate should be able to ''use SSH for remote access and management'' as part of the System Operation and Maintenance domain1.

A Linux administrator is creating a new sudo profile for the accounting user. Which of the following should be added by the administrator to the sudo configuration file so that the accounting user can run / opt/ acc/ report as root?

A.
accounting localhost=/opt/acc/report
A.
accounting localhost=/opt/acc/report
Answers
B.
accounting ALL=/opt/acc/report
B.
accounting ALL=/opt/acc/report
Answers
C.
%accounting ALL=(ALL) NOPASSWD: /opt/acc/report
C.
%accounting ALL=(ALL) NOPASSWD: /opt/acc/report
Answers
D.
accounting /opt/acc/report= (ALL) NOPASSWD: ALL
D.
accounting /opt/acc/report= (ALL) NOPASSWD: ALL
Answers
Suggested answer: C

Explanation:

This answer allows the accounting user to run the /opt/acc/report command as root on any host without entering a password. The % sign indicates that accounting is a group name, not a user name. The ALL keyword means any host, any user, and any command, depending on the context. The NOPASSWD tag overrides the default behavior of sudo, which is to ask for the user's password.

The other answers are incorrect for the following reasons:

A) accounting localhost=/opt/acc/report

This answer only allows the accounting user to run the command on the localhost, not on any host.

This answer also requires the accounting user to enter their password, which is not specified in the question.

B) accounting ALL=/opt/acc/report

This answer only allows the accounting user to run the command as themselves, not as root.

This answer also requires the accounting user to enter their password, which is not specified in the question.

D) accounting /opt/acc/report= (ALL) NOPASSWD: ALL

This answer has an invalid syntax, as there should be no space between the equal sign and the parentheses.

This answer also grants too much privilege to the accounting user, as it allows them to run any command as any user without a password.

A systems administrator is trying to track down a rogue process that has a TCP listener on a network interface for remote command-and-control instructions.

Which of the following commands should the systems administrator use to generate a list of rogue process names? (Select two).

A.
netstat -antp | grep LISTEN
A.
netstat -antp | grep LISTEN
Answers
B.
lsof -iTCP | grep LISTEN
B.
lsof -iTCP | grep LISTEN
Answers
C.
lsof -i:22 | grep TCP
C.
lsof -i:22 | grep TCP
Answers
D.
netstat -a | grep TCP
D.
netstat -a | grep TCP
Answers
E.
nmap -p1-65535 | grep -i tcp
E.
nmap -p1-65535 | grep -i tcp
Answers
F.
nmap -sS 0.0.0.0/0
F.
nmap -sS 0.0.0.0/0
Answers
Suggested answer: A, B

Explanation:

The best commands to use to generate a list of rogue process names that have a TCP listener on a network interface are A. netstat -antp | grep LISTEN and B. lsof -iTCP | grep LISTEN. These commands will show the process ID (PID) and name of the processes that are listening on TCP ports, which can be used to identify any suspicious or unauthorized processes. The other commands are either not specific enough, not valid, or not relevant for this task. For example:

C) lsof -i:22 | grep TCP will only show the processes that are listening on port 22, which is typically used for SSH, and not any other ports.

D) netstat -a | grep TCP will show all the TCP connections, both active and listening, but not the process names or IDs.

E) nmap -p1-65535 | grep -i tcp will scan all the TCP ports on the local host, but not show the process names or IDs.

F) nmap -sS 0.0.0.0/0 will perform a stealth scan on the entire internet, which is not only impractical, but also illegal in some countries.

An administrator would like to list all current containers, regardless of their running state. Which of the following commands would allow the administrator to accomplish this task?

A.
docker ps -a
A.
docker ps -a
Answers
B.
docker list
B.
docker list
Answers
C.
docker image ls
C.
docker image ls
Answers
D.
docker inspect image
D.
docker inspect image
Answers
Suggested answer: A

Explanation:

The best command to use to list all current containers, regardless of their running state, is

A) docker ps -a. This command will show all containers, both running and stopped, with details such as container ID, image name, status, and ports. The other commands are either invalid or not relevant for this task. For example:

B) docker list is not a valid command. There is no subcommand named list in docker.

C) docker image ls will list all the images available on the local system, not the containers.

D) docker inspect image will show detailed information about a specific image, not all the containers.

An administrator has source code and needs to rebuild a kernel module. Which of the following command sequences is most commonly used to rebuild this type of module?

A.
./configure make make install
A.
./configure make make install
Answers
B.
wget gcc cp
B.
wget gcc cp
Answers
C.
tar xvzf build cp
C.
tar xvzf build cp
Answers
D.
build install configure
D.
build install configure
Answers
Suggested answer: A

Explanation:

The best command sequence to rebuild a kernel module from source code is A. ./configure make make install. This is the standard way to compile and install a Linux kernel module, as explained in the web search result 5. The other commands are either not relevant, not valid, or not sufficient for this task. For example:

B) wget gcc cp will try to download, compile, and copy a file, but it does not specify the source code, the module name, or the destination directory.

C) tar xvzf build cp will try to extract, build, and copy a compressed file, but it does not specify the file name, the module name, or the destination directory.

D) build install configure will try to run three commands that are not defined or recognized by the Linux shell.

An administrator started a long-running process in the foreground that needs to continue without interruption. Which of the following keystrokes should the administrator use to continue running the process in the background?

A.
<Ctrl+z> bg
A.
<Ctrl+z> bg
Answers
B.
<Ctrl+d> bg
B.
<Ctrl+d> bg
Answers
C.
<Ctrl+b> jobs -1
C.
<Ctrl+b> jobs -1
Answers
D.
<Ctrl+h> bg &
D.
<Ctrl+h> bg &
Answers
Suggested answer: A

Explanation:

A long-running process is a program that takes a long time to complete or runs indefinitely on a Linux system. A foreground process is a process that runs in the current terminal and receives input from the keyboard and output to the screen. A background process is a process that runs in the background and does not interact with the terminal. A background process can continue running even if the terminal is closed or disconnected.

To start a long-running process in the background, the user can append an ampersand (&) to the command, such assomeapp &. This will runsomeappin the background and return control to the terminal immediately.

To move a long-running process from the foreground to the background, the user can use two keystrokes: Ctrl+Z and bg. The Ctrl+Z keystroke will suspend (pause) the foreground process and return control to the terminal. The bg keystroke will resume (continue) the suspended process in the background and detach it from the terminal. The statement B is correct.

The statements A, C, and D are incorrect because they do not perform the desired task. The bg keystroke alone will not work unless there is a suspended process to resume. The Ctrl+B keystroke will not suspend the foreground process, but rather move one character backward in some applications. The jobs keystroke will list all processes associated with the current terminal. The bg & keystroke will cause an error because bg does not take any arguments.Reference: [How to Run Linux Processes in Background]

Total 371 questions
Go to page: of 38