# Free LFCS practice questions

> 10 free LFCS practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/lfcs-linux-administration/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/lfcs-linux-administration/

### Question 1 of 10

A host sets net.bridge.bridge-nf-call-iptables = 1 in /etc/sysctl.d/k8s.conf, but after each reboot the key is missing and sysctl reports it unknown until br_netfilter is loaded manually. What is the correct persistent fix?

- A. Move the setting to /etc/sysctl.conf so it is applied later in the boot sequence
- B. Add options br_netfilter enable=1 to a file in /etc/modprobe.d/ and run depmod -a
- C. Add bridge-nf-call-iptables=1 to the kernel command line with grubby on every kernel
- D. Add br_netfilter to a file in /etc/modules-load.d/ so the module loads at boot

**Answer:** D

**Explanation:** The key exists only after br_netfilter is loaded, and modules listed in modules-load.d are loaded early by systemd-modules-load, so the sysctl applies afterwards (systemd also reapplies settings for modules it loads). Moving the setting to another sysctl file does not load the module. The setting is not a kernel boot parameter. modprobe.d options apply only when something loads the module, and br_netfilter has no enable parameter.

### Question 2 of 10

A rootless Podman user runs podman run -p 80:8080 and gets a permission error binding host port 80. Policy allows unprivileged services to use ports from 80 upwards on this host. Which change fixes this persistently?

- A. Add --cap-add=NET_BIND_SERVICE to the podman run command so the container can bind port 80
- B. Add --privileged to the podman run command so the container gets all capabilities on the host
- C. Set net.ipv4.ip_unprivileged_port_start = 80 in a file under /etc/sysctl.d/ and apply it
- D. Run setsebool -P container_manage_cgroup on so the rootless container can bind low ports

**Answer:** C

**Explanation:** Unprivileged users cannot bind ports below net.ipv4.ip_unprivileged_port_start, which defaults to 1024, so lowering it to 80 lets the rootless port forwarder bind port 80. Capabilities granted to the container apply inside its user namespace and do not let the host-side process bind a privileged port. --privileged does not grant real host root rights to a rootless container. The cgroup boolean is unrelated to port binding.

### Question 3 of 10

You reset the root password of a RHEL 9 system by booting with rd.break, remounting /sysroot read-write, running chroot /sysroot and passwd. SELinux is enforcing. What must you do before rebooting so logins keep working?

- A. Run restorecon -Rv / outside the chroot so the shadow file keeps its old label
- B. Run grub2-mkconfig -o /boot/grub2/grub.cfg so that rd.break is removed again
- C. Run setenforce 0 inside the chroot so that the new password is accepted at boot
- D. Run touch /.autorelabel inside the chroot so file contexts are restored at boot

**Answer:** D

**Explanation:** passwd in the rescue environment rewrites /etc/shadow without a proper SELinux label, and /.autorelabel triggers a relabel on the next boot so authentication can read it. setenforce does nothing in the initramfs chroot and is not persistent. restorecon outside the chroot runs against the initramfs, not the real root. rd.break was added only for one boot from the GRUB editor, so regenerating grub.cfg is unnecessary.

### Question 4 of 10 (choose 2)

With NetworkManager you must create a bridge br0 and attach the Ethernet interface ens1 to it as a port. Which two commands do this? (Choose two.)

- A. nmcli con add type bond ifname br0 con-name br0
- B. ip link add br0 type veth peer name ens1
- C. nmcli con add type bridge ifname br0 con-name br0
- D. nmcli con add type ethernet slave-type bridge ifname ens1 master br0
- E. nmcli dev connect br0 ifname ens1 type port

**Answer:** C, D

**Explanation:** The first command creates the bridge profile, and adding an Ethernet profile for ens1 with slave-type bridge and master br0 makes it a bridge port (newer releases also accept port-type and controller as names for these properties). A bond is a different device type. nmcli dev connect takes only a device name. ip link with veth creates a virtual pair, is not persistent and would collide with the existing ens1.

### Question 5 of 10

Virtual machines on a host must be attached directly to the physical LAN through ens1 so they get addresses from the LAN DHCP server. The host itself must keep network access. Which NetworkManager setup fits?

- A. Create a bridge br0, add ens1 as its port, move the host IP config to br0, and attach VMs to br0
- B. Keep ens1 as is and attach VMs to the libvirt default network, which uses NAT on virbr0
- C. Create a VLAN ens1.10 on ens1 and attach the VMs to it while the host keeps ens1 for itself
- D. Create a bond bond0 with ens1 as its only port in active-backup mode and attach the VMs to it

**Answer:** A

**Explanation:** A Linux bridge with the physical NIC as a port forwards frames between VMs and the LAN, and the host keeps connectivity through the bridge interface. A one-port bond provides no switching for guests. The libvirt default network NATs guests behind the host, so they do not get LAN DHCP addresses. A VLAN interface tags traffic but is not a switch for VMs.

### Question 6 of 10

An XFS filesystem on an LVM logical volume is 200 GiB, but only 30 GiB is used. You need to return 120 GiB to the volume group. What is the supported way to do this?

- A. Unmount it, run xfs_repair to compact the data, then run lvreduce -L 80G on the logical volume
- B. Back up the data with xfsdump, recreate a smaller LV and XFS filesystem, then restore with xfsrestore
- C. Unmount it and run lvreduce -r -L 80G so LVM shrinks the XFS filesystem before reducing the LV
- D. Run xfs_growfs -D with a smaller block count while it is mounted to shrink the data section first

**Answer:** B

**Explanation:** XFS has no general shrink support: it can be grown, and the experimental shrink in recent kernels only removes unused space at the end of the last allocation group. The supported way is to back up, recreate the LV and filesystem at the smaller size, and restore. lvreduce -r fails because no XFS shrink tool is available for this. xfs_growfs cannot remove whole allocation groups to give back 120 GiB. xfs_repair does not compact data, and reducing the LV under XFS destroys the filesystem.

### Question 7 of 10

Disk /dev/sdb in volume group vg_app is failing. The VG has enough free extents on other PVs to hold its data. You must remove the disk without downtime. Which sequence is correct?

- A. pvremove -ff /dev/sdb, then vgreduce --removemissing vg_app afterwards
- B. pvmove /dev/sdb, then vgreduce vg_app /dev/sdb, then pvremove /dev/sdb
- C. vgreduce vg_app /dev/sdb, then pvmove /dev/sdb, then pvremove /dev/sdb
- D. lvreduce -L -100G vg_app/lv_app, then vgreduce vg_app /dev/sdb afterwards

**Answer:** B

**Explanation:** pvmove migrates all allocated extents off the PV while volumes stay online, after which vgreduce removes it from the VG and pvremove wipes the label. vgreduce refuses to remove a PV that still holds data. Forcing pvremove loses the data on that disk. Shrinking a logical volume risks the filesystem and does not guarantee the extents left /dev/sdb.

### Question 8 of 10

A custom unit /etc/systemd/system/api.service must be restarted automatically whenever its process exits with an error, but not when it is stopped cleanly. What should you do?

- A. Add OnFailure=api.service to the [Unit] section, then run systemctl restart api.service to apply it
- B. Add Restart=on-failure to the [Service] section, then run systemctl daemon-reload and restart the service
- C. Add Restart=always to the [Install] section, then run systemctl daemon-reload and restart the service
- D. Add RemainAfterExit=yes to the [Service] section, then run systemctl reenable api.service to apply it

**Answer:** B

**Explanation:** Restart=on-failure restarts the service on non-zero exit codes, signals and timeouts but not on a clean exit, and daemon-reload makes systemd read the changed file. Restart belongs in [Service], and always would also restart after clean exits. RemainAfterExit only marks a oneshot as active after it exits. OnFailure activates other units and pointing it at itself is not how restarts are configured.

### Question 9 of 10

df reports that /var is 100% full, but du -sh /var shows only half of its size in use. No other filesystems are mounted below /var. What is the most likely cause and how do you confirm it?

- A. Filesystem metadata is corrupted; confirm by running fsck -n on the mounted /var device right away
- B. The filesystem has run out of inodes; confirm with df -i and remove many small files
- C. A process still holds a deleted file open; list such files with lsof +L1 and restart that process
- D. Reserved blocks for root fill the gap; confirm with tune2fs -l and lower them with -m 0

**Answer:** C

**Explanation:** Space of a deleted file is freed only when the last open handle closes, so df counts it while du cannot see it; lsof +L1 lists open files with a link count of zero. Inode exhaustion makes df -i full but does not cause a block gap between df and du. Reserved blocks are a few percent, not half. Corruption is far less likely and fsck on a mounted filesystem is unreliable.

### Question 10 of 10 (choose 2)

A variable APP_ENV=prod must be set for every user at login, including users created in the future. Which two locations are appropriate? (Choose two.)

- A. An export line in /etc/skel/.bash_profile for new accounts
- B. A script such as /etc/profile.d/app.sh that exports APP_ENV
- C. A setting named APP_ENV in /etc/login.defs
- D. An export line in /root/.bashrc on the server
- E. A line APP_ENV=prod in /etc/environment

**Answer:** B, E

**Explanation:** Login shells source every script in /etc/profile.d/, and pam_env reads /etc/environment for all sessions, so both apply to every user. Files in /etc/skel are copied only into new home directories, so existing users are missed. /root/.bashrc affects only root. login.defs holds shadow suite settings and does not define environment variables.

Ready for a timed run? Take the free 15-question LFCS mini exam: https://devopscodelab.com/app/exams/lfcs-linux-administration/mini/

DevOpsCode Lab is not affiliated with Linux Foundation. LFCS and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
