CompTIA Linux+ Exam Questions

Page 2 of 25

21.

An administrator needs to monitor an app container. They want the monitoring tools to be located external to the app container. What type of orchestration process should they utilize?

  • Agentless

  • Agent

  • Vagrant

  • Spinnaker

Correct answer: Agentless

An agentless orchestration utility is not installed within the container app but installed in an external environment. 

An agent-based utility is installed within the app. Vagrant is a DevOps solution for portable development environments. Spinnaker is an open-source DevOps solution for continuous delivery of software changes.

22.

A user wants to use SCP (secure copy) to regularly download some files from a remote server. Which command-line tool should the user use for this?

  • cURL

  • wget

  • yum

  • zypper

Correct answer: cURL

The cURL program supports numerous protocols, including DAP, DICT, FILE, Gopher, IMAP, LDAP, POP3, RTSP, SCP, SFTP, SMTP, and TFTP. It can also issue a warning if a remote server's certificate is self-signed or signed by an untrusted certificate authority. 

The wget application supports FTP, FTPS, HTTP, and HTTPS, but it does not support SCP. The yum tool is for working with repositories on Red Hat-based systems. The zypper tool is a command-line package manager for Red Hat-based systems.

23.

Which command will put SELinux into a mode that will deny users access based on defined policies?

  • setenforce 1

  • setenforce 0

  • getenforce 0

  • getenforce 1

Correct answer: setenforce 1

The setenforce command will change the mode of SELinux. To make the mode permanent, edit it inside the /etc/selinux/config file. 

The 0 option refers to permissive mode, while 1 refers to enforcing. The getenforce command is used to view the current mode.

24.

An administrator wants to use the Red Hat Package Manager to install an application or upgrade it if it is already there. Which action should they add to the rpm command to accomplish this?

  • -U

  • -q

  • -i

  • -F

Correct answer: -U

The -U action installs or upgrades a package. 

The -q action is to query if a package is already installed. The -i option is to just install the package. The -F option only upgrades if a previous version is there already.

25.

What is the name of the repositories where container images are centrally stored?

  • Container registry

  • Hypervisor 

  • Container template 

  • Docker

Correct answer: Container registry

Container images are typically stored centrally in repositories known as container registries. A container registry can be public or private. They are an easy way to share images. 

Hypervisors provide the virtual environment for virtual machines. Container templates are used to quickly duplicate a container environment. Docker is a type of container software. 

26.

Which of the following commands is a comment in a shell script?

  • # This is a comment

  • /bin/bash This is a comment

  • <!--This is a comment -->

  • /* This is a comment */

Correct answer: # This is a comment

The pound sign (#) is used to start a comment in shell scripts. 

Using /bin/bash is invoking the interpreter. The other lines are comments in different programming languages.

27.

Which utility creates a report of any application and kernel crashes on Red Hat-based systems?

  • abrt

  • udevadmin

  • dmesg

  • lpq

Correct answer: abrt

Red Hat-based systems use the Automatic Bug Reporting Tool (abrt) to create a report of any application and kernel crashes. 

The udevadmin command is for device management. The dmesg tool is for viewing just kernel messages. The lpq command is for showing the print queue.

28.

Which command will immediately reboot a Linux system?

  • init 6

  • init 0

  • shutdown +1 -h 

  • halt

Correct answer: init 6

The init command will switch a system's runlevel. Runlevel 6 is a reboot. 

Using the init command with runlevel 0 will halt the system. The shutdown +1 -h command instructs the system to shut down and then halt. It is possible to reboot using the shutdown command, but it would require the -r option. The halt command will shut down the system.

29.

Which logic construct checks once if a condition is true and then runs a block of code if it is?

  • if

  • while

  • for

  • until

Correct answer: if

An if statement checks a condition and if it is true, it runs a block of code. It can be used with else and else if statements. 

A while loop iterates while a condition evaluates to true. A for loop iterates through all elements in a series. An until loop is the opposite of a while loop and iterates while a condition is false.

30.

Which filename extension is the default to use for shell scripts?

  • .sh

  • .txt

  • .conf

  • .tar

Correct answer: .sh

A shell script ends with .sh by convention. However, it is not a requirement. 

A .txt file is a text file. A .conf file is a configuration file. A .tar file is an archive file.

31.

Which range of network ports are referred to as "registered ports"?

  • 1024-49151

  • 0-1023

  • 49151+

  • 0-49151

Correct answer: 1024-49151

Some administrators change the default ports that applications use to throw off potential attackers. Ports 1024-49151 are registered ports with IANA. 

Ports 0-1023 are "well-known ports." Ports greater than 49151 are "private ports."

32.

What utility can be used to make an initramfs boot image from tools and files already installed on a system?

  • dracut

  • grub2-install

  • dmesg

  • fsck

Correct answer: dracut

The dracut utility creates a boot image by using installed framework and files. 

You can use grub2-install to install or re-install the GRUB2 bootloader. You can use dmesg to view recent boot messages. The fsck utility is used to check and repair filesystems. 

33.

Which utility tests network throughput and needs to be installed on both a client and a server?

  • iperf

  • iftop

  • netstat

  • route

Correct answer: iperf

The iperf command needs to be run on both a client and a server. It will also need the default ports open between each system, which is 5001 or 5201 for iperf3. 

The iftop command displays network bandwidth usage for an adapter. The netstat command shows which sockets are connected and listening. The route command updates the system's routing tables.

34.

Which Linux tool can be used to display and change settings to a network interface, such as speed and duplex?

  • ethtool

  • ifconfig

  • ss

  • brctl

Correct answer: ethtool

The ethtool can be used to query and configure network device settings. By default, it will list the current settings but can also change settings like speed, duplex, and auto-negotiation. 

The ifconfig command is used to set an address and subnet mask. The ss comand is used to display socket information. The brctl command is used to create and control an Ethernet bridge.

35.

A user wants to search the system for a file called network but without file globbing. What command should they run to accomplish this?

  • locate '\network'

  • locate '/network'

  • locate '/network/'

  • locate 'network'

Correct answer: locate '\network'

The command locate '\network' would search for a file called network but without file globbing. File globbing involves using wildcard characters to find results similar to the search term. Globbing can be avoided by using quotation marks around the pattern and preceding it with a \ character. 

The other options are not written in the correct syntax.

36.

An administrator is troubleshooting an issue in which the server slows down over time. They want to determine if there's an issue with RAM usage. Which command can they use to check this?

  • free

  • dmesg

  • lsmod

  • lshw

Correct answer: free

The free command shows how much free and used memory is in the system. If there is not enough free memory or if there is a memory leak caused by a poorly coded program, the system will slow down considerably. 

The dmesg command is for viewing kernel messages. The lsmod command is used to show modules loaded into the kernel. The lshw command will show how much RAM is installed but not usage statistics.

37.

Which command tests a network connection between two hosts by opening a listening socket that the client can connect to?

  • netcat

  • ping

  • traceroute

  • mtr

Correct answer: netcat

The netcat utility can establish a connection between two systems. After a connection is established, text typed on the client will show up on the server. 

The ping command simply checks if the other system is reachable. The traceroute utility is for troubleshooting where lag is happening between networks. The mtr command is a combination of ping and traceroute.

38.

A developer is creating a new repository to start a coding project. Which Git command should they use to make a new, empty repository?

  • init

  • add

  • branch

  • commit

Correct answer: init

The init command initializes a new, empty repository or initializes an already existing one. 

The add command adds files to the repository. The branch command can list, create, or delete a branch. The commit command records changes to the repository and makes a restore point.

39.

In cryptography, which type of key is used to decrypt ciphers and is meant to be shared?

  • Public keys

  • Private keys

  • Symmetric keys

  • Single keys

Correct answer: Public keys

Public keys are used in asymmetric cryptography so that all users do not need the same private key. Examples of this include SSH and digital certificates. 

Private keys are used to encrypt data and should not be shared publicly. Symmetric and single are other ways to call private keys.

40.

A user creates a variable in a script but is NOT able to access it outside of the shell. What type of variable did they create?

  • Local

  • Global

  • Parent

  • Child

Correct answer: Local

A local variable is only accessible in the context it is created in, such as a script. 

A global variable is defined outside of the script at the shell level. Parent and child are types of process relationships.