All Linux Foundation / CNCF exams
Free LFCS practice test: 30 questions with answers
30 original questions for Linux Foundation Certified System Administrator, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
All 30 LFCS questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Essential Commands (6 questions)
Question 1
An administrator needs the disk space used by each directory under /srv, shown in human-readable sizes and summarized per directory. Which command should be used?
- Alsblk /srv
- Bdf -h /srv
- Cls -lh /srv
- Ddu -sh /srv/*
Show answer and explanationHide answer
Correct answer: Ddu -sh with a glob reports the total size of each item in human-readable form. df reports filesystem free space rather than per-directory usage, ls -lh shows file sizes without totals, and lsblk lists block devices.
Question 2
Which command finds regular files under /var/log that were modified within the last 24 hours?
- Agrep -mtime 1 /var/log
- Blocate -t 1d /var/log
- Cls --recent /var/log
- Dfind /var/log -type f -mtime -1
Show answer and explanationHide answer
Correct answer: Dfind with -type f and -mtime -1 selects regular files modified in the last day. locate uses a prebuilt database and does not filter by modification time, grep searches file contents, and ls has no recent option.
Question 3
Which two commands display the contents of a text file to the terminal without opening an editor? (Choose two.)
- Amkdir
- Bchmod
- Ccat
- Dless
- Etouch
Show answer and explanationHide answer
Correct answer: C, Dcat prints the whole file and less pages through it, and both read the file without modifying it. touch changes timestamps or creates empty files, mkdir creates directories, and chmod changes permissions.
Question 4
Which command creates a symbolic link named current in the working directory that points to /opt/app-2.3?
- Amklink current /opt/app-2.3
- Bln /opt/app-2.3 current
- Cln -s /opt/app-2.3 current
- Dcp -s /opt/app-2.3 current
Show answer and explanationHide answer
Correct answer: Cln -s creates a symbolic link, and the first argument is the target while the second is the link name. A plain ln creates a hard link, which cannot point to a directory, cp -s is not a link command, and mklink is a Windows command.
Question 5
A pipeline should list each distinct line of a file ordered from most to least frequent. Which command sequence does this?
- Acut -d' ' -f1 file | count
- Buniq -c file
- Csort file | uniq -c | sort -rn
- Dwc -u file
Show answer and explanationHide answer
Correct answer: Cuniq only collapses adjacent duplicates, so the input must be sorted first, and uniq -c adds counts before a reverse numeric sort orders by frequency. The other pipelines skip the sort or use commands that do not exist.
Question 6
A file must have owner read, write and execute, group read and execute, and no permissions for others. Which numeric mode represents this?
- A755
- B700
- C640
- D750
Show answer and explanationHide answer
Correct answer: DOwner rwx is 7, group r-x is 5, and others --- is 0, which gives 750. 755 gives others read and execute, 640 removes execute for the owner and group, and 700 removes all group access.
Operation of Running Systems (6 questions)
Question 7
An administrator needs to check whether the nginx service starts automatically at boot. Which command answers this?
- Asystemctl boot-status nginx
- Bsystemctl is-enabled nginx
- Csystemd-analyze check nginx
- Dsystemctl list-boot nginx
Show answer and explanationHide answer
Correct answer: Bsystemctl is-enabled reports whether a unit is enabled to start at boot. The other options are not systemctl subcommands for this purpose, and systemd-analyze check validates unit file syntax.
Question 8
A process ignores SIGTERM and must be stopped immediately. Which signal should be sent, and why can the process not ignore it?
- ASIGQUIT, because it writes a core dump and then continues
- BSIGHUP, because it always stops a process
- CSIGKILL, because the kernel terminates the process and it cannot be caught
- DSIGINT, because it is sent only by the kernel
Show answer and explanationHide answer
Correct answer: CSIGKILL cannot be caught, blocked or ignored, so the kernel terminates the process. SIGHUP, SIGINT and SIGQUIT can be caught or ignored by a process, so they do not guarantee termination.
Question 9
Which two commands show running processes ordered by CPU usage? (Choose two.)
- Aps aux --sort=pid
- Bdf -h
- Cfree -m
- Dtop
- Eps aux --sort=-%cpu
Show answer and explanationHide answer
Correct answer: D, Etop shows live processes sorted by CPU by default, and ps with --sort=-%cpu prints a static list ordered from highest CPU use. Sorting by PID does not order by CPU, and df and free report disk and memory.
Question 10
An administrator wants only the journal entries from the current boot. Which journalctl option provides this?
- Ajournalctl --last-boot-only
- Bjournalctl -t boot
- Cjournalctl -b
- Djournalctl -l
Show answer and explanationHide answer
Correct answer: Cjournalctl -b limits output to the current boot, and -b with an offset selects other boots. The other options are not valid selectors for the current boot.
Question 11
A backup script must run every weekday at 06:30. Which crontab entry does this?
- A6 30 * * 1-5 /usr/local/bin/backup.sh
- B30 6 * * 0-6 /usr/local/bin/backup.sh
- C30 6 1-5 * * /usr/local/bin/backup.sh
- D30 6 * * 1-5 /usr/local/bin/backup.sh
Show answer and explanationHide answer
Correct answer: DCron fields are minute, hour, day of month, month and day of week, so 30 6 * * 1-5 runs at 06:30 Monday to Friday. The other entries reverse the time, run every day, or select days of the month instead.
Question 12
A service should restart automatically whenever its process exits with a failure. Which unit file setting achieves this?
- AKeepAlive=always
- BAutoRestart=yes
- CRestart=on-failure
- DRestartOnCrash=true
Show answer and explanationHide answer
Correct answer: CRestart=on-failure in the [Service] section restarts the service when it exits abnormally. The other keys are not systemd unit directives.
Networking (6 questions)
Question 13
Which command lists the TCP sockets that are listening, with the numeric ports and the owning process?
- Aping -l
- Bss -tlnp
- Cifconfig -t
- Droute -t
Show answer and explanationHide answer
Correct answer: Bss -tlnp shows listening TCP sockets with numeric addresses and process information when run with sufficient privilege. ifconfig and route do not show listening sockets, and ping -l sets a preload count rather than listing sockets.
Question 14
Which file maps hostnames to IP addresses locally, and is consulted before DNS for lookups that the files source covers?
- A/etc/hosts
- B/etc/resolv.conf
- C/etc/services
- D/etc/nsswitch.conf
Show answer and explanationHide answer
Correct answer: A/etc/hosts provides static name-to-address mappings used by the resolver depending on the lookup order. resolv.conf defines DNS servers, services maps port names to numbers, and nsswitch.conf sets the lookup order rather than the mappings.
Question 15
An administrator needs to add the address 192.168.50.10/24 to interface eth1 immediately, without making it persistent. Which command should be used?
- Aip addr add 192.168.50.10/24 dev eth1
- Broute add eth1 192.168.50.10
- Cifconfig eth1 /24 192.168.50.10 persist
- Dip addr set eth1 192.168.50.10
Show answer and explanationHide answer
Correct answer: Aip addr add assigns an address to an interface until reboot or until it is removed. The other options use invalid syntax, and route add does not configure an interface address.
Question 16
On an Ubuntu host with ufw, which command allows inbound SSH using the application profile?
- Aufw allow OpenSSH
- Biptables -A SSH allow
- Cufw enable ssh only
- Dufw open 22/ssh
Show answer and explanationHide answer
Correct answer: Aufw allow OpenSSH uses the application profile that ufw ships for SSH, which is the simplest correct rule. ufw open and ufw enable ssh only are not valid ufw syntax, and iptables -A SSH uses a chain name that does not exist.
Question 17
An administrator wants to see the route each hop takes to example.org along with latency at each step. Which tool does this?
- Aping -c 1 example.org
- Bnc -z example.org 80
- Cdig example.org
- Dtraceroute example.org
Show answer and explanationHide answer
Correct answer: Dtraceroute reports each hop between the host and the destination with its round-trip time. dig queries DNS records, ping -c 1 sends one echo request, and nc -z tests whether a port is open.
Question 18
Which two commands help check DNS resolution for a name? (Choose two.)
- Adig example.org
- Bhost example.org
- Cip route show
- Dssh-keygen -l
- Enmcli dev status
Show answer and explanationHide answer
Correct answer: A, Bdig and host query DNS servers and show the records returned for a name. ip route show lists routing table entries, ssh-keygen -l prints key fingerprints, and nmcli dev status shows device state rather than name lookups.
User and Group Management (6 questions)
Question 19
The user dev must join the docker group while keeping the existing supplementary groups. Which command does this?
- Auseradd -g docker dev
- Busermod -G docker dev
- Cusermod -aG docker dev
- Dgroupadd dev docker
Show answer and explanationHide answer
Correct answer: Cusermod -aG appends the group to the supplementary list, which keeps the existing memberships. Omitting -a replaces the whole list, groupadd creates a group rather than adding a user, and useradd -g changes the primary group when the account is created.
Question 20
Which file stores the hashed passwords for local user accounts?
- A/etc/group
- B/etc/shadow
- C/etc/passwd
- D/etc/gshadow
Show answer and explanationHide answer
Correct answer: B/etc/shadow stores password hashes and aging data, readable only by root. /etc/passwd holds account fields, /etc/group holds group membership, and /etc/gshadow holds group password data.
Question 21
An administrator needs to view the password aging details for the account alice, such as the last change date and the expiry date. Which command shows this?
- Achage -l alice
- Bgroups alice
- Cpasswd --expire alice
- Did alice
Show answer and explanationHide answer
Correct answer: Achage -l lists the password aging information for an account. passwd --expire forces a password change, and id and groups show identity and group membership rather than aging data.
Question 22
Which two sudo practices are recommended? (Choose two.)
- AGrant only the specific commands a user needs
- BEdit /etc/sudoers directly with a plain text editor
- CSet NOPASSWD ALL for every account
- DStore sudo passwords in /etc/motd
- EEdit sudo rules with visudo
Show answer and explanationHide answer
Correct answer: A, Evisudo checks the sudoers syntax before saving, which prevents lockouts, and narrow command grants follow least privilege. A plain editor risks syntax errors, blanket NOPASSWD grants weaken control, and storing passwords in a message file is unsafe.
Question 23
The account tom must be locked so that password logins are disabled, without deleting the account. Which command does this?
- Auserdel -L tom
- Bgroupmod -L tom
- Cusermod -L tom
- Dusermod -e tom
Show answer and explanationHide answer
Correct answer: Cusermod -L locks the password by prefixing the stored hash with an invalid character, which blocks password login. -e sets an expiry date rather than locking, and userdel and groupmod do not lock user passwords.
Question 24
A new user carol needs a home directory and should be a member of the analysts group as a supplementary group. Which command does this?
- Auseradd -m -G analysts carol
- Bnewuser -m carol analysts
- Cuseradd -G analysts carol --no-home-group
- Duseradd -m -g analysts carol
Show answer and explanationHide answer
Correct answer: Auseradd -m creates the home directory and -G adds the supplementary group. -g would make analysts the primary group, and newuser and the last option are not valid account creation commands with these arguments.
Storage Management (6 questions)
Question 25
An administrator needs a tree view of disks, partitions and their mount points. Which command provides it?
- Alsblk
- Bfdisk -l /dev/sda
- Cdu -h /
- Dblkid -t
Show answer and explanationHide answer
Correct answer: Alsblk prints block devices as a tree with sizes and mount points. blkid shows filesystem identifiers, fdisk -l lists partition tables without the mount tree, and du reports directory sizes.
Question 26
A new partition /dev/sdb1 must be formatted with the ext4 filesystem. Which command should be used?
- Amkfs -t ext5 /dev/sdb1
- Bmkfs.ext4 /dev/sdb1
- Cfsck.ext4 /dev/sdb1
- Dtune2fs -c /dev/sdb1
Show answer and explanationHide answer
Correct answer: Bmkfs.ext4 creates an ext4 filesystem on the partition, which destroys existing data on it. fsck checks a filesystem, tune2fs adjusts its parameters, and ext5 is not a Linux filesystem type.
Question 27
A filesystem must mount automatically at boot using a stable identifier rather than a device name. Which change achieves this?
- ACreate a file named /dev/fstab
- BAdd an /etc/fstab entry that references the filesystem UUID with the mount options
- CAdd the device to /etc/mtab
- DAdd the device name to /etc/hostname
Show answer and explanationHide answer
Correct answer: B/etc/fstab defines persistent mounts, and a UUID stays the same even if device names change. /etc/mtab records current mounts and is managed by the system, /etc/hostname holds the host name, and /dev/fstab is not used.
Question 28
An administrator needs a 20 GB logical volume named data in the volume group vg0. Which command creates it?
- Alvcreate -L 20G -n data vg0
- Blvcreate -n vg0 20G data
- Cvgcreate -L 20G data vg0
- Dpvcreate -L 20G data
Show answer and explanationHide answer
Correct answer: Alvcreate with -L sets the size, -n sets the name, and the volume group comes last. The other arguments are in the wrong order, and vgcreate and pvcreate create volume groups and physical volumes rather than logical volumes.
Question 29
Which two steps are part of creating a software RAID 1 array with mdadm? (Choose two.)
- Alvextend /dev/md0
- Bmdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
- Cmdadm --detail --scan >> /etc/mdadm.conf
- Dmkfs.xfs /dev/sdb
- Emount /dev/sdc /mnt
Show answer and explanationHide answer
Correct answer: B, Cmdadm --create builds the mirrored array from two devices, and recording the scan output in mdadm.conf keeps the array assembled at boot. Formatting, mounting and extending a logical volume are later steps, not part of creating the RAID array.
Question 30
After the logical volume holding an ext4 filesystem was extended, the filesystem must grow to use the new space. Which command does this?
- Afsck -y /dev/vg0/data
- Btune2fs -r /dev/vg0/data
- Cxfs_growfs /dev/vg0/data
- Dresize2fs /dev/vg0/data
Show answer and explanationHide answer
Correct answer: Dresize2fs grows an ext4 filesystem to fill its device after the volume has been extended. xfs_growfs applies to XFS, tune2fs -r changes reserved blocks, and fsck checks rather than grows the filesystem.