No products in the cart.
CompTIA Linux+ Exam Questions
Page 1 of 25
1.
An administrator wants to change the clock from local time to UTC. Which command should they run to do this?
-
timedatectl set-timezone UTC
-
date set-timezone UTC
-
hwclock set-timezone UTC
-
localectl set-timezone UTC
Correct answer: timedatectl set-timezone UTC
The timedatectl command can display a list of time zoned data files, change the time zone, and set the time. Setting the clock may not work if automatic time synchronization is enabled.
The date command shows or sets the date. The hwclock command sets the time in the system's BIOS or UEFI. The localectl command sets the locale.
2.
Which command opens up a text-based user interface that allows an administrator to manually adjust a user's password aging information?
-
chage
-
passwd
-
id
-
usermod
Correct answer: chage
The chage command followed by the user's account name will open up a text-based user interface. There, an administrator can change the minimum and maximum password age, last password change date, password expiration warning leeway, password inactivity value, and account expiration date.
The passwd command is for changing passwords. The id command is for finding a user's id. The usermod command is for modifying user information such as their home directory or username.
3.
An administrator is about to do a snapshot of a system. What command should they run FIRST to make sure that there are no open files?
-
lsof
-
ls
-
ps
-
top
Correct answer: lsof
The list open files (lsof) command shows which files are open by which processes.
The ls command is used to show files and directories. The ps command is used to show active processes. The top command is used to show a real-time view of processes.
4.
Which term in DevOps describes the orchestration methods that control configurations and deployments through means such as scripts and libraries?
-
Infrastructure as code
-
Version control
-
App container
-
Self-healing
Correct answer: Infrastructure as code
Infrastructure as code can refer to automating processes like deployment or treating infrastructure development as if it were a software development project.
Version control refers to keeping registered versions of code for organization or rollbacks. An app container is a stand-alone package containing the operating system and libraries it needs to function. Self-healing refers to the ability of an orchestration tool to bring more app containers online if some of them malfunction.
5.
A user is getting a permission denied error when trying to create a new file in their home directory. The administrator wants to see if the partition that holds their files is full. Which command should they use to see if they have run out of disk space?
-
df
-
repquota
-
quotacheck
-
chattr
Correct answer: df
The df command makes a summary of a disk's available and used space.
The repquota command is used for checking a user's or group's quota. The quotacheck command is for creating a database file for quotas. The chattr command is for removing a file's immutable bit.
6.
Which type of keys are used in symmetric encryption?
-
Private keys
-
Public keys
-
Private/public key pairs
-
SSH
Correct answer: Private keys
In symmetric encryption, there are only private keys, and all users will need the same key. However, it is faster than asymmetric cryptography.
Public keys are used with asymmetric cryptography. A public/private key pair is used for asymmetric cryptography. SSH is an implementation of asymmetric cryptography.
7.
Which command will give a hierarchical view of USB hubs and devices attached to each?
-
lsusb -t
-
lsusb -d
-
lsusb -v
-
lsusb -s
Correct answer: lsusb -t
The command lsusb -t will display USB information in a tree format. It shows the hub, driver, and transfer speed.
The -d option only displays devices from a specific vendor ID. The -v option is for verbose mode. The -s option only displays options for a particular bus.
8.
Which command should be used to edit the sudoers file?
-
visudo
-
vi
-
emacs
-
nano
Correct answer: visudo
The visudo command should be used because other editors may corrupt the file. It can also be edited by running sudo -e /etc/sudoers or running sudoedit /etc/sudoers.
The vi, emacs, and nano utilities are text editors in Linux.
9.
What do two exclamation points (!!) in the password field of the /etc/shadow file mean?
-
The user's password has not been set
-
The user's account is locked
-
The user's password is encrypted with the MD5 algorithm
-
The user's password hash has not been salted
Correct answer: The user's password has not been set
Two exclamation points in the second field of the /etc/shadow file mean that a password has not been set. Setting a password will fill this field with a salted and hashed version of the password.
A locked account will have a single exclamation point before the password. The algorithm is determined by what is in the /etc/login.defs file. All passwords should be salted.
10.
Which permission protects a file from being deleted by anyone except the file owner?
-
Sticky Bit
-
SUID
-
GUID
-
2660
Correct answer: Sticky Bit
The sticky bit protects a file by only allowing the owner to delete it. It can be set by adding the digit 1 before the octal mode setting.
The Set User ID (SUID) permission runs a file based on file owner permissions rather than the user running the file. The Group User ID (GUID) has files run with the file's group permissions. 2660 is the octal to set GUID.
11.
Which is the PRIMARY tool for working with a repository on a Red Hat-based Linux distribution?
-
yum
-
apt
-
dpkg
-
make
Correct answer: yum
Yellowdog Update Manager (YUM) lets an administrator install, remove, and query software packages in a Red Hat repository. The repository files are stored in the folder /etc/yum.repos.d.
Debian-based systems use the apt suite of tools to work with repositories and the dpkg tool to interact with a package management database. The make command is for compiling software.
12.
An administrator is using Git for version control. They want to mark specific commit versions with additional information, such as a release number, to maintain organization. Which command can be used for this purpose?
-
git tag
-
git status
-
git push
-
git log
Correct answer: git tag
The git tag command allows you to mark specific commit versions with additional information such as the release number.
The git status command is used for viewing a branch in use. The git push command is used to push a project to a remote repository. The git log command is used to view the log for Git.
13.
Initialization scripts for each service are typically located in which directory for Linux distributions based on SystemV?
-
/etc/init.d
-
/etc/grub.d
-
/etc/sysctl.d
-
/etc/sysconfig
Correct answer: /etc/init.d
For Linux distributions based on SystemV, initialization scripts for each service are typically located in the /etc/init.d directory.
The /etc/grub.d folder is for the GRUB bootloader settings. The /etc/sysctl.d folder is for system configuration parameters. The /etc/sysconfig directory holds network configuration files.
14.
An administrator wants to quickly resolve a hostname to an IP address. What command gives them ONLY this information WITHOUT any added details?
-
Host
-
Dig
-
Mtr
-
Netstat
Correct answer: Host
The host command queries the DNS server to resolve a hostname to its IP address. The syntax for this command is to just type the hostname after the command, such as host google.com.
The dig command gives a lot of extra details, including query time and authoritative server, which are not needed in this scenario. The mtr command traces the route to the host along with giving the same information as the ping command. The netstat command lists network connections, displays routing tables, and displays network interface information.
15.
With System V initialization, which file brings the system to a predefined runlevel?
-
/etc/inittab
-
/etc/rc.local
-
/etc/resolv.conf
-
/etc/systemd/system/default.target
Correct answer: /etc/inittab
The /etc/inittab file is a configuration file for initializing the system. Each line of the file tells which directory has scripts to run for the specified runlevel.
The /etc/rc.local file is a script run upon boot or changing runlevels with commands that run in the background. The /etc/resolv.conf file is for configuring DNS information. The /etc/systemd/system/default.target file is for default group of units in the systemd initialization process.
16.
An administrator wants to make a backup of files that have only been changed since the last backup operation. Which type of backup should they use?
-
Incremental
-
Differential
-
Snapshot
-
Full
Correct answer: Incremental
An incremental backup makes a copy of files that have changed since the last backup regardless of the type of backup that was previously performed.
A differential backup only copies files that have changed since the last full backup. A snapshot uses a full backup and then pointers in a reference table that keeps track of changes. A full backup is a copy of all the data on a system, ignoring its modification date.
17.
An administrator wants to backup and compress a bunch of text files in a directory. Which command will accomplish this?
-
tar -zcvf backup.tar.gz *.txt
-
cpio -zcvf backup.tar.gz *.txt
-
dd -zcvf backup.tar.gz *.txt
-
gzip -zcvf backup.tar.gz *.txt
Correct answer: tar -zcvf backup.tar.gz *.txt
The tar command is used to create an archive. The -z option will use the gzip utility for compression.
The other commands will produce errors because of their syntax.
18.
In which situation would an administrator use the unlink command?
-
To remove a file that shares an inode number with another
-
To unmount a filesystem
-
To disable a network interface card
-
To add or remove modules to the Linux kernel.
Correct answer: To remove a file that shares an inode number with another
Files that share inode numbers are hard symbolic links. They can be removed with the unlink command.
The umount command can unmount a filesystem. The ifdown command can disable a network interface card. The modprobe command can add or remove modules to the Linux kernel.
19.
An administrator wants to disable ICMP messages to increase security. Which file would they use to configure this?
-
/etc/sysctl.conf
-
/etc/hosts
-
/etc/nsswitch.conf
-
/etc/resolv.conf
Correct answer: /etc/sysctl.conf
The /etc/sysctl.conf file is used to fine-tune networking parameters. It has kernel parameters that are used when working with network interfaces.
The /etc/hosts file is for resolving hostname to IP address locally. The /etc/nsswitch.conf file is for determining which services should be used to resolve hostnames. The /etc/resolv.conf file is used to set the DNS servers the host should use.
20.
An administrator has set up a new server and wants to be able to quickly restore it to a bootable state in case of a disaster. What type of backup should they make?
-
System image
-
Full
-
Incremental
-
Differential
Correct answer: System image
A system image copies the operating system binaries and configuration files so that the system can boot. The individual files can subsequently be recovered by using a full backup.
A full backup is for copying all files to be able to restore individual files or all of them at a later time. An incremental backup copies data that has changed since the last backup operation. A differential backup copies files that have been modified since the last full backup.