LFCS
Free LFCS practice questions
10 questions from our LFCS practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Operations Deployment
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?
- AMove the setting to /etc/sysctl.conf so it is applied later in the boot sequence
- BAdd options br_netfilter enable=1 to a file in /etc/modprobe.d/ and run depmod -a
- CAdd bridge-nf-call-iptables=1 to the kernel command line with grubby on every kernel
- DAdd br_netfilter to a file in /etc/modules-load.d/ so the module loads at boot Correct answer
Answer and 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, Operations Deployment
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?
- AAdd --cap-add=NET_BIND_SERVICE to the podman run command so the container can bind port 80
- BAdd --privileged to the podman run command so the container gets all capabilities on the host
- CSet net.ipv4.ip_unprivileged_port_start = 80 in a file under /etc/sysctl.d/ and apply it Correct answer
- DRun setsebool -P container_manage_cgroup on so the rootless container can bind low ports
Answer and 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, Operations Deployment
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?
- ARun restorecon -Rv / outside the chroot so the shadow file keeps its old label
- BRun grub2-mkconfig -o /boot/grub2/grub.cfg so that rd.break is removed again
- CRun setenforce 0 inside the chroot so that the new password is accepted at boot
- DRun touch /.autorelabel inside the chroot so file contexts are restored at boot Correct answer
Answer and 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, Networking. 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.)
- Anmcli con add type bond ifname br0 con-name br0
- Bip link add br0 type veth peer name ens1
- Cnmcli con add type bridge ifname br0 con-name br0 Correct answer
- Dnmcli con add type ethernet slave-type bridge ifname ens1 master br0 Correct answer
- Enmcli dev connect br0 ifname ens1 type port
Answer and 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, Networking
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?
- ACreate a bridge br0, add ens1 as its port, move the host IP config to br0, and attach VMs to br0 Correct answer
- BKeep ens1 as is and attach VMs to the libvirt default network, which uses NAT on virbr0
- CCreate a VLAN ens1.10 on ens1 and attach the VMs to it while the host keeps ens1 for itself
- DCreate a bond bond0 with ens1 as its only port in active-backup mode and attach the VMs to it
Answer and 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, Storage
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?
- AUnmount it, run xfs_repair to compact the data, then run lvreduce -L 80G on the logical volume
- BBack up the data with xfsdump, recreate a smaller LV and XFS filesystem, then restore with xfsrestore Correct answer
- CUnmount it and run lvreduce -r -L 80G so LVM shrinks the XFS filesystem before reducing the LV
- DRun xfs_growfs -D with a smaller block count while it is mounted to shrink the data section first
Answer and 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, Storage
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?
- Apvremove -ff /dev/sdb, then vgreduce --removemissing vg_app afterwards
- Bpvmove /dev/sdb, then vgreduce vg_app /dev/sdb, then pvremove /dev/sdb Correct answer
- Cvgreduce vg_app /dev/sdb, then pvmove /dev/sdb, then pvremove /dev/sdb
- Dlvreduce -L -100G vg_app/lv_app, then vgreduce vg_app /dev/sdb afterwards
Answer and 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, Essential Commands
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?
- AAdd OnFailure=api.service to the [Unit] section, then run systemctl restart api.service to apply it
- BAdd Restart=on-failure to the [Service] section, then run systemctl daemon-reload and restart the service Correct answer
- CAdd Restart=always to the [Install] section, then run systemctl daemon-reload and restart the service
- DAdd RemainAfterExit=yes to the [Service] section, then run systemctl reenable api.service to apply it
Answer and 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, Essential Commands
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?
- AFilesystem metadata is corrupted; confirm by running fsck -n on the mounted /var device right away
- BThe filesystem has run out of inodes; confirm with df -i and remove many small files
- CA process still holds a deleted file open; list such files with lsof +L1 and restart that process Correct answer
- DReserved blocks for root fill the gap; confirm with tune2fs -l and lower them with -m 0
Answer and 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, Users and Groups. 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.)
- AAn export line in /etc/skel/.bash_profile for new accounts
- BA script such as /etc/profile.d/app.sh that exports APP_ENV Correct answer
- CA setting named APP_ENV in /etc/login.defs
- DAn export line in /root/.bashrc on the server
- EA line APP_ENV=prod in /etc/environment Correct answer
Answer and 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.