LPIC-1

Free LPIC-1 practice questions

10 questions from our LPIC-1 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.

Back to the LPIC-1 practice exams

Question 1 of 10, 101: System Architecture

A vendor's out-of-tree driver keeps loading automatically for a USB device, and the administrator wants the kernel to stop auto-loading the module named badwifi at boot. Which change is the standard way to do this?

  1. AAdd the module name to /etc/sysctl.conf with the value kernel.modules.badwifi=0
  2. BAdd the line 'blacklist badwifi' to a .conf file under /etc/modprobe.d/ Correct answer
  3. CAdd the line 'disable badwifi' to the file /etc/modules-load.d/badwifi.conf
  4. DDelete the badwifi entry from /proc/modules and then run the depmod -a command

Answer and explanation: A 'blacklist' directive in a file under /etc/modprobe.d/ stops modprobe and udev from loading the module automatically by its aliases. /etc/modules-load.d/ lists modules to load at boot and has no 'disable' keyword. /proc/modules is a read-only view of loaded modules, and depmod only rebuilds dependency data. sysctl sets kernel parameters, not module loading.

Question 2 of 10, 102: Linux Installation and Package Management

An administrator needs to extract a single configuration file from vendor.rpm to look at it without installing the package. Which pipeline does this?

  1. Arpm2cpio vendor.rpm | gunzip -dc
  2. Brpm2cpio vendor.rpm | cpio -idmv Correct answer
  3. Crpm -ivh --test vendor.rpm | tar -xvf -
  4. Drpm -qlp vendor.rpm | cpio -o

Answer and explanation: rpm2cpio converts the RPM payload into a cpio archive on stdout, and cpio -idmv extracts it into the current directory. rpm --test only checks whether installation would work, and its output is not an archive. gunzip cannot read the cpio stream that rpm2cpio produces. rpm -qlp lists file names, and cpio -o would create an archive rather than extract one.

Question 3 of 10, 103: GNU and Unix Commands

In Bash, which command creates the directories logs/2024, logs/2025 and logs/2026 in one step using brace expansion?

  1. Amkdir -p logs/{2024,2025,2026} Correct answer
  2. Bmkdir -p logs/20{24-26}
  3. Cmkdir -p logs/{2024..2026..2}
  4. Dmkdir -p logs/202[4-6]

Answer and explanation: Brace expansion with a comma list produces one word per item, so mkdir receives three paths. 202[4-6] is a glob that only matches names that already exist; otherwise mkdir creates a directory with that literal name. {2024..2026..2} is a sequence with a step of 2, which gives only 2024 and 2026. {24-26} is not a valid brace expression, so it stays literal and creates one directory called 20{24-26}.

Question 4 of 10, 103: GNU and Unix Commands

A configuration file must have every occurrence of 'http://' changed to 'https://', and the file must be changed in place. Which command does this?

  1. Ased -e 's|http://|https://|p' site.conf
  2. Bsed -i 's|http://|https://|g' site.conf Correct answer
  3. Csed 's|http://|https://|' site.conf > site.conf
  4. Dsed -n 's|http://|https://|g' site.conf

Answer and explanation: sed -i edits the file in place, the s command with the g flag replaces every match on each line, and | works as the delimiter so the slashes need no escaping. -n stops automatic printing and does not edit the file. Redirecting into the same file truncates it before sed reads it, and without g only the first match per line changes. The p flag only prints modified lines to stdout again.

Question 5 of 10, 104: Devices, Linux Filesystems, Filesystem Hierarchy Standard

Why does 'ln /home/user/file /mnt/usb/file' fail when /mnt/usb is a different filesystem from /home?

  1. AHard links can only be created by root on removable media
  2. BHard links cannot span filesystems, because inode numbers are per filesystem Correct answer
  3. CHard links to regular files are disabled by fs.protected_hardlinks
  4. DHard links need the -f option whenever the target directory is on removable media

Answer and explanation: A hard link points at an inode number, and inode numbers are only unique inside one filesystem, so ln reports an invalid cross-device link; a symlink (ln -s) is needed. Root has the same limitation. -f only removes an existing destination file. fs.protected_hardlinks limits linking to files you do not own; it does not block all links.

Question 6 of 10, 105: Shells and Shell Scripting

In a Bash script, which loop prints the numbers 1 to 5, one per line?

  1. Afor i in [1-5]; do echo "$i"; done
  2. Bfor i in $(seq 5 1); do echo "$i"; done
  3. Cwhile i in $(seq 1 5); do echo "$i"; done
  4. Dfor i in $(seq 1 5); do echo "$i"; done Correct answer

Answer and explanation: Command substitution runs seq 1 5, and the for loop goes over each number. [1-5] is a filename glob, which matches one-character file names from 1 to 5 in the current directory, or stays as the literal text if there are none. while takes a condition command and has no 'in' list. seq 5 1 prints nothing, because seq counts up by default and needs a negative step to count down.

Question 7 of 10, 107: Administrative Tasks

On a system where /etc/login.defs sets UID_MIN 1000, an administrator needs a system account for a daemon, with no home directory and no login shell. Which command fits best?

  1. Auseradd -r -M -s /usr/sbin/nologin svcmon Correct answer
  2. Buseradd -m -s /usr/sbin/nologin svcmon
  3. Cuseradd -r -m -s /bin/bash svcmon
  4. Duseradd -u 1000 -M -s /bin/false svcmon

Answer and explanation: -r creates a system account with a UID below UID_MIN (from the SYS_UID range), -M skips the home directory, and nologin prevents interactive logins. -m creates a home directory, and without -r the UID comes from the normal user range. /bin/bash gives the daemon account a real login shell. Forcing UID 1000 puts it in the regular user range and may clash with the first human user.

Question 8 of 10, 108: Essential System Services. Choose 2.

Which two statements about systemd-journald and rsyslog running on the same server are correct? (Choose two.)

  1. Ajournald writes plain text files, and rsyslog only stores binary data
  2. Bjournald can forward messages to rsyslog, which then writes text files in /var/log Correct answer
  3. Crsyslog can read the journal with its imjournal input module Correct answer
  4. DThe two services cannot run at once, because both bind to port 514
  5. Ersyslog replaces journald, so journalctl stops working when rsyslog runs

Answer and explanation: Many distributions run both: journald collects the messages, and rsyslog receives them through the syslog socket (ForwardToSyslog) or reads the journal with imjournal, then writes classic text logs. journald does not listen on port 514, and rsyslog only does when remote reception is set up. journalctl keeps working alongside rsyslog. The journal is binary, while rsyslog writes text.

Question 9 of 10, 109: Networking Fundamentals. Choose 2.

A user can ping the gateway 192.168.1.1 but not 8.8.8.8, and 'ip route' shows no default route. Which two commands, run as root, would restore outbound connectivity for the running system? (Choose two.)

  1. Aip link set 192.168.1.1 up
  2. Bip addr add default dev 192.168.1.1
  3. Cip route add default via 192.168.1.1 Correct answer
  4. Droute add default gw 192.168.1.1 Correct answer
  5. Eip neigh add default lladdr 192.168.1.1

Answer and explanation: Both ip route add default via and the legacy route add default gw add a default route through the gateway, which fixes traffic to other networks until the next reboot. ip addr add assigns interface addresses and does not accept 'default' in this way. ip link set works on interfaces, not IP addresses. ip neigh adds neighbour (ARP) entries, which do not create routes.

Question 10 of 10, 110: Security

During a security audit, an administrator must list every regular file on the system that has the SUID bit set. Which command does this?

  1. Afind / -type f -perm -1000 2>/dev/null
  2. Bfind / -type f -perm 0755 2>/dev/null
  3. Cfind / -type f -perm -4000 2>/dev/null Correct answer
  4. Dfind / -type f -user root -executable 2>/dev/null

Answer and explanation: -perm -4000 matches files where at least the SUID bit is set, and 2>/dev/null hides permission errors. 1000 is the sticky bit. -perm 0755 matches only files with exactly that mode. Listing root-owned executables includes normal programs and misses SUID files owned by other users.