LPI Linux Essentials Exam — Questions and Answers
Question 1: What is a primary difference between the Apache 2.0 license and the MIT license?
- The MIT license requires you to publish all modifications.
- The Apache 2.0 license includes an express grant of patent rights, while the MIT license does not. (Correct answer)
- The Apache 2.0 license prohibits commercial use.
- The MIT license is a copyleft license, while Apache 2.0 is not.
Correct answer: The Apache 2.0 license includes an express grant of patent rights, while the MIT license does not.
A key feature of the Apache 2.0 license is that it includes an explicit grant of patent rights from contributors to users. The MIT license is much simpler and does not explicitly address patent rights, which is a key reason some projects and corporations prefer the Apache license.
Question 2: Which file defines which users and groups can use sudo?
- /etc/sudo.conf
- /etc/pam.d/sudo
- /etc/security/sudo
- /etc/sudoers (Correct answer)
Correct answer: /etc/sudoers
/etc/sudoers (edited safely with visudo) controls sudo access policies.
Question 3: Which file would you read to find the Linux kernel version currently running on a system?
- /boot/kernel.conf
- /sys/kernel/release
- /proc/version (Correct answer)
- /etc/kernel-version
Correct answer: /proc/version
/proc/version contains the kernel version string, build date, and compiler information for the running kernel.
Question 4: A user has written a script file named `run_report.sh` but receives a "Permission denied" error when trying to execute it with `./run_report.sh`. The output of `ls -l` shows the permissions as `-rw-r--r--`. Which command will resolve this issue?
- set-executable run_report.sh
- chown user run_report.sh
- chmod +x run_report.sh (Correct answer)
- run -a run_report.sh
Correct answer: chmod +x run_report.sh
To be executed directly, a script file requires the execute permission. The `chmod +x` command adds the execute (x) permission for the owner, group, and others, resolving the "Permission denied" error.
Question 5: Which command would display only lines that do NOT match a pattern in grep?
- grep -v pattern file (Correct answer)
- grep -x pattern file
- grep -m pattern file
- grep -e pattern file
Correct answer: grep -v pattern file
grep -v inverts the match, printing only lines that do not contain the pattern.
Question 6: How can you view the groups a user belongs to?
- cat /etc/group | grep username
- id username
- groups username
- All of the above (Correct answer)
Correct answer: All of the above
All three commands can show group membership: 'groups', 'id', and inspecting /etc/group all work.
Question 7: Which command would create a new directory called 'projects' in the current location?
- create projects
- mkdir projects (Correct answer)
- touch projects
- newdir projects
Correct answer: mkdir projects
`mkdir` (make directory) creates a new directory with the specified name in the current or given path.
Question 8: After navigating from `/usr/share` to `/etc/systemd`, which command will take you back to `/usr/share`?
- cd ..
- cd last
- cd back
- cd - (Correct answer)
Correct answer: cd -
The `cd -` command is a special shortcut that changes the current directory to the previous working directory. It effectively toggles between the two most recent directories.
Question 9: By default, when you use the `gzip` command on a file (e.g., `gzip myfile.txt`), what happens to the original file?
- The original file remains, and a new file named myfile.txt.gz is created.
- The original file is deleted and replaced by myfile.txt.gz. (Correct answer)
- An error is produced, as an output file must be specified.
- The original file is renamed to myfile.txt.gz.
Correct answer: The original file is deleted and replaced by myfile.txt.gz.
The default behavior of the `gzip` command is to compress the specified file and replace it with the compressed version, which has a `.gz` extension. The original file is removed. To keep the original file, the `-k` (or `--keep`) option must be used.
Question 10: You are in a directory `/var/log`. You want to list the contents of the `apt` subdirectory within `/var/log`. Which command, using a relative path, would you use?
- list apt
- dir apt
- ls /var/log/apt
- ls apt (Correct answer)
Correct answer: ls apt
Since you are already in `/var/log`, you can use a relative path. The command `ls apt` will list the contents of the `apt` directory, which is located within your current directory.
Question 11: A file has permissions -rw-rw-r--. Which class has write access?
- Owner only
- All classes
- Owner and group (Correct answer)
- Group and others
Correct answer: Owner and group
rw- for owner and rw- for group means both owner and group have write access; others have read-only.
Question 12: Which pipeline lists the ten most frequently occurring words in a text file?
- cat file | uniq | sort -n | head -10
- cat file | wc -w | sort -r | head -10
- cat file | sort | uniq -c | sort -rn | head -10 (Correct answer)
- cat file | grep -c . | sort | head -10
Correct answer: cat file | sort | uniq -c | sort -rn | head -10
Splitting into words, counting with uniq -c, reverse-numeric sorting, then head -10 gives the top 10 most frequent words.
Question 13: What keyboard shortcut suspends a foreground process in the terminal?
- Ctrl+C
- Ctrl+S
- Ctrl+Z (Correct answer)
- Ctrl+D
Correct answer: Ctrl+Z
Pressing Ctrl+Z sends the SIGTSTP signal to the foreground process, suspending it and returning control to the shell.
Question 14: A file is owned by user 'alice' and group 'staff'. The current user is 'bob', who is in the 'staff' group. The file permissions are rw-r--r--. Can bob write to the file?
- Yes, because others have read permission
- No, the file is locked
- No, bob can only read it via group permissions (Correct answer)
- Yes, because he is in the staff group
Correct answer: No, bob can only read it via group permissions
The group permission is r-- (read-only), so bob, matched as a group member, can only read the file.
Question 15: A company forks a project licensed under the MIT License and sells it as a proprietary product without releasing source code. Is this permitted?
- Yes, the MIT License permits this as long as the copyright notice is retained (Correct answer)
- No, the company must pay a royalty to the original author
- Yes, but only if the company joins the Open Source Initiative
- No, all MIT-derived works must remain open source
Correct answer: Yes, the MIT License permits this as long as the copyright notice is retained
The MIT License is permissive and allows proprietary forks; the only requirement is retaining the original copyright and license notice.
Question 16: You have a compressed archive named `backup.tar.gz`. Before extracting it, you need to see the list of files it contains without modifying the archive. Which of the following commands will achieve this?
- tar -xvf backup.tar.gz
- gunzip backup.tar.gz
- tar -tvf backup.tar.gz (Correct answer)
- tar -cvf backup.tar.gz
Correct answer: tar -tvf backup.tar.gz
The `tar` command with the `-t` (or `--list`) option is used to list the contents of an archive without extracting them. The `-v` option provides a verbose (detailed) listing, and `-f` specifies the archive file. The `-x` option would extract the files, and `-c` would try to create a new archive. `gunzip` would decompress the file but not list the contents of the `.tar` archive within.
Question 17: A company uses open source software licensed under the GNU Lesser General Public License (LGPL) in a proprietary product. Which statement is most accurate?
- The company can link to the LGPL library without open-sourcing its proprietary code (Correct answer)
- The entire proprietary product must be released as open source
- The company must pay a fee to the Free Software Foundation
- The company cannot use LGPL software in any commercial product
Correct answer: The company can link to the LGPL library without open-sourcing its proprietary code
The LGPL is designed to allow proprietary software to link to LGPL-licensed libraries without requiring the proprietary code to be open-sourced.
Question 18: Which command shows a tree view of processes illustrating parent-child relationships?
- ps tree
- pstree (Correct answer)
- proctree
- ptree
Correct answer: pstree
The `pstree` command displays running processes in a hierarchical tree format, clearly showing parent-child relationships between processes.
Question 19: What does the load average represent in the output of the `uptime` command?
- Average disk I/O wait time
- Average CPU temperature over time
- Average number of processes waiting for CPU over 1, 5, and 15 minutes (Correct answer)
- Average network throughput
Correct answer: Average number of processes waiting for CPU over 1, 5, and 15 minutes
Load average reflects the average number of processes in the run queue (waiting for or using CPU) over the past 1, 5, and 15 minutes.
Question 20: Which utility can both compress files and create archives (unlike gzip which only compresses)?
- compress
- xz
- zip (Correct answer)
- bzip2
Correct answer: zip
The zip utility creates archive files containing multiple files with compression, while gzip/bzip2/xz only compress single files.
Question 21: A user creates a script named `greet.sh` with the content `echo "Hello, $1"`. How should the user execute this script to produce the output `Hello, David`?
- echo "David" | ./greet.sh
- ./greet.sh David (Correct answer)
- David ./greet.sh
- ./greet.sh $1="David"
Correct answer: ./greet.sh David
Arguments passed to a script on the command line are known as positional parameters. `$1` refers to the first argument, `$2` to the second, and so on. By running `./greet.sh David`, the string "David" becomes the first argument and is substituted for `$1` within the script.
Question 22: What does the `free` command display on a Linux system?
- Physical and swap memory usage (Correct answer)
- Free inodes on filesystems
- Free disk space
- Available CPU cores
Correct answer: Physical and swap memory usage
The `free` command shows the total, used, and available physical RAM and swap space on the system.
Question 23: Which file stores the encrypted passwords for user accounts on a modern Linux system?
- /etc/passwd
- /etc/gshadow
- /etc/shadow (Correct answer)
- /etc/security
Correct answer: /etc/shadow
Modern Linux systems store encrypted passwords in /etc/shadow, which is readable only by root.
Question 24: Which of the following correctly defines a shell function named `greet`?
- func greet { echo Hello; }
- def greet() { echo Hello; }
- function greet[] { echo Hello; }
- greet() { echo Hello; } (Correct answer)
Correct answer: greet() { echo Hello; }
The POSIX-compatible syntax `name() { commands; }` defines a shell function.
Question 25: Which virtual filesystem in Linux provides an interface to kernel data structures and information about system processes?
- /proc (Correct answer)
- /dev
- /tmp
- /sys
Correct answer: /proc
The `/proc` filesystem is a special, pseudo-filesystem that provides an interface to kernel data structures. It doesn't contain real files but runtime system information, such as system memory, devices mounted, and hardware configuration. It contains a directory for each running process, identified by its process ID (PID).
Question 26: Which command displays the amount of disk space used and available on mounted filesystems?
- df -h (Correct answer)
- du -h
- mount --stats
- ls -s
Correct answer: df -h
df -h reports disk space usage for all mounted filesystems in human-readable format showing total, used, and available space.
Question 27: Which command is used to view the contents of a text file one screen at a time?
- less (Correct answer)
- cat
- head
- grep
Correct answer: less
`less` allows you to scroll through file contents one screen at a time, both forward and backward.
Question 28: What does 'umask 027' mean for newly created files?
- Files get permissions 640 (Correct answer)
- Files get permissions 027
- Files get permissions 777
- Files get permissions 750
Correct answer: Files get permissions 640
Default file permissions (666) minus umask (027) = 640, giving rw-r----- for new files.
Question 29: What does the `.` (single dot) represent in a Linux filesystem path?
- A hidden file prefix
- The current directory (Correct answer)
- The parent directory
- The root directory
Correct answer: The current directory
A single dot `.` refers to the current directory, so `./script.sh` runs a script in the current location.
Question 30: Which character is used to redirect standard output AND standard error to the same file in bash?
- &>>
- >!
- >>2
- 2>&1 combined with > (Correct answer)
Correct answer: 2>&1 combined with >
Using `> file 2>&1` first redirects stdout to the file, then redirects stderr to wherever stdout now points.
Question 31: Which command is used to display the first 10 lines of a text file named `report.txt`?
- head report.txt (Correct answer)
- cat report.txt | top -n 10
- tail report.txt
- less -n 10 report.txt
Correct answer: head report.txt
The `head` command, by default, displays the first 10 lines of a specified file. The `tail` command shows the last lines, `cat` displays the entire file, and `less` is a pager for viewing files page by page.
Question 32: What is the effect of setting a user's shell to /sbin/nologin?
- The user's account is deleted at next login
- The user cannot log in interactively (Correct answer)
- The user can only log in via SSH
- The user is restricted to a chroot environment
Correct answer: The user cannot log in interactively
/sbin/nologin prints a message and rejects interactive login attempts, commonly used for service accounts.
Question 33: What does a 'dual-license' model mean for open source software?
- Two developers must sign off on all license changes
- The software alternates between licenses with each version
- The software requires two separate licenses to use
- The software is released under two different licenses simultaneously, offering users a choice (Correct answer)
Correct answer: The software is released under two different licenses simultaneously, offering users a choice
A dual-license model means the software is released under two licenses at once, often one open source (e.g., GPL) and one commercial, giving users or companies a choice.
Question 34: What is the purpose of the `wc -l` command?
- Count words in a file
- Count characters in a file
- Count bytes in a file
- Count lines in a file (Correct answer)
Correct answer: Count lines in a file
wc -l counts the number of newline-terminated lines in the input.
Question 35: Which command prints the current working directory?
- where
- cwd
- pwd (Correct answer)
- dir
Correct answer: pwd
pwd (print working directory) outputs the absolute path of the current directory.
Question 36: What is the purpose of cache memory (L1, L2, L3) in a CPU?
- Store frequently accessed data closer to the CPU to reduce latency (Correct answer)
- Store the operating system kernel for fast access
- Buffer disk writes before flushing to storage
- Provide additional RAM when system memory is full
Correct answer: Store frequently accessed data closer to the CPU to reduce latency
CPU cache levels (L1, L2, L3) store frequently used data and instructions near the processor to avoid slower main memory accesses.
Question 37: Which command creates a new group called 'devops' on a Linux system?
- groupadd devops (Correct answer)
- newgroup devops
- mkgroup devops
- addgroup devops
Correct answer: groupadd devops
groupadd devops is the standard command to create a new group entry in /etc/group.
Question 38: Which tar option extracts files to a specific directory instead of the current one?
- -D /path/to/dir
- -X /path/to/dir
- -C /path/to/dir (Correct answer)
- -O /path/to/dir
Correct answer: -C /path/to/dir
The -C option changes the working directory before performing any operations, so files are extracted there.
Question 39: Which symbolic permission argument adds execute permission for all users?
- o+x
- g+x
- u+x
- a+x (Correct answer)
Correct answer: a+x
'a' stands for all (user, group, others), so 'a+x' adds execute for everyone.
Question 40: What does the 'w' command show when run on a Linux system?
- Who is logged in and what they are doing (Correct answer)
- Pending writes to disk
- The write permissions of the current directory
- A list of all user accounts
Correct answer: Who is logged in and what they are doing
The w command displays currently logged-in users, their terminals, login times, and the commands they are running.
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