LPI 101-500 - LPIC-1 Exam 101, Part 1 of 2, version 5.0
Which wildcards will match the following filenames? (Choose two.)
ttyS0
ttyS1
ttyS2
ttyS[1-5]
tty?[0-5]
tty*2
tty[A-Z][012]
tty[Ss][02]
The Answer Is:
B, CExplanation:
[character list] matches any one of the characters in the list. ? matches any single character. * matches any number of characters, including none.
Therefore, the wildcard ttyS[1-5] will match any filename that starts with ttyS and ends with a digit from 1 to 5, such as ttyS1, ttyS2, ttyS3, ttyS4, or ttyS5. However, it will not match ttyS0, which has a 0 at the end.
The wildcard tty?[0-5] will match any filename that starts with tty, followed by any single character, followed by a digit from 0 to 5, such as ttyS0, ttyS1, ttyS2, ttyA0, ttyB5, or ttyZ4. This wildcard will match all the given filenames.
The wildcard tty*2 will match any filename that starts with tty and ends with 2, such as ttyS2, ttyA2, ttyB2, or ttyZZZ2. This wildcard will match ttyS2, but not the other two filenames.
The wildcard tty[A-Z][012] will match any filename that starts with tty, followed by a capital letter from A to Z, followed by a digit from 0 to 2, such as ttyA0, ttyB1, ttyC2, ttyZ0, or ttyZ2. This wildcard will match ttyS0 and ttyS2, but not ttyS1, which has a 1 at the end.
The wildcard tty[Ss][02] will match any filename that starts with tty, followed by either S or s, followed by either 0 or 2, such as ttyS0, ttyS2, ttys0, or ttys2. This wildcard will match ttyS0 and ttyS2, but not ttyS1, which has a 1 at the end.
Which daemon handles power management events on a Linux system?
acpid
batteryd
pwrmgntd
psd
inetd
The Answer Is:
AExplanation:
 The daemon that handles power management events on a Linux system is acpid. A daemon is a background process that runs continuously and performs certain tasks without user intervention. The acpid daemon listens for power management related events, such as switching between AC and battery power on a laptop, pressing the power button, closing the lid, etc., and executes various commands in response. The acpid daemon can be configured by editing the files in /etc/acpi/events and /etc/acpi/actions directories, or by using a graphical tool like gnome-power-manager or xfce4-power-manager. The acpid daemon is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
Power management - ArchWiki2
9.12. Power Management: Advanced Configuration and Power Interface (ACPI)
Which is the default percentage of reserved space for the root user on new ext4 filesystems?
10%
3%
15%
0%
5%
The Answer Is:
EExplanation:
The reserved space is a portion of the filesystem that is only accessible to the root user or users with sudo privileges. The reserved space serves two purposes: to prevent ordinary users from filling up the filesystem completely and crashing the system, and to reduce fragmentation by leaving some free space. The reserved space is set by default to 5% of the total filesystem size when the filesystem is created with the mkfs.ext4 command. This means that 5% of the blocks are reserved for the root user and are not counted as available space by the df command. The reserved space can be changed or disabled by using the tune2fs command with the -m option. For example, to change the reserved space to 1%, use the following command:
sudo tune2fs -m 1 /dev/sdXY
where /dev/sdXY is the device name of the ext4 filesystem.
To disable the reserved space completely, use 0% instead of 1%. However, this is not recommended, as it may affect the performance and stability of the system, especially if the filesystem is almost full.
References:
Reserved space for root on a filesystem - why?
Linux : How to reduce the percentage of reserved blocks on ext4 filesystem
tune2fs(8) - Linux manual page
Which of the following statements are true about the boot sequence of a PC using a BIOS? (Choose two.)
Some parts of the boot process can be configured from the BIOS
Linux does not require the assistance of the BIOS to boot a computer
The BIOS boot process starts only if secondary storage, such as the hard disk, is functional
The BIOS initiates the boot process after turning the computer on
The BIOS is started by loading hardware drivers from secondary storage, such as the hard disk
The Answer Is:
A, DExplanation:
The boot sequence of a PC using a BIOS is the process of loading and executing the operating system from the power-on state. The BIOS (Basic Input/Output System) is a firmware program that is stored in a ROM chip on the motherboard and provides the interface between the hardware and the software. The BIOS performs the following tasks during the boot sequence12:
It runs the power-on self-test (POST) to check the integrity and functionality of the hardware components and peripherals.
It reads the BIOS settings from the CMOS memory and applies them to the system configuration. Some parts of the boot process, such as the boot device order, can be configured from the BIOS by pressing a specific key (usually F2, F10, or Del) during the POST.
It locates and loads the boot loader program from the first sector of the boot device, which is usually the hard disk. The boot loader program can be GRUB, LILO, or Windows Boot Manager, depending on the operating system installed. The boot loader is responsible for loading the kernel and the initial ramdisk (initrd) into memory and passing control to them.
It transfers the execution to the boot loader and exits the boot sequence.
The other options are false or irrelevant. Linux does require the assistance of the BIOS to boot a computer, at least until the kernel takes over the hardware control. The BIOS boot process does not start only if secondary storage is functional, it can also boot from other devices such as USB drives, CD-ROMs, or network. The BIOS is not started by loading hardware drivers from secondary storage, it is stored in a ROM chip and runs before any secondary storage is accessed. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
The Linux Booting Process - 6 Steps Described in Detail - freeCodeCamp.org3
Guide to the Boot Process of a Linux System - Baeldung4
Which of the following commands installs GRUB 2 into the master boot record on the third hard disk?
grub2 install /dev/sdc
grub-mkrescue /dev/sdc
grub-mbrinstall /dev/sdc
grub-setup /dev/sdc
grub-install /dev/sdc
The Answer Is:
EExplanation:
The command that installs GRUB 2 into the master boot record on the third hard disk is grub-install /dev/sdc. The grub-install command is the high-level tool for installing GRUB 2 on a disk or a partition. It takes a device name as an argument and writes the GRUB 2 boot loader information to the specified location. If the device name is a disk, such as /dev/sdc, the boot loader information is written to the master boot record (MBR) of the disk, which is the first sector that contains the boot code and the partition table. If the device name is a partition, such as /dev/sdc1, the boot loader information is written to the boot sectorof the partition, which is the first sector of the partition that contains the boot code and the file system information. The grub-install command is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12.
The other commands are either invalid or do not perform the desired task. The grub2 install command does not exist, as grub2 is not a valid command name. The grub-mkrescue command is used to create a bootable GRUB 2 rescue image, not to install GRUB 2 on a disk or a partition3. The grub-mbrinstall command does not exist, as mbrinstall is not a valid subcommand for grub. The grub-setup command is a low-level tool for installing GRUB 2 on a disk or a partition, but it is not recommended for normal use, as it requires specifying the location of the GRUB 2 core image file4. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
GNU GRUB Manual 2.06: Making a GRUB bootable CD-ROM3
GNU GRUB Manual 2.06: Installing GRUB natively4
Which of the following files, located in a user’s home directory, contains the Bash history?
.bashrc_history
.bash_histfile
.history
.bash_history
.history_bash
The Answer Is:
DExplanation:
The correct answer is D, .bash_history. This file, located in a user’s home directory, contains the Bash history, which is a list of commands that the user has entered in the Bash shell. The syntax of the file is:
~/.bash_history
The ~ symbol represents the user’s home directory, which is usually /home/username. The / symbol is a directory separator that separates the components of a path. The . symbol at the beginning of the file name indicates that the file is hidden, which means that it is not normally displayed by the ls command or the file manager, unless the -a option or the show hidden files option is used. The bash_history is the name of the file that stores the Bash history.
The Bash history is maintained by the Bash shell while it is running, and it is written to the .bash_history file when the shell exits or when the history -a or -w options are used. The history command can be used to display, manipulate, or search the Bash history. The HISTFILE variable can be used to change the name or location of the .bash_history file. The HISTSIZE and HISTFILESIZE variables can be used to change the number of commands that are stored in the Bash history and the .bash_history file, respectively.
The other files are incorrect for the following reasons:
A, .bashrc_history: This file does not exist by default, and it is not used to store the Bash history. The .bashrc file is a configuration file that is executed by the Bash shell when it starts in interactive mode. It can contain commands, aliases, functions, variables, or other settings that affect the behavior of the shell. However, it is not used to store the history of the commands that the user has entered.
B, .bash_histfile: This file does not exist by default, and it is not used to store the Bash history. The .bash_histfile file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name.
C, .history: This file does not exist by default, and it is not used to store the Bash history. The .history file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name.
E, .history_bash: This file does not exist by default, and it is not used to store the Bash history. The .history_bash file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name.
References:
Where is bash’s history stored? - Unix & Linux Stack Exchange
How to view the .bash_history file via command line? - Ask Ubuntu
shell - How can I see all of the bash history? - Stack Overflow
What does the command mount --bind do?
It makes the contents of one directory available in another directory
It mounts all available filesystems to the current directory
It mounts all user mountable filesystems to the user’s home directory
It mounts all file systems listed in /etc/fstab which have the option userbind set
It permanently mounts a regular file to a directory
The Answer Is:
AExplanation:
The mount --bind command is used to create a bind mount, which is an alternate view of a directory tree. A bind mount takes an existing directory tree and replicates it under a different point. The directories and files in the bind mount are the same as the original. Any modification on one side is immediately reflected on the other side, since the two views show the same data. For example, after issuing the command:
mount --bind /some/where /else/where
the directories /some/where and /else/where have the same content, which is the content of /some/where. A bind mount can be useful for accessing hidden files, creating chroot environments, or changing the permissions or ownership of files.
The other options are not correct because:
B. It mounts all available filesystems to the current directory: This is not what the mount --bind command does. The mount --bind command only creates a bind mount for a single directory tree. To mount all available filesystems to the current directory, one would need to use the mount -a command with the -t option and specify the current directory as the target.
C. It mounts all user mountable filesystems to the user’s home directory: This is not what the mount --bind command does. The mount --bind command only creates a bind mount for a single directory tree. To mount all user mountable filesystems to the user’s home directory, one would need to use the mount -a command with the -t option and specify the user’s home directory as the target. However, this is not a common or recommended practice, as it may cause conflicts or errors with the existing files and directories in the user’s home directory.
D. It mounts all file systems listed in /etc/fstab which have the option userbind set: This is not what the mount --bind command does. The mount --bind command only creates a bind mount for a single directory tree. To mount all file systems listed in /etc/fstab which have the option userbind set, one would need to use the mount -a command with the -O option and specify userbind as the option. However, this is not a standard or supported option for the mount command or the /etc/fstab file, and it may not work as expected.
E. It permanently mounts a regular file to a directory: This is not what the mount --bind command does. The mount --bind command only creates a bind mount for a directory tree, not a regular file. To mount a regular file to a directory, one would need to use the mount command with the -o loop option and specify the file and the directory as the source and the target. However, this is only possible for files that contain a valid filesystem image, such as an ISO file or a disk image. A bind mount is not permanent, and it can be unmounted with the umount command.
References:
Understanding Bind Mounts | Baeldung on Linux
What is a bind mount? - Unix & Linux Stack Exchange
mount(8) - Linux manual page
Which of the following regular expressions represents a single upper-case letter?
:UPPER:
[A-Z]
!a-z
%C
{AZ}
The Answer Is:
BExplanation:
The regular expression that represents a single upper-case letter is [A-Z]. This is a character class that matches any one character from the range A to Z, which are the 26 upper-case letters of the English alphabet. A character class is enclosed in square brackets and can contain a list or a range of characters to match. For example, [abc] matches any one of the letters a, b, or c, and [0-9] matches any one digit from 0 to 9. The other options are not valid regular expressions for a single upper-case letter. The :UPPER: option is not a valid syntax for a character class, and it would be interpreted as a literal string of seven characters. The !a-z option is not a valid syntax for a negated character class, and it would be interpreted as a literal string of four characters. The %C option is not a valid syntax for a character class, and it would be interpreted as a literal string of two characters. The {AZ} option is not a valid syntax for a character class, and it would be interpreted as a literal string of four characters. The curly braces are used for interval expressions, which specify the number of repetitions of a character or a group of characters. For example, a{2,4} matches the letter a repeated two, three, or four times. References:
How to Use Regular Expressions (regexes) on Linux1
How to Use Regular Expressions (RegEx) on Linux2
A beginner’s guide to regular expressions with grep3
When is the content of the kernel ring buffer reset? (Choose two.)
When the ring buffer is explicitly reset using the command dmesg --clear
When the ring buffer is read using dmesg without any additional parameters
When a configurable amount of time, 15 minutes by default, has passed
When the kernel loads a previously unloaded kernel module
When the system is shut down or rebooted
The Answer Is:
A, EExplanation:
The content of the kernel ring buffer is reset when the ring buffer is explicitly reset using the command dmesg --clear or when the system is shut down or rebooted. The kernel ring buffer is a portion of the physical memory that holds the kernel’s log messages. It has a fixed size, which means once the buffer is full, the older logs records are overwritten. The dmesg command-line utility is used to print and control the kernel ring buffer in Linux and other Unix-like operating systems1. The dmesg --clear option clears the ring buffer’s contents, which can be useful for debugging purposes or to free up some memory2. The systemshutdown or reboot also clears the ring buffer’s contents, as the physical memory is reset and the kernel is reloaded3.
The other options are false or irrelevant. The ring buffer is not reset when it is read using dmesg without any additional parameters, as this option only displays the current contents of the buffer without modifying them2. The ring buffer is not reset when a configurable amount of time, 15 minutes by default, has passed, as there is no such time limit for the buffer’s persistence4. The ring buffer is not reset when the kernel loads a previously unloaded kernel module, as this action only affects the kernel’s functionality and not its log messages5. References:
Dmesg Command in Linux | Linuxize1
dmesg(1) - Linux manual page2
Linux Dmesg Command Help and Examples - Computer Hope3
Lockless Ring Buffer Design — The Linux Kernel documentation4
Linux Kernel Module Management 101 - Linux.com5
Which command must be entered before exiting vi to save the current file as filea.txt?
%s filea.txt
%w filea.txt
:save filea.txt
:w filea.txt
:s filea.txt
The Answer Is:
DExplanation:
 The correct answer is D, :w filea.txt. This command will save the current file as filea.txt before exiting vi. The syntax of the command is:
w [filename]
The colon (:) begins command-input mode, which allows the user to enter commands at the bottom of the screen. The w stands for write, which means to save the file. The filename is the name of the file to be saved. If no filename is given, the command will save the file with the same name as the original file.
Therefore, the command :w filea.txt will save the current file as filea.txt and return to command mode. To exit vi, the user can then enter :q, which stands for quit.
The other commands are incorrect for the following reasons:
A, %s filea.txt: This command will not save the file, but it will try to substitute the string filea.txt in the file. The syntax of the command is:
%s/pattern/replacement/
The % symbol means to apply the command to the whole file. The s stands for substitute, which means to replace a pattern with another pattern. The pattern is the string to be matched, and the replacement is the string to replace the matched string. However, this command is incomplete, because it does not have a replacement or a delimiter. The command will cause an error and will not save the file.
B, %w filea.txt: This command will not save the file, but it will try to write the file to a filter. The syntax of the command is:
%w !command
The % symbol means to apply the command to the whole file. The w stands for write, which means to save the file. The ! symbol means to execute an external command. The command is the name of the filter to which the file is written. However, this command is incomplete, because it does not have a ! symbol or a filter name. The command will cause an error and will not save the file.
C, :save filea.txt: This command will not save the file, but it will try to save the file under a new name and switch to the new file. The syntax of the command is:
saveas filename
The saveas command is similar to the write command, but it also changes the current file name to the new file name. However, this command is incorrect, because it does not have the as keyword after save. The command will cause an error and will not save the file.
E, :s filea.txt: This command will not save the file, but it will try to substitute the string filea.txt in the current line. The syntax of the command is:
s/pattern/replacement/
The s stands for substitute, which means to replace a pattern with another pattern. The pattern is the string to be matched, and the replacement is the string to replace the matched string. However, this command is incomplete, because it does not have a replacement or a delimiter. The command will cause an error and will not save the file.
References:
How to Save a File in Vi / Vim Editor & Quit - phoenixNAP
How to Save a File in Vim / Vi and Quit the Editor | Linuxize
How to Save a File in Linux After Using the Vi Command - Computer Hope
How to Save a File in Vi / Vim Editor in Linux - Tecmint
How to Save a File in Vi / Vim Editor & Quit - GeeksforGeeks