CompTIA Linux+ Exam Questions

Page 6 of 25

101.

Which format should be used for hypervisor templates to easily duplicate virtual machine environments?

  • OVF

  • DLL

  • JSON

  • YAML

Correct answer: OVF

The Open Virtualization Format (OVF) is an open standard for virtual machine configurations. It uses a distribution package of several files and a single XML configuration file. 

A Dynamic Link Library (DLL) is a library of code that can be used by various programs. JSON is a data exchange format that is human-readable. YAML is a human-readable data serialization language.

102.

A developer is using the vi editor and is in Insert mode. They want to quickly save the file and exit the program while overriding protection. Which command sequence would they use?

  • Escape:wq!

  • :wq!

  • I:wq

  • Escape:x!

Correct answer: Escape:wq!

The developer should hit the Escape key first to exit Insert mode. Then, they can hit the colon key to get into Ex mode and use w to write, q to quit, and the exclamation point to override protections. 

The I command will go into Insert mode. The other answer choices skip a step.

103.

An administrator wants to see BIOS information from inside Linux. Which command can they run to accomplish this?

  • dmidecode -t bios

  • lspci -t bios

  • lshw -t bios

  • lsdev -t bios

Correct answer: dmidecode -t bios

The dmidecode provides information about hardware and requires a DMI/SMBIOS-compatible computer. The -t option allows for gathering a certain type of information, such as BIOS, memory, or processor. 

The lspci command shows information about PCI buses and devices. The lshw command shows detailed hardware information. The lsdev command gives information on hardware devices. The -t bios option is not applicable to the lspic, lshw, and lsdev commands. 

104.

An administrator is troubleshooting an issue in which a script creates files in a directory but cannot access the files later. They want to explicitly configure the script file's ACL to fix any issues with inheriting permissions. Which command can they use to accomplish this?

  • setfacl

  • chown

  • chattr

  • chroot

Correct answer: setfacl

The setfacl sets the access control list of the file or directory specified. This can override the inherited Access Control List (ACL). 

The chown command only changes ownership. The chattr command changes attributes rather than permissions. The chroot command sets a new root filesystem for an application to run in.

105.

Which file controls which physical terminals a root user can log in from?

  • /etc/securetty

  • /etc/sshd_config

  • /etc/at.deny

  • /etc/fstab

Correct answer: /etc/securetty

The /etc/securetty file has a list of terminals from which root is allowed to log in. If the file is empty, the root user will not be able to log in from any physical console. This doesn't block the root user from logging in via the network. 

The /etc/sshd_config defines configurations for remote secure connections. The /etc/at.deny file determines which users cannot submit commands to be executed at a later time. The /etc/fstab file is for configuring filesystems that will be mounted.

106.

Which file contains all the ports defined on a Linux server?

  • /etc/services

  • /etc/networks

  • /etc/hosts

  • /etc/resolv.conf

Correct answer: /etc/services

The /etc/services file has the ports that each service uses. It translates human-readable service names into their ports. 

The /etc/networks file has symbolic names for networks. The /etc/hosts file translates hostnames to IP addresses. The /etc/resolv.conf file lists search domains.

107.

Which line of code should appear at the top of a shell script?

  • #!/bin/bash

  • echo "Hello world"

  • BASH=/bin/bash

  • export $PATH

Correct answer: #!/bin/bash

The first line of code contains the absolute path to the command-line interpreter, such as #!/bin/bash. This is called the shebang line. 

The other lines should come after the shebang line.

108.

Which command will input the file /etc/resolve.conf to the cat utility?

  • cat < /etc/resolv.conf

  • cat > /etc/resolv.conf

  • cat | /etc/resolv.conf

  • cat <> /etc/resolv.conf

Correct answer: cat < /etc/resolv.conf

The operator < can select an input device other than the terminal. In this case, it uses the file /etc/resolv.conf as input for the cat utility. 

The other options will give errors.

109.

Which command will assign a file to a new owner?

  • chown User1 document1.txt 

  • chgrp User1 document1.txt 

  • chmod User1 document1.txt 

  • umask User1 document1.txt 

Correct answer: chown User1 document1.txt 

The chown command will change a file to a new owner. The root user or current owner can change it. 

The chgrp command will change the group. The chmod will change file permissions. The unmask command will change the default permissions for new files.

110.

Which command finds a command's source code and manual pages?

  • whereis  

  • which

  • locate

  • find

Correct answer: whereis

The whereis command can find the location of binaries, source code, and manual pages for a command. 

The which command finds the path to a command. The locate command finds a file by its name. The find command searches for files in a directory.

111.

A user is writing a script to automate backup on a server. They don't want to store passwords on the system, so they would like to use a public/private key solution. Which file should they add their public key to on the server to accomplish this?

  • authorized_keys

  • known_hosts

  • ssh_config

  • ssh_host_rsa_key

Correct answer: authorized_keys

To log in without a password, a client can copy their public key to the authorized_keys file on the server. A secure connection should be used to copy it. 

The known_hosts file is for a client to store a server's public key. The ssh_config file has client configurations. The ssh_host_rsa_key file is a system's private key.

112.

Which state of a process is in virtual memory and waiting for a signal from the kernel?

  • Interruptible sleep

  • Uninterruptible sleep

  • Zombie

  • Running

Correct answer: Interruptible sleep

A process that moves to virtual memory is considered sleeping. A process in interruptible sleep can wake up from a kernel signal.

A process in uninterruptible sleep needs some external event to occur. A zombie process is stuck in a limbo state. A running process is actively using CPU.

113.

Which authentication service uses a ticketing service to grant access?

  • Kerberos

  • LDAP

  • RADIUS

  • TACACS+

Correct answer: Kerberos

Kerberos has a key distribution center that issues users a Ticket-Granting Ticket (TGT) that can be used to grant access. It uses the kinit command to store credentials on a server and the klist command to view information about all tickets. 

LDAP focuses on authorization and uses a central server with a tree-like hierarchy. RADIUS is used by users to authenticate locally or remotely via a modem. TACACS+ offers authentication, authorization, and accounting as well as fully encrypted transactions. 

114.

An administrator has installed several different kernels to choose from on a system. Where can they go to see a list of each kernel's modules?

  • /usr/lib/modules

  • /etc/modprobe.d/

  • /proc/modules

  • /lib/modprobe.d

Correct answer: /usr/lib/modules

The /usr/lib/modules directory will have subdirectories for each kernel version. This may also be in the /lib/modules directory, depending on the version of Linux. 

The /etc/modprobe.d directory has configuration files created during the system's installation. The /proc/modules file shows the modules in the current kernel. The /lib/modprobe.d directory has configuration files for modules. 

115.

An administrator needs to monitor app containers to see how they are performing. They want to install software into the app itself to monitor it. Which type of solution are they employing?

  • Agent

  • Agentless

  • Apache Mesos

  • Docker Swarm

Correct answer: Agent

In agent-based orchestration, software is placed in the container app. However, this could possibly hurt the app's performance. 

In agentless orchestration, the monitoring tool uses pre-existing or embedded software in the container or outside the container. Apache Mesos is a kernel for containers. Docker Swarm is an orchestration system for Docker containers.

116.

An administrator wants to look up the IP address for a web server and then pipe the output to a text file. Which of the following commands would accomplish this?

  • nslookup google.com | cat > lookup_result

  • nslookup google.com | cat < lookup_result

  • nslookup google.com > cat | lookup_result

  • nslookup google.com | cat | lookup_result

Correct answer: nslookup google.com | cat > lookup_result

After executing the nslookup command, its temporary output is piped to the cat command, which then outputs it to a text file. 

The other answer options will give errors.

117.

An administrator wants to get a detailed listing of SELinux's settings. Which command will show output, including root directory and policy name?

  • sestatus

  • getenforce

  • setenforce

  • semanage

Correct answer: sestatus

The sestatus shows detailed information about the status of SELinux. This includes information such as the mode and policy. 

The getenforce command gets the current mode. The setenforce command changes the mode. The semanage command lists available policy booleans.

118.

Which algorithm is not used in cryptography but still functions as a file integrity checker?

  • MD5

  • SHA

  • ZIP

  • BZIP2

Correct answer: MD5

The MD5 algorithm is not used in cryptography because of known vulnerabilities; however, it can still be used to check a file's integrity. By using the md5sum utility, it can be determined if a remote and local file are identical. 

SHA is used for cryptography as well as file integrity checking. ZIP and BZIP2 are used for creating archives of files and directories.

119.

An administrator wants to search the /etc/passwd file to see if there is anyone named user1, user2, or user3. What command could they use for this?

  • egrep user[1,2,3] /etc/passwd

  • egrep user1{2,3} /etc/passwd

  • egrep user|1,2,3| /etc/passwd

  • egrep user1+ /etc/passwd

Correct answer: egrep user[1,2,3] /etc/passwd

The egrep command allows you to use extended regular expressions. It is deprecated now by the command grep -E. 

Curly braces match a minimum of the left character and a maximum of the right character. The | character is used for OR expressions. The + character matches one or more occurrences of the character on its left.

120.

Which directive should be set to NO in the /etc/ssh/sshd_config file to keep users from trying to enter the system as an administrator?

  • PermitRootLogin

  • Port

  • User

  • ForwardXll

Correct answer: PermitRootLogin

The PermitRootLogin parameter should be set to NO to prevent brute-force attacks. 

The Port parameter can change the default port to hide against attacks. The User property is used in ssh_config to set a username that will be used when connecting. The ForwardX11 property is used with remote desktop access.