Dive into practice questions
Question 1
A DevOps engineer wants to make a copy of a coworker's existing repositories to a sandbox machine. Which of the following commands should the engineer use to accomplish this task?
A. git fetch
B. git checkout
C. git retrieve
D. git clone
Question 2
Which of the following directories contains the Linux kernel?
A. /proc
B. /sys
C. /dev
D. /boot
Question 3
A systems administrator is deploying a new custom application. Which of the following commands in the ~/.bashrc file will add $HOME/bin to the PATH variable?
A. PATH=~/bin;$PATH;export PATH
B. export $PATH=~/bin:$PATH
C. export PATH=~/bin:$PATH
D. PATH=~/bin;export $PATH
Question 4
A Linux administrator creates a Bash script that gets flagged by the CI/CD lint check as using deprecated syntax for the following line:
my_var=`grep -i USER1 users.txt`
Which of the following should the administrator use to avoid the deprecation notice in the script?
A. my_var=`cat users.txt | grep -i USER1`
B. my_var={grep -i USER1 users.txt}
C. my_var=[[ grep -i USER1 users.txt ]]
D. my_var=$(grep -i USER1 users.txt)
Question 5
A systems administrator is writing a new Python script. Which of the following should the administrator place as the first line?
A. !#/usr/bin/python3
B. #!/usr/bin/python3
C. \#/usr/bin/python3
D. #\/usr/bin/python3
Question 6
A Linux administrator installs the httpd service but wants to prevent it from running until it is configured. Which of the following is the best way to accomplish this task?
A. systemctl mask httpd
B. systemctl disable httpd
C. systemctl stop httpd
D. systemctl reload httpd
Question 7
A Linux administrator is trying to mount a new data drive that was recently added to the system.
When running the mount command, the administrator receives the following error:
# mount /dev/vdb1 /data
mount: /data: wrong fs type, bad option, bad superblock on /dev/vdb1, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
The administrator gathers some more details from the system and receives the following:
# dmesg | tail -10
[14249.798937] vdb: vdb1
[14260.556335] EXT4-fs (vdb1): VFS: Can't find ext4 filesystem
[14260.556935] EXT4-fs (vdb1): VFS: Can't find ext4 filesystem
[14260.557547] EXT4-fs (vdb1): VFS: Can't find ext4 filesystem
[14260.591339] ISOFS: Unable to identify CD-ROM format.
[14260.630492] FAT-fs (vdb1): bogus number of reserved sectors
[14260.630499] FAT-fs (vdb1): Can't find a valid FAT filesystem
[14260.640887] hfs: can't find a HFS filesystem on dev vdb1
[14260.672604] hfsplus: unable to find HFS+ superblock
[14260.673751] XFS (vdb1): Invalid superblock magic number
# lsblk -f
| NAME | FSTYPE | FSVER | UUID | FSAVAIL | FSUE% | MOUNTPOINTS |
| zram0 | [SWAP] | |||||
| vda | ||||||
| ├─vda1 | ||||||
| ├─vda2 | xfs | e6a828b0-d59e-42c0-a53f-852913eca2db | 479.8M | 50% | /boot | |
| └─vda3 | LVM2_member | LVM2 001 | jip0qB-X8OD-KVdQ-mjz5-Sv5G-0btk-HHjLaA | |||
| └─fedora_fedora-roo | xfs | 641957ce-39b6-4077-84a3-6e31b1d78e7d | 12.9G | 14% | / | |
| vdb | ||||||
| └─vdb1 |
Which of the following best describes the reason the filesystem fails to mount?
A. There is no filesystem created on the data drive.
B. The filesystem is using the wrong partition.
C. The data drive is missing LVM configuration.
D. The kernel lacks the correct filesystem definitions.
Question 8
A systems administrator is working on a firewall configuration and needs to deny all inbound connections except for the standard SSH port. Which of the following commands should the administrator use for this task? (Select two).
A. ufw proto tcp port 22
B. ufw reject all
C. ufw reject out
D. ufw deny all
E. ufw default deny incoming
F. ufw allow 22/tcp
Question 9
Regular users of a Linux server are reporting issues with updating their passwords. Given the following outputs:
$ passwd
Current password:
New password:
Retype new password:
passwd: Authentication token manipulation error
passwd: password unchanged
$ ls -l /usr/bin/passwd
-rwxr-xr-x 1 root root 59976 Nov 24 2023 /usr/bin/passwd
Which of the following commands should a server administrator use to fix this issue?
A. chmod u+s /usr/bin/passwd
B. chgrp users /usr/bin/passwd
C. chown 757 /usr/bin/passwd
D. export PATH=$PATH:/usr/bin
Question 10
A systems administrator is testing a new Java version on a server, which stores binaries in the /usr/lib/jvm/java-1.8.0-openjdk/jre/bin/ directory. However, when attempting to use the java command, the administrator receives the following output:
[user@comptia ~]$ java
-bash: java: command not found
The administrator then inspects the following output:
[user@comptia ~]$ which java
/usr/bin/which: no java in (/home/user/.local/bin:/home/user/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
[user@comptia ~]$ echo $PATH
/home/user/.local/bin:/home/user/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
Which of the following commands allows the administrator to use the newly installed java command only for the duration of the current session?
A. export PATH=$PATH:/usr/lib/jvm/java-1.8.0-openjdk/jre/bin/
B. cp /usr/lib/jvm/java-1.8.0-openjdk/jre/bin/ /usr/bin
C. ln -s /usr/lib/jvm/java-1.8.0-openjdk/jre/bin/ /home/user/bin
D. set java=/usr/lib/jvm/java-1.8.0-openjdk/jre/bin/java
Answer key
Question 1: D (git clone)
Question 10: A (export PATH=$PATH:/usr/lib/jvm/java-1.8.0-openjdk/jre/bin/)