LPI Linux Essentials Exam — Questions and Answers
Question 1: A shell script contains the following lines: MY_VAR="Linux System" echo "I am learning about the '$MY_VAR'" echo "I am learning about the \"$MY_VAR\"" What is the output when this script is executed?
- I am learning about the 'Linux System' I am learning about the "$MY_VAR"
- I am learning about the '$MY_VAR' I am learning about the "$MY_VAR"
- I am learning about the '$MY_VAR' I am learning about the "Linux System" (Correct answer)
- I am learning about the 'Linux System' I am learning about the "Linux System"
Correct answer: I am learning about the '$MY_VAR' I am learning about the "Linux System"
Single quotes (') prevent any kind of expansion, so '$MY_VAR' is printed literally. Double quotes (") allow for variable expansion, so "$MY_VAR" is replaced with its value, "Linux System". The backslashes before the inner double quotes are necessary to escape them so they are printed as literal characters.
Question 2: What does the `continue` statement do inside a bash loop?
- Restarts the loop from the beginning
- Skips the rest of the current iteration and starts the next one (Correct answer)
- Exits the entire loop
- Exits the script
Correct answer: Skips the rest of the current iteration and starts the next one
`continue` jumps back to the loop condition check, skipping the remaining commands in the current iteration.
Question 3: The Free Software Foundation (FSF) defines four essential freedoms for free software. Which of the following is NOT one of those freedoms?
- The freedom to redistribute copies to help others.
- The freedom from any cost associated with the software. (Correct answer)
- The freedom to run the program for any purpose.
- The freedom to study how the program works and change it.
Correct answer: The freedom from any cost associated with the software.
The FSF's definition of free software focuses on liberty, not price. It defines free software by four essential freedoms: the freedom to run the program, to study and change it, to redistribute copies, and to distribute copies of your modified versions. Free software can be sold.
Question 4: A user runs the `umask 0027` command. What will the default permissions be for a newly created directory afterwards?
- drwxrwxrwx
- drwxr-xrwx
- drw-r-----
- drwxr-x--- (Correct answer)
Correct answer: drwxr-x---
The system starts with default permissions for a directory, which is 777 (`rwxrwxrwx`). The `umask` value is subtracted from this default. 777 - 027 results in 750. This octal value corresponds to `rwxr-x---`.
Question 5: Which flag tells tar to use xz compression when creating an archive?
- -x
- -J (Correct answer)
- -j
- -z
Correct answer: -J
The uppercase -J flag selects xz compression, while lowercase -j selects bzip2 and -z selects gzip.
Question 6: An administrator wants to add an existing user, 'sara', to the supplementary group 'developers'. Which of the following commands is the correct and safest way to do this without affecting her current group memberships?
- usermod -G developers sara
- usermod -a -G developers sara (Correct answer)
- usermod -g developers sara
- groupmod -a -m developers sara
Correct answer: usermod -a -G developers sara
The `usermod` command modifies a user's account. The `-G` option is used to specify a list of supplementary groups. Crucially, the `-a` (append) option must be used with `-G` to add the user to the new group without removing them from their existing supplementary groups.
Question 7: Which directory in a Linux system typically contains device files for hardware devices?
- /hardware
- /proc/devices
- /sys
- /dev (Correct answer)
Correct answer: /dev
/dev contains device files (special files) that represent hardware devices such as disks, terminals, and printers.
Question 8: Which command displays a dynamic, real-time view of running processes on a Linux system?
- top (Correct answer)
- pstree
- jobs
- ps
Correct answer: top
The `top` command provides an interactive, continuously updated display of system processes and resource usage.
Question 9: What is the significance of the year 2007 for the GPL?
- GNU GPL version 3 was released, adding provisions for patents and Tivoization (Correct answer)
- The FSF was founded and released the first GPL
- The Linux kernel switched from GPLv2 to GPLv3
- The original GPL was first published
Correct answer: GNU GPL version 3 was released, adding provisions for patents and Tivoization
GPL version 3 was released in 2007, addressing issues like software patents, Tivoization (hardware restrictions), and compatibility with other licenses.
Question 10: Which grep option makes the search case-insensitive?
- -v
- -i (Correct answer)
- -n
- -c
Correct answer: -i
The -i option tells grep to ignore case differences when matching patterns.
Question 11: Which command shows compression statistics like compressed size, original size, and ratio for a .gz file?
- gzip -v file.gz
- gzip -t file.gz
- gzip -l file.gz (Correct answer)
- gzip -s file.gz
Correct answer: gzip -l file.gz
The -l (list) option displays compression statistics including compressed size, uncompressed size, and compression ratio.
Question 12: What does `uniq` do by default when given sorted input?
- Counts all unique words
- Reverses the order of lines
- Removes consecutive duplicate lines (Correct answer)
- Sorts the lines alphabetically
Correct answer: Removes consecutive duplicate lines
uniq removes consecutive duplicate lines, so input should be sorted first to eliminate all duplicates.
Question 13: Which shell built-in command displays the value of a variable named MYVAR?
- print MYVAR
- show $MYVAR
- display MYVAR
- echo $MYVAR (Correct answer)
Correct answer: echo $MYVAR
The echo command followed by the variable name prefixed with $ displays its value.
Question 14: Which command displays the first 5 lines of a file named data.csv?
- first 5 data.csv
- top 5 data.csv
- cat -5 data.csv
- head -5 data.csv (Correct answer)
Correct answer: head -5 data.csv
head -n N (or the shorthand head -N) prints the first N lines of a file.
Question 15: Which command extracts only a specific file from a tar archive?
- tar -xf archive.tar path/to/file.txt (Correct answer)
- tar -xf archive.tar --only file.txt
- tar -sf archive.tar file.txt
- tar -ef archive.tar file.txt
Correct answer: tar -xf archive.tar path/to/file.txt
You can specify one or more filenames after the archive name with tar -xf to extract only those specific files.
Question 16: Which command shows how long the Linux system has been running since its last boot?
- uptime (Correct answer)
- systime
- boot
- runtime
Correct answer: uptime
The `uptime` command displays the current time, how long the system has been running, the number of logged-in users, and load averages.
Question 17: What is a relative path?
- A path that always starts with a forward slash
- A path stored in an environment variable
- A path that uses the ~ shortcut
- A path described in relation to the current working directory (Correct answer)
Correct answer: A path described in relation to the current working directory
A relative path does not start with `/` and is interpreted relative to the current working directory (e.g., `docs/report.txt`).
Question 18: A system administrator needs to gather detailed information about the CPU architecture, such as the number of cores, threads per core, and CPU family. Which command provides a comprehensive, human-readable summary of this information?
- cat /proc/cpuinfo
- uname -p
- lscpu (Correct answer)
- dmesg | grep CPU
Correct answer: lscpu
The `lscpu` command gathers CPU architecture information from sysfs and /proc/cpuinfo and displays it in an easy-to-read, summarized format. While `cat /proc/cpuinfo` contains the raw data, `lscpu` organizes it more clearly. `uname -p` only shows the processor architecture type, and `dmesg` shows kernel messages, which may include CPU information at boot, but it is not its primary purpose to provide a clean summary.
Question 19: What does `tail -f /var/log/syslog` do?
- Follows the file and prints new lines as they are written (Correct answer)
- Shows the first 10 lines and exits
- Shows lines in reverse order
- Filters lines matching 'syslog'
Correct answer: Follows the file and prints new lines as they are written
tail -f follows a file in real time, printing new content as it is appended.
Question 20: Which command lists all currently running processes for all users in a detailed format?
- ls -la
- ps aux (Correct answer)
- top -a
- jobs -l
Correct answer: ps aux
The `ps aux` command shows all processes from all users with detailed information including CPU and memory usage.
Question 21: What does the command wc -l file.txt report?
- File size in bytes
- Line count (Correct answer)
- Word count
- Character count
Correct answer: Line count
wc -l counts the number of newline characters, effectively reporting the number of lines.
Question 22: How can you allow a user to run only the `reboot` command with sudo without a password?
- Add 'username ALL=(ALL) NOPASSWD: /sbin/reboot' to /etc/sudoers (Correct answer)
- Add username to the 'reboot' group
- Add 'username reboot' to /etc/security/access.conf
- Run 'chmod u+s /sbin/reboot'
Correct answer: Add 'username ALL=(ALL) NOPASSWD: /sbin/reboot' to /etc/sudoers
A NOPASSWD rule in /etc/sudoers grants passwordless sudo access to a specific command.
Question 23: What is the purpose of the /etc/group file?
- Maps group names to GIDs and lists group members (Correct answer)
- Stores encrypted group passwords only
- Defines default permissions for new groups
- Controls which groups can use sudo
Correct answer: Maps group names to GIDs and lists group members
/etc/group maps group names to GIDs and lists the supplementary members of each group.
Question 24: What does 'cd' with no arguments do in bash?
- Returns an error
- Displays the current directory
- Changes to the home directory (Correct answer)
- Changes to the root directory
Correct answer: Changes to the home directory
Running `cd` without arguments is equivalent to `cd ~` and takes you to the current user's home directory.
Question 25: What does the tilde (~) represent in a Linux shell?
- The root directory
- The parent directory
- The current user's home directory (Correct answer)
- The last visited directory
Correct answer: The current user's home directory
In bash and most Linux shells, `~` expands to the current user's home directory (e.g., /home/alice).
Question 26: Which command shows USB devices currently connected to the system?
- devlist --usb
- cat /proc/usb
- lsusb (Correct answer)
- usbscan
Correct answer: lsusb
lsusb lists USB buses and the devices connected to them, displaying vendor/product IDs and descriptions.
Question 27: Which signal sent by `kill` gracefully requests a process to terminate, allowing cleanup?
- SIGKILL (9)
- SIGINT (2)
- SIGHUP (1)
- SIGTERM (15) (Correct answer)
Correct answer: SIGTERM (15)
SIGTERM (signal 15) is the default signal sent by `kill`, asking the process to terminate gracefully and perform cleanup operations.
Question 28: What is the primary purpose of the `#!/bin/bash` line at the beginning of a shell script?
- It is a comment indicating the script's version number.
- It specifies the absolute path to the interpreter that should execute the script. (Correct answer)
- It pre-loads all environment variables from the user's .bashrc file.
- It sets the script's permissions to be executable by default.
Correct answer: It specifies the absolute path to the interpreter that should execute the script.
This line, known as a 'shebang', is an interpreter directive. It tells the operating system's program loader which program (in this case, `/bin/bash`) should be used to run the commands contained in the script.
Question 29: Which field in /etc/passwd specifies the user's default shell?
- Field 7 (Correct answer)
- Field 4
- Field 5
- Field 6
Correct answer: Field 7
The seventh (last) field in /etc/passwd specifies the user's login shell, e.g., /bin/bash.
Question 30: Which of the following Creative Commons licenses allows others to distribute, remix, and build upon your work, even commercially, as long as they credit you?
- CC BY-SA
- CC BY-NC
- CC BY-ND
- CC BY (Correct answer)
Correct answer: CC BY
The CC BY (Attribution) license is the most permissive Creative Commons license, permitting any use including commercial, provided attribution is given.
Question 31: Which octal value sets the sticky bit on a directory along with permissions 755?
- 2755
- 3755
- 1755 (Correct answer)
- 4755
Correct answer: 1755
The sticky bit is represented by the leading octal digit 1, so 1755 = sticky + rwxr-xr-x.
Question 32: Which command would you use to see the password aging information for a user?
- chage -l username (Correct answer)
- id --age username
- passwd -S username
- usermod -l username
Correct answer: chage -l username
chage -l displays the password aging details including last change date, expiry date, and inactivity period.
Question 33: What is the result of running `bzip2 -d file.txt.bz2`?
- Decompresses to file.txt and keeps file.txt.bz2
- Decompresses to file.txt and removes file.txt.bz2 (Correct answer)
- Creates file.txt.bz2.d
- Outputs decompressed content to stdout
Correct answer: Decompresses to file.txt and removes file.txt.bz2
By default, bzip2 -d removes the compressed file and replaces it with the decompressed version.
Question 34: What is the purpose of swap space in a Linux system?
- Act as virtual memory when RAM is full (Correct answer)
- Store temporary files created during compilation
- Cache frequently accessed disk blocks
- Temporarily store files being transferred between drives
Correct answer: Act as virtual memory when RAM is full
Swap space is used as virtual memory, allowing the system to move inactive memory pages to disk when physical RAM is exhausted.
Question 35: What will `echo ${#name}` print if `name="Linux"`?
- Linux
- name
- 0
- 5 (Correct answer)
Correct answer: 5
The `${#var}` expansion returns the length in characters of the variable's value.
Question 36: What does the `grep -l 'error' *.log` command output?
- Only the names of .log files that contain 'error' (Correct answer)
- Lines not containing 'error' in .log files
- The count of matches in each .log file
- Every matching line from all .log files
Correct answer: Only the names of .log files that contain 'error'
grep -l prints only the filenames of files that contain at least one match, not the matching lines.
Question 37: Which useradd option specifies a comment (typically the user's full name) for the account?
- -c (Correct answer)
- -n
- -m
- -d
Correct answer: -c
The -c option sets the GECOS comment field in /etc/passwd, which traditionally stores the user's full name.
Question 38: A user is currently in the `/home/user/documents` directory. Which of the following commands will change the current directory to the `/home/user` directory?
- cd /
- cd ~/
- cd .. (Correct answer)
- cd documents
Correct answer: cd ..
The `..` represents the parent directory. From `/home/user/documents`, the parent directory is `/home/user`. Therefore, `cd ..` will navigate one level up to the desired directory.
Question 39: What happens when you use 'chmod = r file.txt' (symbolic assignment)?
- Sets file to read-only for the owner only
- Removes read permission for all
- Sets read permission for all; clears write and execute for all (Correct answer)
- Adds read permission without changing others
Correct answer: Sets read permission for all; clears write and execute for all
Using '=' with no class prefix applies to all classes and sets exactly those permissions, clearing all others.
Question 40: Which license is commonly used by the Linux kernel?
- BSD 2-Clause License
- GNU General Public License version 2 (GPLv2) (Correct answer)
- MIT License
- Apache License 2.0
Correct answer: GNU General Public License version 2 (GPLv2)
The Linux kernel is licensed under the GNU General Public License version 2 (GPLv2), a strong copyleft license.
LPI Linux Essentials Exam
The LPI Linux Essentials Exam (010-160) validates foundational Linux knowledge including open-source concepts, command-line navigation, data extraction, archiving, user management, file permissions, basic scripting, hardware awareness, process monitoring, and networking basics.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds