Which daemon handles power management events on a Linux system?
acpid
batteryd
pwrmgntd
psd
inetd
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)
Consider the following output from the command ls –i:
How would a new file named c.txt be created with the same inode number as a.txt (Inode 525385)?
ln –h a.txt c.txt
ln c.txt a.txt
ln a.txt c.txt
ln –f c.txt a.txt
ln –i 525385 c.txt
This command creates a hard link to a.txt with the name c.txt. The new file c.txt will have the same inode number as a.txt (Inode 525385).
A hard link is a directory entry that points to the same data blocks as another file. A hard link is indistinguishable from the original file, and it shares the same inode number, permissions, ownership, and timestamps. A hard link can only be created within the same file system, and it cannot link to directories or special files. A hard link increases the link count of the file, which is the number of directory entries that refer to the file. The link count can be seen by using the ls -l command. The file is only deleted when the link count reaches zero, which means that all the hard links to the file are removed.
The ln command is used to create hard links or symbolic links. The syntax of the ln command is:
ln [options] source target
The source is the name of the existing file, and the target is the name of the new link. By default, the ln command creates a hard link, unless the -s option is used to create a symbolic link. A symbolic link is a special file that contains the path to another file or directory. A symbolic link is different from a hard link, as ithas its own inode number, permissions, ownership, and timestamps. A symbolic link can link to any file or directory, even across file systems, and it does not affect the link count of the file. A symbolic link can be identified by the ls -l command, as it shows the link name followed by an arrow and the target name.
For example, to create a hard link to a.txt with the name c.txt, use the following command:
ln a.txt c.txt
This command will create a new file c.txt that has the same inode number as a.txt (Inode 525385). The output of the ls -i command will show something like:
525385 a.txt 525385 c.txt
To create a symbolic link to a.txt with the name b.txt, use the following command:
ln -s a.txt b.txt
This command will create a new file b.txt that has a different inode number than a.txt (Inode 526053), and contains the path to a.txt. The output of the ls -i command will show something like:
525385 a.txt 526053 b.txt -> a.txt
References:
Linux Hard and Soft Links - Linuxize
ln(1) - Linux manual page
How to Create Hard and Symbolic Links in Linux - How-To Geek
What output will be displayed when the user fred executes the following command?
echo ‘fred $USER’
fred fred
fred /home/fred/
‘fred $USER’
fred $USER
‘fred fred’
This output will be displayed when the user fred executes the following command:
echo 'fred $USER'
The echo command is a built-in Linux feature that prints out arguments as the standard output. The syntax of the echo command is:
echo [option] [string]
The option can modify the behavior of the echo command, such as enabling the interpretation of escape characters or omitting the newline after the output. The string is the text that is displayed as the output.
The single quotation marks (’ ') are used to enclose the string argument and prevent any expansion or substitution of the characters inside the quotation marks. This means that any variables, commands, or special characters inside the single quotation marks are treated as literal characters, not as expressions.
The $USER variable is a shell variable that holds the username of the current user. However, since it is enclosed in single quotation marks, it is not expanded to its value, but printed as it is.
Therefore, the command echo ‘fred $USER’ will print the string fred $USER as the output, without any changes. The output will be the same for any user who executes the command, not just fred.
The other outputs are incorrect for the following reasons:
A, fred fred: This output would be displayed if the $USER variable was expanded to its value, which is fred for the user fred. However, since the $USER variable is enclosed in single quotation marks, it is not expanded, but printed as it is.
B, fred /home/fred/: This output would be displayed if the $USER variable was expanded to its value, which is fred for the user fred, and then concatenated with the string /home/ to form a path. However, since the $USER variable is enclosed in single quotation marks, it is not expanded, but printed as it is. Also, there is no concatenation operator in the echo command, so the string /home/ would not be added to the output.
C, ‘fred $USER’: This output would be displayed if the single quotation marks were also printed as part of the output. However, the single quotation marks are not part of the string argument, but only used to enclose it and prevent any expansion or substitution. They are not displayed as the output.
E, ‘fred fred’: This output would be displayed if the single quotation marks were also printed as part of the output, and the $USER variable was expanded to its value, which is fred for the user fred. However, neither of these conditions are true. The single quotation marks are not part of the string argument, but only used to enclose it and prevent any expansion or substitution. They are not displayed as the output. The $USER variable is enclosed in single quotation marks, so it is not expanded, but printed as it is.
References:
How to use Echo Command in Linux (With Examples) - phoenixNAP
How to Use the Echo Command on Linux - How-To Geek
echo command in Linux with Examples - GeeksforGeeks
Which of the following commands redirects the output of ls to standard error?
ls >-1
ls <
ls >&2
ls >>2
ls |error
This command redirects the output of ls to standard error, which is file descriptor 2 by default. The syntax of the command is:
ls >& file_descriptor
The ls command is a utility that lists the files and directories in the current working directory or a specified directory. The >& symbol is a redirection operator that redirects the standard output of a command to another file descriptor, which can be a file, a device, or another stream. The file_descriptor is the number of the file descriptor to which the output is redirected.
Therefore, the command ls >&2 will run the ls command and redirect its output to file descriptor 2, which is standard error. This means that the output of ls will not be displayed on the screen, but sent to the standard error stream, which can be used for error handling or logging purposes.
The other commands are incorrect for the following reasons:
A, ls >-1: This command will not redirect the output of ls to standard error, but it will cause an error. The > symbol is a redirection operator that redirects the standard output of a command to a file or device, overwriting any existing content. The -1 argument is not a valid file name or device name, and it will cause the shell to report an error and exit.
B, ls < D, ls >>2: This command will not redirect the output of ls to standard error, but it will append the output of ls to a file named 2. The >> symbol is a redirection operator that redirects the standard output of a command to a file or device, appending to any existing content. The 2 argument is the name of the file to which the output is appended. If the file does not exist, it will be created. The command will not display anything on the screen, but write the output of ls to the file 2. E, ls |error: This command will not redirect the output of ls to standard error, but it will pipe the output of ls to another command named error. The | symbol is a pipe operator that redirects the standard output of one command to the standard input of another command. The error argument is the name of the command that receives the output of ls as its input. However, there is no such command named error in the Linux system, and the shell will report an error and exit.
Which umask value ensures that new directories can be read, written and listed by their owning user, read and listed by their owning group and are not accessible at all for everyone else?
0750
0027
0036
7640
0029
The umask value is a four-digit octal number that determines the default permissions for new files and directories created by a user. The umask value specifies the permissions that are not granted to the user, group, and others. The permissions are represented by three bits for each category, where 1 means execute, 2 means write, and 4 means read. The sum of these values indicates the combination of permissions. For example, 7 means read, write, and execute; 6 means read and write; 5 means read and execute; 4 means read only; 3 means write and execute; 2 means write only; 1 means execute only; and 0 means no permission.
The umask value is subtracted from the maximum permissions for files and directories, which are 666 and 777, respectively. The maximum permissions are then converted to binary and bitwise ANDed with the bitwise complement of the umask value. The result is the default permissions for the new files and directories. For example, if the umask value is 0027, the default permissions for a new file are:
666 - 027 = 639 639 in octal = 110 011 001 in binary 027 in octal = 000 010 111 in binary Bitwise complement of 027 = 111 101 000 in binary 110 011 001 AND 111 101 000 = 110 001 000 in binary 110 001 000 in binary = 608 in octal 608 in octal = rw- — —
The default permissions for a new directory are:
777 - 027 = 750 750 in octal = 111 101 000 in binary 027 in octal = 000 010 111 in binary Bitwise complement of 027 = 111 101 000 in binary 111 101 000 AND 111 101 000 = 111 101 000 in binary 111 101 000 in binary = 750 in octal 750 in octal = rwx r-x —
Therefore, the umask value of 0027 ensures that new files can be read and written by their owning user, and are not accessible at all for everyone else. New directories can be read, written and listed by their owning user, read and listed by their owning group, and are not accessible at all for everyone else.
References:
Umask command in Linux with examples - GeeksforGeeks
What Is umask in Linux, and How Do You Use It? - How-To Geek
What is UMASK and how to set UMASK in Linux/Unix? - Kernel Talks
What is true regarding the configuration of yum? (Choose two.)
Changes to the repository configuration become active after running yum confupdate
Changes to the yum configuration become active after restarting the yumd service
The configuration of package repositories can be divided into multiple files
Repository configurations can include variables such as $basearch or $releasever
In case /etc/yum.repos.d/ contains files, /etc/yum.conf is ignored
The configuration of yum can be divided into multiple files, and repository configurations can include variables such as $basearch or $releasever. The main configuration file for yum is /etc/yum.conf, which contains the global options for yum and can also define repositories in the [repository] sections. However, it is recommended to define individual repositories in separate files in the /etc/yum.repos.d/ directory, which can be easier to manage and maintain. Each file in this directory should have a .repo extension and contain one or more [repository] sections with the repository name, URL, and other options12. Repository configurations can use yum variables to dynamically set values for certain options, such as the baseurl or the enabled. Yum variables are enclosed in curly braces and start with a dollar sign, such as {$basearch} or {$releasever}. These variables are replaced by their actual values at runtime, based on the system architecture, the operating system version, or other factors. Some of the common yum variables are34:
$basearch: The base architecture of the system, such as x86_64, i386, or arm.
$releasever: The release version of the operating system, such as 7, 8, or 9.
$arch: The exact architecture of the system, such as x86_64, i686, or armv7hl.
$uuid: A unique identifier for the system, generated by the product-id plugin.
$YUM0-$YUM9: Custom variables that can be set by the user in the /etc/yum/vars/ directory or the /etc/yum.conf file.
The other options are false or irrelevant. There is no yum confupdate command or yumd service, and changes to the yum configuration become active immediately after saving the files. The /etc/yum.conf file is not ignored if the /etc/yum.repos.d/ directory contains files, but the repository options in the /etc/yum.conf file can be overridden by the options in the .repo files. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
How to Use Yum Variables to Enhance your Yum Experience - Red Hat …3
Yum Variables - CentOS4
Which of the following regular expressions represents a single upper-case letter?
:UPPER:
[A-Z]
!a-z
%C
{AZ}
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 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
A Debian package creates several files during its installation. Which of the following commands searches for packages owning the file /etc/debian_version?
apt-get search /etc/debian_version
apt –r /etc/debian_version
find /etc/debian_version -dpkg
dpkg –S /etc/debian_version
apt-file /etc/debian_version
The command that searches for packages owning the file /etc/debian_version is dpkg –S /etc/debian_version. The dpkg command is the low-level tool for installing, removing, configuring, and querying Debian packages. The -S or --search option takes a file name or a pattern as an argument and searches for the packages that contain the matching files. The output shows the package name and the file name separated by a colon. For example, running dpkg -S /etc/debian_version will produce the output base-files:/etc/debian_version, indicating that the file /etc/debian_version belongs to the base-files package. The other commands are either invalid or do not perform the desired task. The apt-get command is used to download and install packages from the Debian repositories, but it does not have a search option. The aptcommand is a high-level tool for managing packages, but it does not have a -r option. The find command is used to search for files in the file system, but it does not have a -dpkg option. The apt-file command is used to search for files in the packages available in the Debian repositories, but it requires a subcommand such as search or show before the file name or pattern. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
dpkg(1) - Linux manual page3
apt-get(8) - Linux manual page
apt(8) - Linux manual page
find(1) - Linux manual page
apt-file(1) - Linux manual page
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 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