Limited-Time Offer: Enjoy 50% Savings! Ends in 00h 00m 00s Coupon code: 50OFF
Skip to content

Free LPI LPIC-1 Exam 101, Part 1 of 2 101-500 Exam Questions

Page: 1 / 20 Total 296 questions

Want more questions? Get Premium Access.

Question 1

Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file?

Correct Answer: B. cut --d : -f 1,4 /etc/passwd
Explanation:

The command that prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file is cut -d : -f 1,4 /etc/passwd. The cut command is used to extract selected fields or characters from each line of a file or standard input. The -d or --delimiter option specifies the character that separates the fields, which in this case is a colon (:). The -f or --fields option specifies the fields to be printed, which in this case are the first and the fourth fields. The /etc/passwd file is a text file that contains information about the user accounts on the system, such as the username, password, user ID, group ID, home directory, and login shell. The first column of the file is the username and the fourth column is the group ID, which corresponds to the primary group of the user. The cut command will print these two columns separated by a colon for each line of the file. For example, running cut -d : -f 1,4 /etc/passwd will produce an output like this:

root:0 daemon:1 bin:1 sys:3 sync:4 games:5 man:12 lp:7 mail:8 news:9 uucp:10 proxy:13 www-data:33 backup:34 list:38 irc:39 gnats:41 nobody:65534 systemd-network:100 systemd-resolve:101 syslog:102 messagebus:103 _apt:104 lxd:105 uuidd:106 dnsmasq:107 sshd:108 pollinate:109 vboxadd:999 ubuntu:1000

The other commands are either invalid or do not perform the desired task. The fmt command is used to reformat paragraphs of text, but it does not have a -f option. The sort command is used to sort lines of text, but it does not have a -t option. The paste command is used to merge lines of files, but it does not have a -f option. The split command is used to split a file into pieces, but it does not have a -c option.Reference:

Linux Essentials - Linux Professional Institute Certification Programs

Exam 101 Objectives - Linux Professional Institute

cut(1) - Linux manual page

/etc/passwd file - Linux.com


Question 2

Which of the following commands is used to modify quota settings? (Choose two.)

Correct Answer: B. setquota; C. edquota
Explanation:

The following commands are used to modify quota settings:

B . setquota: This command is used to set disk quotas for users or groups on a filesystem. The setquota command requires the user or group name, the soft and hard limits for blocks and inodes, and the device name or mount point of the filesystem as arguments. For example, to set a quota for user sammy with a 100MB soft limit and a 110MB hard limit for blocks, and a 1000 soft limit and a 1100 hard limit for inodes on the /home filesystem, use the following command:

sudo setquota -u sammy 100M 110M 1000 1100 /home

C . edquota: This command is used to edit disk quotas for users or groups on a filesystem. The edquota command opens an editor, such as nano or vi, with the current quota settings for the specified user or group. You can then modify the settings as you wish, and save and exit the editor to apply the changes. For example, to edit the quota for user sammy on the /home filesystem, use the following command:

sudo edquota -u sammy

This will open an editor with the following content:

Disk quotas for user sammy (uid 1000): Filesystem blocks soft hard inodes soft hard /dev/vda1 40 0 0 13 0 0 /dev/vda2 1024 102400 112640 10 1000 1100

You can then change the values as you wish, and save and exit the editor to apply the changes.

The other options are not valid commands or options. The editquota and quotaedit commands do not exist on a standard Linux system. The quotaset command is a synonym for setquota, but it is not commonly used.


How to Configure/Setup Disk Quotas in Linux | 2DayGeek

setquota(8): set disk quotas - Linux man page

edquota(8): edit user/group quotas - Linux man page

Question 3

Which of the following protocols is designed to access the video card output of a virtual machine?

Correct Answer: D. SPICE
Explanation:

Both SPICE (Simple Protocol for Independent Computing Environments) and VNC (Virtual Network Computing) are protocols designed to access the video card output of virtual machines. SPICE is optimized specifically for virtual machine environments and provides better performance and features, while VNC is a more generic remote desktop protocol that also works for virtual machine console access.

Question 4

Which command is used to sync the hardware clock to the system clock? (Specify ONLY the command without any path or parameters.)

Correct Answer: A. Huclock
Explanation:

The hwclock command (sometimes called clock on older systems) is used to query and set the hardware clock (CMOS clock or RTC - Real Time Clock). The option hwclock -w or hwclock --systohc syncs the hardware clock to the current system clock.

Question 5

What is the default action of the split command on an input file?

Correct Answer: B. It will break the file into new files of 1,000 line pieces each.
Explanation:

The split command in Linux is used to split large files into smaller files. The default action of the split command on an input file is to break the file into new files of 1,000 line pieces each. The names of the new files are PREFIXaa, PREFIXab, PREFIXac, and so on. By default, the PREFIX of the new files is x, but it can be changed with the -a option. For example, the following command will split the file someLogFile.log into new files of 1,000 lines each with the prefix log:

split someLogFile.log -a 3 log

The new files will be named logaaa, logaab, logaac, and so on. To verify the number of lines in each new file, we can use the wc command with the -l option. For example, the following command will show the number of lines in the first and the last new file:

wc -l logaaa logaas

The output will be:

1000 logaaa 170 logaas

This means that the original file had 17,170 lines and was split into 18 new files. 17 of them have 1,000 lines each, and the last one has the remaining 170 lines.Reference:

[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use ofsplitandcatto split or join files.

[Split Command in Linux: 9 Useful Examples], Topic: Split Files


Question 6

Which grep command will print only the lines that do not end with a / in the file foo?

Correct Answer: C. grep -v '/$' foo
Explanation:

Thegrepcommandthatwillprintonlythelinesthatdonotendwitha/inthefilefooisgrepv/' foo. This command uses the following options and pattern:

-v: Inverts the matching, meaning that it only outputs the lines that do not match the pattern. /:Matchesa/characterattheendofaline.The symbol represents the end of a line in regular expressions. foo: The name of the file to search.

The output of this command will show all the lines in the file foo that do not have a / as the last character. For example, if the file foo contains the following lines:

/home/user/ /var/log/messages /etc/passwd /usr/bin/

The output of the command will be:

/var/log/messages /etc/passwd

The other commands are incorrect for the following reasons:

grep '/$' foo: This command will print only the lines that do end with a / in the file foo, which is the opposite of what is required.

grep '/#' foo: This command will print only the lines that contain the string /# in the file foo, which is not related to the question.

grep -v '/#' foo: This command will print only the lines that do not contain the string /# in the file foo, which is also not related to the question.


[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of egrep to search for extended regular expressions in text output.

[How to Use the grep Command on Linux], Topic: Start and End of Lines.

Question 7

Which of the following commands kills the process with the PID 123 but allows the process to "clean up" before exiting?

Correct Answer: D. kill -TERM 123
Explanation:

The commandkill -TERM 123kills the process with the PID 123 but allows the process to ''clean up'' before exiting. The option -TERM specifies the signal to be sent to the process, which is the termination signal (SIGTERM). This signal requests the process to terminate gracefully, which means that the process can perform any necessary actions before exiting, such as closing files, releasing resources, or saving data. The process can also catch the signal and ignore it or handle it in a different way, if it is programmed to do so. The syntax is:kill -TERM pid. For example,kill -TERM 123will send the SIGTERM signal to the process with the PID 123, asking it to terminate nicely. The other options are not correct because:

A . kill -PIPE 123: This command sends the broken pipe signal (SIGPIPE) to the process, which is not used to kill the process, but to notify it that the other end of a pipe has been closed.This signal is usually ignored by the process, unless it is writing to the pipe, in which case it will cause the process to terminate1.

B . kill -KILL 123: This command sends the kill signal (SIGKILL) to the process, which is the most powerful way to kill the process, but it does not allow the process to ''clean up'' before exiting. The SIGKILL signal cannot be caught, blocked, or ignored by the process, and it forces the process to terminate immediately, without performing any actions.This command should be used as a last resort, when the process is unresponsive or causing harm to the system2.

C . kill -STOP 123: This command sends the stop signal (SIGSTOP) to the process, which is not used to kill the process, but to pause it. The SIGSTOP signal cannot be caught, blocked, or ignored by the process, and it suspends the execution of the process until it receives a continue signal (SIGCONT).This command can be used to temporarily stop a process from running, without terminating it3.Reference:

What is the purpose of the SIGPIPE signal? - Stack Overflow

How to kill a process in Linux - LinuxConfig.org

Linux Signals - GeeksforGeeks


Question 8

When removing a package, which of the following dpkg options will completely remove the files including configuration files?

Correct Answer: C. --purge
Explanation:

When removing a package on a system using dpkg package management, the --purge option ensures that configuration files are removed as well. The --purge option is equivalent to the --remove option followed by the --purge-config-files option, which removes any configuration files that are marked as obsolete. The --remove option only removes the package files, but leaves the configuration files intact. The --clean option removes any .deb files from the local cache, but does not affect the installed packages. The --delete option is not a valid option for dpkg.Reference:

1, 102.4 Lesson 1

3, 101-500 Exam - Free Questio ns and Answers - ITExams.com

man dpkg


Question 9

Which of the following commands will change the quota for a specific user?

Correct Answer: A. edquota
Explanation:

The correct command to change the quota for a specific user isedquota. This command allows you to edit the quota limits for a user, a group, or a file set. You can specify the name of the user that you want to edit the quotas for after the command. For example, to change the disk quota for user 'linuxconfig', you can use the following command:

sudo edquota -u linuxconfig

This command will open an editor with the current quota information for the user 'linuxconfig'. You can modify the soft and hard limits for the block and inode usage as per your requirements. You can also use the -p option to copy the quota settings from another user. For example, to copy the quota settings from user 'ramesh' to user 'linuxconfig', you can use the following command:

sudo edquota -p ramesh -u linuxconfig

The other commands are not suitable for changing the quota for a specific user. Therepquotacommand displays a summary of the current quota usage and limits for the users or groups. Thequota -ecommand turns off the disk quota for the current user. Thequotacommand shows the disk quota and usage for the current user or for the users specified on the command line. For more information on how to use disk quota on Linux, you can refer to the following articles:

How to use disk quota on Linux with examples

5 Steps to Setup User and Group Disk Quota on UNIX / Linux


Question 10

What of the following statements are true regarding /dev/ when using udev? (Choose TWO correct answers.)

Correct Answer: B. Additional rules for udev can be created by adding them to /etc/udev/rules.d/.; D. The /dev/ directory is a filesystem of type tmpfs and is mounted by udev during system startup.
Explanation:

udev is a device manager that dynamically creates and removes device nodes in the /dev/ directory. It also handles device events, such as adding, removing, or changing the attributes of devices. udev uses rules to match devices and assign properties, permissions, names, symlinks, and other actions. The rules are stored in files under /lib/udev/rules.d/ and /etc/udev/rules.d/. The latter directory can be used to create additional or override existing rules. The /dev/ directory is not a regular directory on the root filesystem, but a virtual filesystem of type tmpfs that is mounted by udev during system startup. tmpfs is a filesystem that resides in memory and can grow and shrink dynamically. The content of /dev/ is not stored in /etc/udev/dev, but is created by udev based on the rules and the available devices. udev does not prevent the creation of block or character devices in /dev/ using mknod, but it may overwrite or remove them if they conflict with the rules or the device events.Reference:LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 102.4


Question 11

Which of the following commands changes all occurrences of the word ''bob'' in file data to ''Bob'' and prints the result to standard output?

Correct Answer: B. sed's/bob/Bob/g' data
Explanation:

The sed command is used to perform various text processing tasks on a file or a stream. The s command is used to substitute a pattern with a replacement. The g flag is used to replace all occurrences of the pattern in a line. The / character is used to separate the pattern, the replacement, and the flags. Therefore, the command sed's/bob/Bob/g' data will change all occurrences of the word ''bob'' in file data to ''Bob'' and print the result to standard output. The other commands are incorrect because they either use the wrong syntax or do not replace all occurrences of the word ''bob''.Reference:

LPI 101-500 Exam Objectives, Topic 103.7, Weight 4

LPI Learning Materials, Chapter 3.7, Basic Scripting

Web Search Results,1


Question 12

What is true regarding the statement beginning with #! that is found in the first line of a script? (Choose TWO correct answers.)

Correct Answer: B. It triggers the installation of the scripts interpreter; C. It specifies the path and the arguments of the interpreter used to run the script
Explanation:

The #! (shebang or hashbang) at the beginning of a script is a special construct that tells the operating system which interpreter should execute the script. When a script with a shebang is executed directly (e.g., ./script.sh), the kernel reads this first line and uses the specified interpreter (such as #!/bin/bash) to run the script. This allows scripts to be executable without explicitly calling the interpreter on the command line.

Question 13

When given the following command line.

echo "foo bar" | tee bar | cat

Which of the following output is created?

Correct Answer: B. foo bar
Explanation:

The output of the given command line isfoo bar. The command line consists of three commands that are connected by pipes (|). A pipe is a symbol that redirects the standard output of one command to the standard input of another command. Theechocommand prints its argument to the standard output, which isfoo barin this case. Theteecommand reads from the standard input and writes to both the standard output and a file. The file name is given as an argument, which isbarin this case. Thecatcommand reads from the standard input and writes to the standard output. Therefore, the command line does the following:

Theechocommand printsfoo barto the standard output, which is redirected to the standard input of theteecommand by the first pipe.

Theteecommand readsfoo barfrom the standard input and writes it to both the standard output and the filebar. The standard output of theteecommand is redirected to the standard input of thecatcommand by the second pipe.

Thecatcommand readsfoo barfrom the standard input and writes it to the standard output, which is displayed on the terminal.

Hence, the output of the command line isfoo bar. The other options are either incorrect or not applicable. Thecat,tee barandbarare not printed by any of the commands. Thefoois only part of the output, not the whole output.Reference:

LPIC-1 Exam 101 Objectives, Topic 103: GNU and Unix Commands, 103.4 Use streams, pipes and redirects

LPIC-1 Linux Administrator 101-500 Exam FAQ, LPIC-1 Exam 101 Objectives, GNU and Unix Commands (Total Weight: 25)


Question 14

What information can the lspci command display about the system hardware? (Choose THREE correct answers.)

Correct Answer: A. Device IRQ settings; B. PCI bus speed; D. Device vendor identification
Explanation:

: The lspci command can display information about the system hardware, such as:

Device IRQ settings1: The lspci command can show the interrupt request (IRQ) number assigned to each device by using the -v option. The IRQ number indicates how the device communicates with the CPU.

PCI bus speed2: The lspci command can show the speed of the PCI bus by using the -vv option. The speed is expressed in megahertz (MHz) or gigahertz (GHz) and indicates how fast the data can be transferred between the device and the bus.

Device vendor identification3: The lspci command can show the name and identification number of the device vendor by using the -n or -nn option. The vendor identification helps to identify the manufacturer and model of the device.


Question 15

When planning a partition scheme, which of the following directories could be considered for separate partitions? (Choose three.)

Correct Answer: B. /home
Explanation:

When planning a partition scheme, it is advisable to consider creating separate partitions for some directories that may contain large amounts of data, have different backup or security requirements, or benefit from being on different filesystems. Some of the common directories that could be considered for separate partitions are:

/home: This directory contains the personal files and settings of the users. Creating a separate partition for /home can make it easier to backup, restore, or upgrade the system without affecting the user data. It can also improve security by allowing different mount options such as noexec or nosuid.Additionally, it can help to prevent the system from becoming unusable if the users fill up their disk space with personal files123.

/var: This directory contains variable data such as logs, caches, spool files, databases, and web server content. Creating a separate partition for /var can prevent the system from crashing or becoming unresponsive if the /var partition fills up due to excessive logging or caching. It can also improve performance by allowing different filesystem options such as noatime or nodiratime.Furthermore, it can enhance security by isolating the data that may be modified by external sources such as web applications or mail servers124.

/opt: This directory contains optional software packages that are not part of the standard distribution. Creating a separate partition for /opt can make it easier to manage, backup, or remove these packages without affecting the rest of the system.It can also allow different filesystem types or features that may be required by some of the software installed in /opt125.

Other directories that could be considered for separate partitions are /boot, /tmp, /usr, and /srv, depending on the system requirements and preferences12.Reference:

Linux Partitioning Recommendations | Average Linux User

Linux Disk Partitioning Schemes - Land of Linux

C .3. Recommended Partitioning Scheme - Debian