LPIC-1 Exam 101, Part 1 of 2, version 5.0 Questions and Answers
The system configuration file named _______ is commonly used to set the default runlevel. (Please provide the file name with full path information)
Options:
Answer:
/etc/inittab
Explanation:
The system configuration file named /etc/inittab is commonly used to set the default runlevel. This file contains information about the initialization process of the system, and it defines the default runlevel, the available runlevels, and the actions to be taken when entering or leaving a runlevel. The default runlevel is the mode of operation that the system starts up into, and it determines which services and processes are running. The default runlevel is specified by a line similar to the following in the /etc/inittab file:
id:5:initdefault:
The number after the first colon indicates the default runlevel, which can range from 0 to 6. The meaning of each runlevel is:
- 0 — Halt
- 1 — Single-user text mode
- 2 — Not used (user-definable)
- 3 — Full multi-user text mode
- 4 — Not used (user-definable)
- 5 — Full multi-user graphical mode (with an X-based login screen)
- 6 — Reboot
To change the default runlevel, edit the /etc/inittab file as root and change the number to the desired runlevel. For example, to change the default runlevel to 3, use the following command:
sudo nano /etc/inittab
And change the line to:
id:3:initdefault:
Then save and exit the file. The changes will take effect on the next reboot.
References:
- SysV Init Runlevels - Red Hat Customer Portal
- init - How can I see or change default run level? - Ask Ubuntu
Which permissions and ownership should the file /etc/passwd have?
Options:
-rw-------1 rootroot531 Jun 5 22:45 /etc/passwd
-rw-r--r--1 rootroot531 Jun 5 22:45 /etc/passwd
-rw-r--r--1 11531 Jun 5 22:45 /etc/passwd
-rw-------1 11531 Jun 5 22:45 /etc/passwd
Answer:
BExplanation:
The correct permissions and ownership for the file /etc/passwd are:
B. -rw-r–r-- 1 root root 531 Jun 5 22:45 /etc/passwd
The /etc/passwd file is a plain text-based database that contains information for all user accounts on the system. It is owned by root and has 644 permissions. The file can only be modified by root or users with sudo privileges and readable by all system users. The permissions and ownership of the file are important for the security and functionality of the system. The permissions and ownership of the file can be viewed by using the ls -l command. For example:
ls -l /etc/passwd
The output of the command will show the following information:
-rw-r–r-- 1 root root 531 Jun 5 22:45 /etc/passwd
The first column shows the permissions of the file, which are composed of 10 characters. The first character indicates the file type, which is - for regular files. The next nine characters indicate the permissions for the user (owner), the group, and the others, respectively. Each set of three characters indicates the read ®, write (w), and execute (x) permissions. A dash (-) means no permission. In this case, the permissions are:
- rw- for the user, which means the user can read and write the file, but not execute it.
- r-- for the group, which means the group can only read the file, but not write or execute it.
- r-- for the others, which means the others can only read the file, but not write or execute it.
The second and third columns show the owner and the group of the file, which are both root. The root user is the superuser or the administrator of the system, who has full access and control over the system. The root group is the primary group of the root user, which usually has no other members.
The fourth column shows the size of the file in bytes, which is 531 in this case. The fifth and sixth columns show the date and time of the last modification of the file, which are Jun 5 22:45 in this case. The last column shows the name of the file, which is /etc/passwd in this case.
The other options are not correct because:
- A. -rw------- 1 root root 531 Jun 5 22:45 /etc/passwd: This option has the wrong permissions for the file. The permissions are 600, which means only the user (root) can read and write the file, and the group and the others have no permissions at all. This would prevent the system users from reading the file, which would cause problems for the login process and other utilities that rely on the file.
- C. -rw-r–r-- 1 1 531 Jun 5 22:45 /etc/passwd: This option has the wrong owner and group for the file. The owner and group are both 1, which is the numeric ID of the user and group. However, the numeric ID of the root user and group is 0, not 1. The user and group with the numeric ID of 1 are usually bin, which is a system user and group that own some system binaries and directories. Thebin user and group should not own the /etc/passwd file, as this would compromise the security and functionality of the system.
- D. -rw------- 1 1 531 Jun 5 22:45 /etc/passwd: This option has both the wrong permissions and the wrong owner and group for the file. The permissions are 600, which means only the user can read and write the file, and the owner and group are both 1, which is the numeric ID of the bin user and group. This would prevent the system users from reading the file, and give the bin user and group full access to the file, which would cause problems for the security and functionality of the system.
Which utility would be used to change how often a filesystem check is performed on an ext2 filesystem without losing any data stored on that filesystem?
Options:
mod2fs
fsck
tune2fs
mke2fs
fixe2fs
Answer:
CExplanation:
The utility that can be used to change how often a filesystem check is performed on an ext2 filesystem without losing any data stored on that filesystem is tune2fs. This command can adjust various parameters of a Linux ext2, ext3, or ext4 filesystem, such as the maximum mount count, the check interval, the reserved blocks percentage, and the default mount options. To change the check interval, the -i option can be used, followed by a time value. For example, to set the check interval to 180 days for the filesystem on /dev/sda1, the following command can be used:
sudo tune2fs -i 180d /dev/sda1
This command will modify the superblock of the filesystem, which contains the metadata and configuration information, without affecting the data stored on the filesystem. The other options are incorrect because they are not suitable for changing the check interval of an ext2 filesystem. Option A is wrong because there is no such utility as mod2fs. Option B is wrong because fsck is a utility for checking and repairing filesystems, not changing their parameters. Option D is wrong because mke2fs is a utility for creating ext2 filesystems, which will erase the existing data on the partition. Option E is wrong because there is no such utility as fixe2fs.
For more information on how to use the tune2fs command, you can refer to the following articles:
- 15 tune2fs command examples in Linux [Cheat Sheet] - GoLinuxCloud
- Linux tune2fs command With Examples - GeeksforGeeks
- tune2fs command-file system management - Linuxstar
- tune2fs Command Examples - Gianforte School of Computing
- tune2fs Command - IBM
Which of the following commands will change the quota for a specific user?
Options:
edquota
repquota
quota -e
quota
Answer:
AExplanation:
The correct command to change the quota for a specific user is edquota. 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. The repquota command displays a summary of the current quota usage and limits for the users or groups. The quota -e command turns off the disk quota for the current user. The quota command 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
Which of the following partition types is used for Linux swap spaces when partitioning hard disk drives?
Options:
82
83
8e
fd
7
Answer:
AExplanation:
Linux swap spaces are designated as type 82 on MBR (Master Boot Record) partition tables, which are used to store information about the partitions on a hard disk drive. This type code identifies the partition as a Linux swap area, which can be used by the Linux kernel to supplement the system RAM by holding idle memory pages. The mkswap command can be used to initialize a partition of type 82 as a swap partition. Other type codes are used for different purposes, such as 83 for Linux native partitions, 8e for Linux LVM partitions, fd for Linux RAID partitions, and 7 for NTFS partitions. References:
- How to create swap partition in Linux
- Choosing partition types for swap and root and choosing device for bootloader installation
- Creating and Using a Swap Partition
- Swap
Which of the following commands enables the setuid (suid) permission on the executable /bin/foo?
Options:
chmod 1755 /bin/foo
chmod 4755 /bin/foo
chmod u-s /bin/foo
chmod 755+s /bin/foo
Answer:
BExplanation:
The correct command to enable the setuid (suid) permission on the executable /bin/foo is:
B. chmod 4755 /bin/foo
The chmod command is used to change the permissions of files and directories in Linux. The chmod command can take either a symbolic or a numeric mode to specify the new permissions. The numeric mode is composed of four digits, each representing a different set of permissions: the first digit is for the special permissions, such as setuid, setgid, and sticky bit; the second digit is for the user permissions; the third digit is for the group permissions; and the fourth digit is for the others permissions. Each digit can range from 0 to 7, where 0 means no permissions, 1 means execute permission, 2 means write permission, 4 means read permission, and the sum of these values means a combination of permissions. For example, 5 means read and execute permissions, and 6 means read and write permissions.
The setuid permission is a special permission that allows an executable to run with the privileges of the owner of the file, instead of the user who launched it. The setuid permission is represented by the value 4 in the first digit of the numeric mode. For example, to enable the setuid permission on an executable file, use the following command:
chmod 4xxx file
where xxx is the combination of the user, group, and others permissions.
In this question, the executable file is /bin/foo, and the desired permissions are:
- setuid permission enabled
- user permissions: read, write, and execute
- group permissions: read and execute
- others permissions: read and execute
Therefore, the numeric mode for these permissions is 4755, where:
- 4 means setuid permission enabled
- 7 means user permissions: read, write, and execute
- 5 means group permissions: read and execute
- 5 means others permissions: read and execute
The correct command to enable the setuid permission on /bin/foo with these permissions is:
chmod 4755 /bin/foo
This command will change the permissions of /bin/foo to -rwsr-xr-x, where the s in the user section indicates the setuid permission.
The other options are not correct because:
- A. chmod 1755 /bin/foo: This command will enable the sticky bit, not the setuid permission, on /bin/foo. The sticky bit is another special permission that prevents users from deleting or renaming files that they do not own in a shared directory. The sticky bit is represented by the value 1 in the first digit of the numeric mode. For example, to enable the sticky bit on a directory, use the following command:
chmod 1xxx directory
where xxx is the combination of the user, group, and others permissions.
- C. chmod u-s /bin/foo: This command will disable the setuid permission, not enable it, on /bin/foo. The u-s option is a symbolic mode that means remove the setuid permission from the user permissions. For example, to disable the setuid permission on an executable file, use the following command:
chmod u-s file
- D. chmod 755+s /bin/foo: This command is not valid because it mixes the numeric and the symbolic modes, which are not compatible. The 755 is a numeric mode that means user permissions: read, write, and execute; group permissions: read and execute; others permissions: read and execute. The +s is a symbolic mode that means add the setuid and setgid permissions to the user and group permissions, respectively. The chmod command does not accept both numeric and symbolic modes at the same time, and it will fail with an error message saying:
chmod: invalid mode: ‘755+s’ Try ‘chmod --help’ for more information.
References:
- SetUID, SetGID, and Sticky Bits in Linux File Permissions - GeeksforGeeks
- How to use special permissions: the setuid, setgid and sticky bits - Linux Tutorials - Learn Linux Configuration
- chmod(1): change file mode bits - Linux man page
Which command is used to query information about the available packages on a Debian system?
Options:
apt-cache
apt-get
apt-search
dpkg
dpkg-search
Answer:
AExplanation:
The command apt-cache is used to query information about the available packages on a Debian system. This command can perform various operations on the package cache, such as searching for packages that match a given pattern, showing detailed information about a specific package, displaying the dependencies of a package, and more. The apt-cache command does not require root privileges and does not modify the system state12.
The other commands are either invalid or do not perform the same function as the correct answer. For example:
- apt-get is used to install, update, upgrade, remove, or purge packages on a Debian system. It requires root privileges and modifies the system state13.
- apt-search is not a valid command. The correct syntax to search for packages using the apt command is apt search1 .
- dpkg is a low-level tool that can install, remove, configure, or query information about Debian packages. It operates on individual packages and does not handle dependencies. It requires root privileges to install or remove packages1 .
- dpkg-search is not a valid command. The correct syntax to search for packages using the dpkg command is dpkg -l or dpkg-query -l1 .
References:
- LPI Linux Essentials, Chapter 6: Managing Software, Section 6.2: Debian Package Management
- apt-cache - query the APT cache | Linux Docs
- apt-get - APT package handling utility | Linux Docs
- [apt - command-line interface | Linux Docs]
- [dpkg - Debian package management system | Linux Docs]
Which of the following commands changes the number of days before the ext3 filesystem on /dev/sda1 has to run through a full filesystem check while booting?
Options:
tune2fs -d 200 /dev/sda1
tune2fs -c 200 /dev/sda1
tune2fs -i 200 /dev/sda1
tune2fs -n 200 /dev/sda1
tune2fs --days 200 /dev/sda1
Answer:
CExplanation:
The correct command to change the number of days before the ext3 filesystem on /dev/sda1 has to run through a full filesystem check while booting is tune2fs -i 200 /dev/sda1. This command sets the interval between two filesystem checks to 200 days. The tune2fs command allows you to view and change various filesystem parameters on Linux ext2, ext3, or ext4 filesystems. The -i option specifies the time interval between checks. The other options are incorrect because they use the wrong parameters for the tune2fs command. Option A is wrong because the -d option is not supported by the tune2fs command. Option B is wrong because the -c option sets the maximum number of mounts, not days, before a check. Option D is wrong because the -n option is not supported by the tune2fs command. Option E is wrong because the --days option is not supported by the tune2fs command. References:
- [LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
- 15 tune2fs command examples in Linux [Cheat Sheet] - GoLinuxCloud
- Linux tune2fs command With Examples - GeeksforGeeks
- tune2fs command-file system management - Linuxstar
- tune2fs Command Examples - Gianforte School of Computing
What is the purpose of the xargs command?
Options:
It passes arguments to an X server.
It reads standard input (STDIN) and builds up command lines to execute.
It helps shell scripts take variable argument lists.
It asks a question, graphically, and returns the answer to the shell.
It allows users to specify long options for commands that normally only accept short options.
Answer:
BExplanation:
The purpose of the xargs command is to read standard input (STDIN) and build up command lines to execute. The xargs command can be used to pass arguments to another command that does not accept input from a pipe. For example, rm | xargs echo will echo the arguments passed to the rm command. The xargs command can also limit the number of arguments per command line, insert arguments at different positions, and handle special characters in the input. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, xargs command
What does the command grub-install /dev/sda do?
Options:
GRUB creates partitions on the device/dev/sdato be used with Linux.
GRUB sets the default BIOS boot device to/dev/sda.
GRUB installs all required files and configures the boot loader on device/dev/sda.
GRUB recompiles the Linux Kernel and installs it on the Master Boot Record of device/dev/sda.
Answer:
CExplanation:
The grub-install command is used to install the GRUB boot loader on a device, such as a hard disk or a floppy disk. The command takes one argument, which is the device name where the boot loader should be installed. The command copies the GRUB files from the /boot/grub directory to the device and writes the boot code to the Master Boot Record (MBR) or the boot sector of the device. The command also creates a device map file in /boot/grub/device.map, which maps the BIOS device names to the Linux device names. The grub-install command is useful for setting up a dual-boot system or for repairing a broken GRUB installation. The command can also take various options to customize the installation, such as --boot-directory, --efi-directory, --removable, --force-lba, and --no-floppy. References:
- GNU GRUB Manual 2.06: Installing GRUB using grub-install
- grub-install Command Options – The Geek Diary
Which of the following commands can be used to search for the executable file foo when it has been placed in a directory not included in $PATH?
Options:
apropos
which
find
query
whereis
Answer:
CExplanation:
The correct command to search for the executable file foo when it has been placed in a directory not included in $PATH is find. The find command can search for files and directories based on various criteria, such as name, type, size, permissions, ownership, and more. To find the executable file foo, you can use the following command:
find / -type f -executable -name foo
This command will search the entire filesystem (/) for regular files (-type f) that are executable (-executable) and have the name foo (-name foo). The other commands are not suitable for this task. The apropos command searches the manual page names and descriptions for a keyword. The which command shows the full path of a command that is in the $PATH variable. The query command is not a standard Linux command. The whereis command locates the binary, source, and manual page files for a command, but only in the standard Linux directories. References:
- [LPI Linux Essentials - 1.1 The Linux Community and a Career in Open Source]
- [LPI Linux Essentials - 1.2 Finding Your Way on a Linux System]
- [LPI Linux Essentials - 1.3 Basic File Management]
- [LPI Linux Essentials - 1.4 Finding Files]
- [LPI Linux Essentials - 2.1 Using Devices, Linux Filesystems, Filesystem Hierarchy Standard]
- [LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
- [LPI Linux Essentials - 2.3 Disk Partitions]
- How to Use the find Command in Linux - How-To Geek
- Find Command in Linux (Find Files and Directories) | Linuxize
- find command in Linux with examples - GeeksforGeeks
- Use the Unix find command to search for files
Which of the following commands shows the definition of a given shell command?
Options:
where
stat
type
case
Answer:
CExplanation:
The type command shows the type of a given shell command, which can be one of the following: alias, keyword, function, builtin, or file. For example, type ls will show that ls is an alias for ls --color=auto. The type command can also show the full path of a file command, such as type grep will show that grep is /bin/grep. References: LPI Linux Essentials, type command
Which of the following commands changes the ownership of file.txt to the user dan and the group staff?
Options:
chown dan/staff file.txt
chown dan:staff file.txt
chown -u dan -g staff file.txt
chown dan -g staff file.txt
Answer:
BExplanation:
The correct command to change the ownership of file.txt to the user dan and the group staff is chown dan:staff file.txt. This command uses the colon (:) as a separator between the user and the group. The other options are incorrect because they use the wrong syntax or options for the chown command.Option A uses a slash (/) instead of a colon, which is not valid. Option C uses the -u and -g options, which are not supported by the chown command. Option D uses the -g option, which only changes the group, not the user. References:
- [LPI Linux Essentials - 1.3 Basic File Management]
- [LPI Linux Essentials - 2.1 Using Devices, Linux Filesystems, Filesystem Hierarchy Standard]
- [LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
- [LPI Linux Essentials - 2.3 Disk Partitions]
- Chown Command in Linux: How to Change File Ownership - phoenixNAP
- chown command in Linux with Examples - GeeksforGeeks
- Chown Command in Linux: How to Use It - Help Desk Geek
- Chown Command in Linux (File Ownership) | Linuxize
Which of the following apt-get commands will install the newest versions of all currently installed packages?
Options:
auto-update
full-upgrade
dist-upgrade
install
update
Answer:
BExplanation:
The apt-get command is used to interact with the APT package management system on Debian-based Linux distributions. The apt-get command has several subcommands that perform different operations on packages. One of these subcommands is full-upgrade, which is used to install the newest versions of all currently installed packages, along with their dependencies. The full-upgrade command also removes any packages that are no longer needed or that conflict with the upgraded packages. The full-upgrade command is equivalent to the dist-upgrade command, which is an older name for the same operation. The other options are not valid subcommands of apt-get. The auto-update option does not exist, the install option is used to install specific packages, not to upgrade them, the update option is used to update the list of available packages, not to install them, and the dist-upgrade option is the same as the full-upgrade option. References:
- APT-GET Command in Linux {Detailed Tutorial With Examples} - phoenixNAP
- Using apt-get Commands in Linux [Ultimate Guide] - It’s FOSS
- Ubuntu ‘apt-get’ list of commands (list, update, upgrade, cheatsheet …
Following the Filesystem Hierarchy Standard (FHS), where should binaries that have been compiled by the system administrator be placed in order to be made available to all users on the system?
Options:
Answer:
/usr/local/bin/
Explanation:
According to the Filesystem Hierarchy Standard (FHS), the /usr/local/ directory is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. The /usr/local/bin/ directory is for local binaries that are not managed by the distribution package manager. These binaries should be accessible to all users on the system. Therefore, binaries that have been compiled by the system administrator should be placed in /usr/local/bin/ to follow the FHS. References:
- Filesystem Hierarchy Standard - Linux Foundation
- Filesystem Hierarchy Standard (FHS) | Linux# - Geek University
Which Debian package management tool asks the configuration questions for a specific already installed package just as if the package were being installed for the first time? (Specify ONLY the command without any path or parameters.)
Options:
Answer:
dpkg-reconfigure
Explanation:
The command dpkg-reconfigure is a Debian package management tool that asks the configuration questions for a specific already installed package just as if the package were being installed for the first time. It can be used to reconfigure a package that was previously installed with default settings, or to change the settings of a package that requires user input during installation. It can also be used to fix a broken configuration file or to restore the original configuration file of a package. References:
- Debian Reference: Chapter 2. Debian package management
- LPI Linux Essentials: 1.3 Package Management
What is the difference between the --remove and the --purge action with the dpkg command?
Options:
--remove removes the program, --purge also removes the config files
--remove only removes the program, --purge only removes the config files
--remove removes a package, --purge also removes all packages dependent on it
--remove removes only the package file itself, --purge removes all files related to the package
Answer:
AExplanation:
The dpkg command is a tool to install, build, remove and manage Debian packages. The option --remove is used to remove an installed package, but it does not remove the configuration files that may have been modified by the user. The option --purge is used to remove an installed package and also delete its configuration files. This can be useful if the user wants to completely uninstall a package and start from scratch if it is reinstalled later. The syntax is: dpkg --remove package or dpkg --purge package. For example, dpkg --remove nginx will remove the nginx web server package, but it will leave the configuration files in /etc/nginxdpkg --purge nginx will remove the nginx package and also delete the configuration files in /etc/nginx1. The other options are not correct because:
- –remove only removes the program, --purge only removes the config files: This is false, because --purge also removes the program, not just the config files.
- –remove removes a package, --purge also removes all packages dependent on it: This is false, because --purge does not remove any other packages, only the specified one. To remove a package and its dependencies, the apt-get command can be used with the option --auto-remove2.
- –remove removes only the package file itself, --purge removes all files related to the package: This is false, because --remove also removes the files that are installed by the package, not just the package file itself. --purge only removes the configuration files that are not removed by --remove. References:
- dpkg(1) — dpkg — Debian buster — Debian Manpages
- How to remove a package and its dependencies with dpkg? - Ask Ubuntu
Which of the following options is used in a GRUB Legacy configuration file to define the amount of time that the GRUB menu will be shown to the user?
Options:
hidemenu
splash
timeout
showmenu
Answer:
CExplanation:
The timeout option in a GRUB Legacy configuration file is used to define the amount of time (in seconds) that the GRUB menu will be shown to the user before booting the default entry. The timeout option is usually located in the /boot/grub/menu.lst file. For example, timeout 10 will display the GRUB menu for 10 seconds. To disable the timeout and wait for user input indefinitely, the value of timeout can be set to -1. To boot immediately without displaying the menu, the value of timeout can be set to 0. The other options are not valid for the GRUB Legacy configuration file. References:
- GRUB Legacy - ArchWiki
- How do I set the grub timeout and the grub default boot entry?
- How to Remove the Timeout From GRUB Menu
Which of the following commands can be used to perform a full text search on all available packages on a Debian system?
Options:
apt
apt-cache
apt-get
apt-search
dpkg
Answer:
BExplanation:
The command apt-cache can be used to perform a full text search on all available packages on a Debian system. It searches the package names and the descriptions for an occurrence of the regular expression given as a keyword and prints out the package name and the short description1. The syntax is: apt-cache search keyword. For example, apt-cache search openssh will return a list of packages related to OpenSSH2. The other commands are not suitable for this task because:
- apt is a high-level command-line tool that provides a user-friendly way to manage packages, but it does not have a search option3.
- apt-get is a low-level command-line tool that handles the installation and removal of packages, but it does not have a search option4.
- apt-search is not a valid command.
- dpkg is a tool to install, build, remove and manage Debian packages, but it does not have a search option5. It can only list the installed packages with the option -l4. References:
- How To Search For Available Packages From Command Line In Debian, Ubuntu Or Linux Mint [APT] - Linux Uprising Blog
- apt(8) — apt — Debian buster — Debian Manpages
- How to List Installed Packages on Debian | Linuxize
- Debian / Ubuntu Linux search package names with apt-cache command
- dpkg(1) — dpkg — Debian buster — Debian Manpages
In which directory must definition files be placed to add additional repositories to yum?
- /etc/yum.repos.d
- /etc/yum.repos.d/
- yum.repos.d
- yum.repos.d/
Options:
Answer:
B
Explanation:
The /etc/yum.repos.d/ directory contains configuration files for additional yum repositories. Each file in this directory should end with .repo and contain information about one or more repositories. The yum command will read all the files in this directory and use them as sources for software packages. The format of the .repo files is similar to the /etc/yum.conf file, which contains the main configuration options for yum. Each .repo file can have one or more sections, each starting with [repository] where repository is a unique identifier for the repository. The section can have various options, such as name, baseurl, enabled, gpgcheck, etc. For example, a .repo file for the EPEL repository could look like this:
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
References:
- 2, 102.5 Use RPM and YUM package management
- 4, 101-500 Exam - Free Questions and Answers - ITExams.com
- man yum.conf
Which of the following commands lists all currently installed packages when using RPM package management?
Options:
yum --query --all
yum --list --installed
rpm --query --all
rpm --list –installed
Answer:
CExplanation:
The command that lists all currently installed packages when using RPM package management is rpm --query --all. This command displays information about all the packages that are currently installed on the system, including their name, version, release, and architecture1. The output can be customized by using various query options and format specifiers2.
The other commands are either invalid or related to YUM, not RPM. yum --query --all is not a valid YUM command, as YUM does not have a --query option3. yum --list --installed is a valid YUM command, but itlists the packages from the YUM repositories, not the RPM database3. rpm --list --installed is not a valid RPM command, as RPM does not have a --list option2.
References:
- RPM Command in Linux | Linuxize
- rpm(8) - Linux manual page
- Linux package management with YUM and RPM | Enable Sysadmin
What is the name of the main configuration file for GNU GRUB? (Specify the file name only without any path.)
- menu.lst
- grub.conf
- grub.cfg
Options:
Answer:
C
Explanation:
The main configuration file for GNU GRUB is grub.cfg, which is usually located in /boot/grub/ or /boot/grub2/ depending on the distribution. This file contains the menu entries for the boot loader, each with a title, a kernel image, an initrd image, and optional parameters. The grub.cfg file is not meant to be edited manually, as it is generated by the grub-mkconfig command, which reads the settings from /etc/default/grub and the scripts in /etc/grub.d/. The /etc/default/grub file contains the global options for GRUB, such as the default menu entry, the timeout, the theme, etc. The /etc/grub.d/ directory contains executable scripts that are run by grub-mkconfig to generate the menu entries for each operating system or kernel found on the system. For example, the script 10_linux generates the entries for the Linux kernels installed by the package manager, while the script 30_os-prober generates the entries for other operating systems detected on the system, such as Windows. To make changes to the GRUB configuration, one should edit the /etc/default/grub file and/or the scripts in /etc/grub.d/, and then run grub-mkconfig -o /boot/grub/grub.cfg to update the grub.cfg file. References:
- 2, 102.2 Install a boot manager
- 4, 102.2 Install a boot manager
- man grub-mkconfig
When using rpm --verify to check files created during the installation of RPM packages, which of the following information is taken into consideration? (Choose THREE correct answers.)
Options:
Timestamps
MD5 checksums
Inodes
File sizes
GnuPG signatures
Answer:
A, B, DExplanation:
When using rpm --verify to check files created during the installation of RPM packages, the following information is taken into consideration:
- Timestamps. RPM compares the modification time of the installed files with the original time stored in the RPM database. If the file has been modified after installation, the timestamp will differ and RPM will report it with an M flag1.
- MD5 checksums. RPM calculates the MD5 checksum of the installed files and compares it with the original checksum stored in the RPM database. If the file has been altered in any way, the checksum will differ and RPM will report it with an 5 flag1.
- File sizes. RPM compares the size of the installed files with the original size stored in the RPM database. If the file has been truncated or appended, the size will differ and RPM will report it with an S flag1.
RPM does not take into consideration the following information:
- Inodes. RPM does not check the inode number of the installed files, as it is not a reliable indicator of file identity. The inode number can change if the file is moved, copied, or restored from a backup2.
- GnuPG signatures. RPM does not verify the GnuPG signatures of the installed files, as they are not part of the RPM package format. The GnuPG signatures are used to verify the authenticity and integrity of the RPM package files before installation, not after3.
References:
- Using RPM to Verify Installed Packages
- inode(7) - Linux manual page
- RPM and GPG: How to verify Linux packages before installing them
Typically, which top level system directory is used for files and data that change regularly while the system is running and are to be kept between reboots? (Specify only the top level directory)
Options:
/var
/var/,
Var
var/
Answer:
AExplanation:
The top-level system directory that is used for files and data that change regularly while the system is running and are to be kept between reboots is /var. The /var directory contains variable data that changes in size as the system runs. For instance, log files, mail directories, databases, and printing spools are stored in /var. These files and data are not temporary and need to be preserved across system reboots. The /var directory is one of the few directories that are recommended to be on a separate partition, according to the Filesystem Hierarchy Standard (FHS)1. This is because the /var directory can grow unpredictably and fill up the / partition, which can cause system instability or failure. By having /var on a separate partition, we can limit the amount of disk space that can be used by variable data and prevent users from affecting the / partition. The /var directory is also a common target for malicious attacks, so having it on a separate partition can improve the security and isolation of the system. References:
- Filesystem Hierarchy Standard
Which RPM command will output the name of the package which supplied the file /etc/exports?
Options:
rpm -F /etc/exports
rpm -qf /etc/exports
rpm -Kl /etc/exports
rpm -qp /etc/exports
rpm -qi/etc/exports
Answer:
BExplanation:
The RPM command that will output the name of the package which supplied the file /etc/exports is rpm -qf /etc/exports. This command will query the RPM database and find the package that owns or provides the file /etc/exports1. The output will show the package name, version, release, and architecture. For example:
The other options are incorrect for the following reasons:
- rpm -F /etc/exports. This command will try to freshen or upgrade the package that contains the file /etc/exports, if it is already installed2. This command will not output the package name, but rather install the latest version of the package from a specified source. For example:
- rpm -Kl /etc/exports. This command is not valid, as RPM does not have a -Kl option. The -K option is used to verify the signatures of the RPM package files, not the installed files3. The -l option is used to list the files in a package, not to query the package name. For example:
- rpm -qp /etc/exports. This command will try to query the package information of the file /etc/exports, as if it was an RPM package file. This command will not output the package name, but rather an error message, as /etc/exports is not a valid RPM package file. For example:
- rpm -qi /etc/exports. This command will try to query the information of the package /etc/exports, as if it was an installed package name. This command will not output the package name, but rather an error message, as /etc/exports is not a valid package name. For example:
References:
- How to find which rpm package provides a specific file or library in RHEL / CentOS
- rpm(8) - Linux manual page
- rpm(8) - Linux manual page
- [rpm(8) - Linux manual page]
Which command will disable swapping on a device? (Specify ONLY the command without any path or parameters.)
- Swapoff
- /sbin/swapoff
Options:
Answer:
A
Explanation:
The swapoff command is used to disable swapping on a device or a file. It takes the path of the device or file as an argument, or -a to disable all swaps. Disabling swap can improve the performance of the system if there is enough physical memory, or it can be necessary if the swap size needs to be changed. However, disabling swap can also cause problems if the system runs out of memory and has no swap space to use. References:
- How to Disable Swap in Linux - Linux Handbook
- How to Permanently Disable Swap in Linux? - GeeksforGeeks
- LPI Linux Essentials - 1.1 Operating System Basics
When removing a package, which of the following dpkg options will completely remove the files including configuration files?
Options:
--clean
--delete
--purge
–remove
Answer:
CExplanation:
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. References:
- 1, 102.4 Lesson 1
- 3, 101-500 Exam - Free Questions and Answers - ITExams.com
- man dpkg
The dpkg-____ command will ask configuration questions for a specified package, just as if the package were being installed for the first time.
Options:
Answer:
dpkg-reconfigure
Explanation:
The dpkg-reconfigure command is used to reconfigure an already installed package. It asks configuration questions for the package, just as if the package were being installed for the first time. This can be useful if the user wants to change some settings or options for the package without reinstalling it. The dpkg-reconfigure command can also be used to fix a broken package configuration or to restore the default settings. References:
- dpkg-reconfigure(8) - Linux man page
- Linux Professional Institute: Exam 101 Objectives
Which world-writable directory should be placed on a separate partition in order to prevent users from being able to fill up the / filesystem? (Specify the full path to the directory.)
Options:
Answer:
/tmp
Answer:tmp,
Answer:/var/tmp/
Answer:/var/tmp/
Answer:A
Explanation:
The world-writable directory that should be placed on a separate partition in order to prevent users from being able to fill up the / filesystem is /tmp. This directory is used by applications and users to store temporary files, and it is world-writable by default. By creating a separate partition for /tmp, the amount ofspace available to users is limited, and the root filesystem is protected from being filled up by temporary files1.
To create a separate partition for /tmp, you can use the fdisk or parted command to create a new partition on the disk. Once the partition is created, you can format it with a filesystem such as ext4, and then mount it to the /tmp directory using the mount command. Finally, you can modify the /etc/fstab file to ensure that the partition is mounted automatically at boot time1. Here is an example of the steps to create a separate partition for /tmp:
After completing these steps, the /tmp directory will be mounted on a separate partition, and users will be limited in the amount of space they can use for temporary files.
References:
- LFCS: Linux World-Writable Directory Partitioning
Which of the following environment variables overrides or extends the list of directories holding shared libraries?
Options:
LD_LOAD_PATH
LD_LIB_PATH
LD_LIBRARY_PATH
LD_SHARE_PATH
LD_RUN_PATH
Answer:
CExplanation:
The environment variable that overrides or extends the list of directories holding shared libraries is LD_LIBRARY_PATH. This variable is used to specify a colon-separated list of directories where the dynamic linker should look for shared libraries when loading a program1. The directories in LD_LIBRARY_PATH are searched before the default directories, such as /lib and /usr/lib, or the directories specified in/etc/ld.so.conf or the executable’s rpath1. This variable can be useful for testing or debugging purposes, or for running programs that require a specific version of a library that is not installed in the system1.
The other options are incorrect for the following reasons:
- LD_LOAD_PATH. This is not a standard environment variable for shared libraries. It may be confused with LD_PRELOAD, which is a variable that allows the user to specify one or more shared libraries that should be loaded before any other library, even the C library2. This variable can be used to override or modify the behavior of certain functions or symbols in the libraries2.
- LD_LIB_PATH. This is not a standard environment variable for shared libraries. It may be confused with LIBPATH, which is a variable that is used on some Unix variants, such as AIX, to specify the search path for shared libraries3. On Linux, this variable has no effect4.
- LD_SHARE_PATH. This is not a standard environment variable for shared libraries. It may be confused with LD_RUN_PATH, which is a variable that allows the user to specify a list of directories that should be embedded in the executable as the rpath5. The rpath is a attribute that tells the dynamiclinker where to look for shared libraries at run time5. Unlike LD_LIBRARY_PATH, LD_RUN_PATH is only effective at link time, not at run time5.
- LD_RUN_PATH. This is not an environment variable that overrides or extends the list of directories holding shared libraries, but rather one that sets the rpath of the executable at link time. See the explanation for LD_SHARE_PATH above.
References:
- How to set the environmental variable LD_LIBRARY_PATH in Linux
- LD_PRELOAD - The secret of code injection into a running process without ptrace
- LIBPATH - Wikipedia
- linux - What is the difference between LD_LIBRARY_PATH and -L at link time? - Stack Overflow
- ld-linux(8) - Linux manual page
Which of the following commands can be used to create a USB storage media from a disk image?
Options:
gdisk
dd
cc
fdisk
mount
Answer:
BExplanation:
The command dd can be used to create a USB storage media from a disk image. The command dd is a low-level utility that can copy and convert data from one source to another, such as files, devices, or pipes. It can be used to create a bootable USB drive from an ISO image or a raw disk image. The syntax is: dd if=input of=output [options]. For example, to create a USB storage media from a disk image file named linux.img, the command would be:
dd if=linux.img of=/dev/sdb
This will copy the contents of linux.img to the device /dev/sdb, which is assumed to be the USB drive. The device name may vary depending on the system, so it is important to check the correct device name beforerunning the command. The command dd can also accept various options, such as bs to specify the block size, status to show the progress, or conv to apply conversions to the data. For example, to create a USB storage media from an ISO image file named linux.iso, with a block size of 4 MB and a progress indicator, the command would be:
dd if=linux.iso of=/dev/sdb bs=4M status=progress
The command dd is also known as "disk destroyer" because it can overwrite data without warning or confirmation. Therefore, it is advisable to use it with caution and backup any important data before using it. The other options are not correct because:
- gdisk is a command to create and manipulate GUID partition tables (GPT), but it does not create a USB storage media from a disk image1.
- cc is a command to compile C programs, but it does not create a USB storage media from a disk image2.
- fdisk is a command to create and manipulate DOS partition tables, but it does not create a USB storage media from a disk image3.
- mount is a command to mount file systems, but it does not create a USB storage media from a disk image4. References:
- How to Create a Bootable Linux USB Flash Drive, the Easy Way
- dd(1) — Linux manual page
- How to use the dd command in Linux - TechRepublic
- LPI Exam 101 Detailed Objectives, section 1.101.3
Which of the following commands will reduce all consecutive spaces down to a single space?
Options:
tr '\s' ' ' < a.txt > b.txt
tr -c ' ' < a.txt > b.txt
tr -d ' ' < a.txt > b.txt
tr -r ' ' '\n' < a.txt > b.txt
tr -s ' ' < a.txt > b.txt
Answer:
EExplanation:
The command that will reduce all consecutive spaces down to a single space is tr -s ’ ’ < a.txt > b.txt. This command uses the following options and syntax:
- -s: Squeezes repeated characters listed in the first set with single occurrence.
- ’ ': Specifies a space character as the first set.
- < a.txt: Redirects the input from a file named a.txt.
- b.txt: Redirects the output to a file named b.txt.
The output of this command will be a new file called b.txt that contains the same text as a.txt, except that any sequence of multiple spaces will be replaced by a single space. For example, if the file a.txt contains the following text:
This is a text file with multiple spaces.
The file b.txt will contain the following text:
This is a text file with multiple spaces.
The other commands are incorrect for the following reasons:
- A. tr ‘\s’ ’ ’ < a.txt > b.txt: This command will replace every whitespace character (\s) with a space character, which will not reduce the number of spaces, but rather convert tabs and newlines into spaces.
- B. tr -c ’ ’ < a.txt > b.txt: This command will complement the first set, meaning that it will apply the operation to all characters that are not spaces. This will not affect the spaces at all, but rather squeeze all other characters.
- C. tr -d ’ ’ < a.txt > b.txt: This command will delete all spaces from the input, which will not reduce them to a single space, but rather remove them completely.
- D. tr -r ’ ’ ‘\n’ < a.txt > b.txt: This command will replace all spaces with newlines, which will not reduce the spaces, but rather create a new line for each word.
References:
- [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.2: Process text streams using filters, Weight: 3, Key Knowledge Areas: Use of tr to translate characters or to squeeze and/or delete them.
- Tr Command in Linux with Examples, Topic: How to squeeze a sequence of repetitive characters using -s option.
When starting a program with the nice command without any additional parameters, which nice level is set for the resulting process?
Options:
-10
0
10
20
Answer:
CExplanation:
When starting a program with the nice command without any additional parameters, the nice level is set to 10 for the resulting process. This means that the process will have a lower priority than the default value of 0, and will be more willing to yield CPU time to other processes. The nice command can also take an optional argument -n followed by a number, which specifies the increment or decrement of the nice value from the default value of 0. For example, the command:
nice -n 5 /usr/bin/prog
will start the /usr/bin/prog process with a nice value of 5, which means a lower priority than the default. Similarly, the command:
nice -n -5 /usr/bin/prog
will start the /usr/bin/prog process with a nice value of -5, which means a higher priority than the default. If the -n argument is omitted, the nice command will assume a default increment of 10. For example, the command:
nice /usr/bin/prog
will start the /usr/bin/prog process with a nice value of 10, which means a very low priority. Note that only the root user can start a process with a negative nice value, as this requires special privileges.
References:
- [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.6: Modify process execution priorities, Weight: 2, Key Knowledge Areas: Know the default priority of a job that is created.
- How to Set Process Priorities With nice and renice on Linux, Topic: The nice Command.
When running the command
sed -e "s/a/b/" /tmp/file >/tmp/file
While /tmp/file contains data, why is /tmp/file empty afterwards?
Options:
The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
The command sed did not match anything in that file therefore the output is empty.
When the shell establishes the redirection it overwrites the target file before the redirected command starts and opens it for reading.
Redirection for shell commands do not work using the > character. It only works using the | character instead.
Answer:
CExplanation:
The problem with the command
sed -e “s/a/b/” /tmp/file >/tmp/file
is that it tries to read and write from the same file, which results in overwriting the file before the command can process it. The shell sets up the redirection by opening the file /tmp/file for writing and truncating it to zero length. Then it executes the sed command, which tries to read from the same file, but finds it empty. Therefore, the output is also empty and the file remains empty. A possible solution is to use a temporary file for the output and then rename it to the original file name. For example:
sed -e “s/a/b/” /tmp/file >/tmp/file.tmp && mv /tmp/file.tmp /tmp/file
This way, the original file is not overwritten until the sed command finishes successfully. The other options are either incorrect or not applicable. The file order is correct, the sed command does match something in the file, and the > character is valid for redirection. The | character is used for piping, not redirection. References:
- 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)
Which grep command will print only the lines that do not end with a / in the file foo?
Options:
grep'/$' foo
grep '/#' foo
grep -v '/$' foo
grep -v '/#' foo
Answer:
CExplanation:
∗∗Thegrepcommandthatwillprintonlythelinesthatdonotendwitha/inthefilefooisgrep−v′/’ 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.
References:
- [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use ofegrepto search for extended regular expressions in text output.
- [How to Use the grep Command on Linux], Topic: Start and End of Lines.
You are trying to make a hard link to an ordinary file but ln returns an error. Which of the following could cause this?
Options:
The source file is hidden.
The source file is read-only.
The source file is a shell script.
You do not own the source file.
The source and the target are on different filesystems.
Answer:
EExplanation:
A hard link is a directory entry that refers to the same inode as another file. An inode is a data structure that stores the metadata and the location of the data blocks of a file. A hard link allows multiple names to refer to the same file content, as long as they are on the same filesystem. However, if the source and the target of the hard link are on different filesystems, the ln command will return an error, because the inode numbers are not consistent across different filesystems. Therefore, the ln command cannot create a hard link that crosses filesystem boundaries. The other options are either incorrect or not applicable. The source file being hidden, read-only, a shell script, or not owned by the user does not prevent the creation of a hard link, as long as the user has the permission to write to the target directory and the source and the target are on the same filesystem. References:
- LPIC-1 Exam 101 Objectives, Topic 103: GNU and Unix Commands, 103.3 Perform basic file management
- LPIC-1 Linux Administrator 101-500 Exam FAQ, LPIC-1 Exam 101 Objectives, GNU and Unix Commands (Total Weight: 25)
Which of the following statements is correct regarding the command foo 1> bar?
Options:
The stdout from the command foo is appended to the file bar.
The stdout from the command foo overwrites the file bar.
The command foo receives its stdin from the file bar.
The command foo receives its stdin from the stdout of the command bar.
The stderr from the command foo is saved to the file bar.
Answer:
BExplanation:
The command foo 1> bar redirects the standard output (stdout) from the command foo to the file bar, overwriting the existing contents of the file. The number 1 before the redirection operator > indicates the file descriptor of the stdout stream, which is 1 by default. The redirection operator > means that the outputof the command is written to the file, replacing any previous data in the file. The file name after the redirection operator is the destination of the output. For example, if the command foo prints “Hello world” to the stdout, and the file bar contains “Goodbye world”, the command foo 1> bar will write “Hello world” to the file bar, erasing “Goodbye world”. The other options are not correct because:
- A. The stdout from the command foo is appended to the file bar: This is not what 1> does, because it overwrites the file, not appends to it. To append the output to the file, the operator >> should be used instead of >.
- C. The command foo receives its stdin from the file bar: This is not what 1> does, because it redirects the output, not the input. To redirect the input from the file, the operator < should be used instead of >.
- D. The command foo receives its stdin from the stdout of the command bar: This is not what 1> does, because it redirects the output to a file, not to another command. To redirect the output to another command, the operator | (pipe) should be used instead of >.
- E. The stderr from the command foo is saved to the file bar: This is not what 1> does, because it redirects the stdout, not the stderr. To redirect the stderr, the file descriptor 2 should be used instead of 1.
In Bash, inserting 1>&2 after a command redirects
Options:
standard error to standard input.
standard input to standard error.
standard output to standard error.
standard error to standard output.
standard output to standard input.
Answer:
CExplanation:
In Bash, inserting 1>&2 after a command redirects standard output to standard error. This means that the output of the command that normally goes to the standard output stream (file descriptor 1) will be sent to the standard error stream (file descriptor 2) instead. This can be useful if we want to capture or discard both the normal output and the error output of a command. For example, if we want to run a command and send both its output and error to /dev/null (a special device that discards any data written to it), we can use:
command > /dev/null 1>&2
This will redirect the standard output of command to /dev/null, and then redirect the standard error of command to the same place as the standard output, which is /dev/null. The other options are not correct because:
- A. standard error to standard input: This is not possible, because standard input is a read-only stream, and we cannot redirect output to it.
- B. standard input to standard error: This is not what 1>&2 does, because 1 refers to standard output, not standard input. To redirect standard input to standard error, we would need to use 0>&2, where 0 refers to standard input.
- D. standard error to standard output: This is not what 1>&2 does, because it would require the opposite order of file descriptors: 2>&1. This would redirect standard error to standard output, not the other way around.
- E. standard output to standard input: This is not possible, for the same reason as option A. References:
- Bash redirections cheat sheet
- How to redirect stderr to a file - Linuxize
What is the effect of the egrep command when the -v option is used?
Options:
It enables color to highlight matching parts.
It only outputs non-matching lines.
It shows the command's version information.
It changes the output order showing the last matching line first.
Answer:
BExplanation:
The -v option for the egrep command activates the invert matching mode, which means that it only outputs the lines that do not match the given pattern or regular expression. This is useful for filtering out unwanted lines or finding exceptions in a file. For example, the following command will output all the lines in the file my_text that do not contain the word “Linux”:
egrep -v Linux my_text
The -v option can be combined with other options to modify the output format or behavior of the egrep command. For example, the -c option will count the number of non-matching lines instead of printing them, and the -i option will ignore the case of the pattern while matching. References:
- [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.
- [Linux egrep Command with Examples], Topic: Invert Matching with egrep.
What is the purpose of the Bash built-in export command?
Options:
It allows disks to be mounted remotely.
It runs a command as a process in a subshell.
It makes the command history available to subshells.
It sets up environment variables for applications.
It shares NFS partitions for use by other systems on the network.
Answer:
DExplanation:
The export command is a Bash built-in command that exports environment variables and functions for use in other shell sessions1. Environment variables are named values that affect the behavior of applications and processes2. For example, the PATH variable stores a list of directories where executable programs are located, and the LANG variable sets the language and locale of the system2. By using the export command, you can make these variables available to any child process spawned by the current shell1. For example, if you want to set the EDITOR variable to vim for all subshells, you can run:
export EDITOR=vim
The export command can also be used to export functions, which are blocks of code that can be reused by invoking their name3. For example, if you want to create and export a function that prints “Hello world”, you can run:
hello () { echo “Hello world”; } export -f hello
Then, you can call the hello function in any subshell or script that inherits the environment from the current shell.
The other options are not related to the export command. Option A refers to the mount command, which attaches a filesystem to a directory4. Option B refers to the command substitution feature, which runs a command in a subshell and replaces it with its output5. Option C refers to the history command, which displays the command history of the current shell. Option E refers to the exportfs command, which maintains the table of exported NFS shares.
References:
- [LPI Linux Essentials - 1.3 Basic Editing]
- [LPI Linux Essentials - 1.4 I/O Redirection]
- [LPI Linux Essentials - 1.5 Manage Simple Partitions and Filesystems]
- Linux export Command with Examples - phoenixNAP
- bash - What does "export" do in shell programming? - Stack Overflow
- How to Use Export Command in Linux [Explained for Beginners]
- mount(8) - Linux manual page
- Command Substitution - Bash Reference Manual
- [history(3) - Linux manual page]
- [exportfs(8) - Linux manual page]
Which command is used in a Linux environment to create a new directory? (Specify ONLY the command without any path or parameters.)
- uk.co.certification.simulator.questionpool.PList@18e10a10
Options:
Answer:
A
Explanation:
The mkdir command is used in a Linux environment to create a new directory. The mkdir command takes one or more arguments that specify the name and path of the directory to be created. For example, mkdir foo will create a directory named foo in the current working directory, while mkdir /home/bar will create a directory named bar in the /home directory. The mkdir command can also create multiple directories at once by using the -p option, which creates any missing parent directories along the path. For example, mkdir -p /tmp/a/b/c will create the directories /tmp, /tmp/a, /tmp/a/b and /tmp/a/b/c if they do not exist already. References:
- LPIC-1 Exam 101 Objectives, Topic 103: GNU and Unix Commands, 103.3 Perform basic file management
- LPIC-1 Linux Administrator 101-500 Exam FAQ, LPIC-1 Exam 101 Objectives, GNU and Unix Commands (Total Weight: 25)
Which of the following commands prints all files and directories within the /tmp directory or its subdirectories which are also owned by the user root? (Choose TWO correct answers.)
Options:
find /tmp -uid root -print
find -path /tmp -uid root
find /tmp -user root -print
find /tmp -user root
find -path /tmp -user root –print
Answer:
A, CExplanation:
The find command is used to search for files and directories that match certain criteria. The -uid option specifies the numeric user ID of the owner of the file or directory, while the -user option specifies the name of the owner. The -print option prints the full file name of the matching file or directory to the standard output. Therefore, both find /tmp -uid root -print and find /tmp -user root -print will print all files and directories within the /tmp directory or its subdirectories which are also owned by the user root. The other options are either invalid or do not perform the desired task. The -path option matches the whole path name, not just the starting directory. The -print option is implied if no other action is specified, but it is good practice to include it for clarity. References:
- 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)
What does the + symbol mean in the following grep regular expression:
grep '^d[aei]\+d$' /usr/share/dict/words
Options:
Match the preceding character set ([aei]) one or more times.
Match the preceding character set ([aei]) zero or more times.
Match the preceding character set ([aei]) zero or one times.
Match a literal + symbol.
Answer:
AExplanation:
The + symbol in a grep regular expression means to match the preceding character or character set one or more times. In other words, it means to repeat the previous element at least once. For example, the regular expression ^d[aei]\+d$ will match any word that starts and ends with d and has one or more of the letters a, e or i in between. Some examples of words that match this pattern are dead, deed, died, daiid, etc. The other options are either incorrect or not applicable. The * symbol means to match the preceding character or character set zero or more times. The ? symbol means to match the preceding character or character set zero or one times. The \+ symbol means to match a literal + symbol, not a repetition modifier. References:
- LPIC-1 Exam 101 Objectives, Topic 103: GNU and Unix Commands, 103.3 Perform basic file management
- LPIC-1 Linux Administrator 101-500 Exam FAQ, LPIC-1 Exam 101 Objectives, GNU and Unix Commands (Total Weight: 25)
From a Bash shell, which of the following commands directly executes the instruction from the file /usr/local/bin/runme.sh without starting a subshell? (Please select TWO answers.)
Options:
source /usr/local/bin/runme.sh
. /usr/local/bin/runme.sh
/bin/bash /usr/local/bin/runme.sh
/usr/local/bin/runme.sh
run /usr/local/bin/runme.sh
Answer:
A, BExplanation:
The commands that directly execute the instruction from the file /usr/local/bin/runme.sh without starting a subshell are source /usr/local/bin/runme.sh and . /usr/local/bin/runme.sh. These commands use the source or dot builtins, which read and execute commands from the given file in the current shell environment. This means that any changes made by the file, such as setting variables, defining functions, or changing directories, will affect the current shell. This is different from running the file as a script, which will create a new shell process and execute the commands in a separate environment. The source or dot commands are useful for loading configuration files, such as ~/.bashrc or /etc/profile, or for running scripts that modify the current state of the shell.
The other commands are incorrect for the following reasons:
- C. /bin/bash /usr/local/bin/runme.sh: This command will run the file as a script using the /bin/bash interpreter. This will create a new shell process and execute the commands in a separate environment. Any changes made by the file will not affect the current shell.
- D. /usr/local/bin/runme.sh: This command will also run the file as a script, but using the interpreter specified by the shebang line (#!) at the beginning of the file. If the file does not have a shebang line, it will use the default shell interpreter, which may or may not be /bin/bash. This will also create a new shell process and execute the commands in a separate environment. Any changes made by the file will not affect the current shell.
- E. run /usr/local/bin/runme.sh: This command is not valid, as there is no builtin or external command called run. This will produce an error message.
References:
- [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.1: Work on the command line, Weight: 4, Key Knowledge Areas: Use of source and ..
- [Bash Reference Manual], Section 4.2: Bash Builtin Commands, Subsection 4.2.5: Bourne Shell Builtins.
Which of the following commands displays the contents of a gzip compressed tar archive?
Options:
gzip archive.tgz | tar xvf -
tar ztf archive.tgz
gzip -d archive.tgz | tar tvf -
tar cf archive.tgz
Answer:
BExplanation:
The command that displays the contents of a gzip compressed tar archive is tar ztf archive.tgz. This command uses the following options:
-z: Tells tar to read or write archives through gzip, allowing it to work on compressed files directly. -t: Lists the contents of an archive without extracting it. -f archive.tgz: Specifies the name of the archive file.
The output of this command will show the names of the files and directories stored in the archive, one per line. For example, if the archive contains three files named file1, file2, and file3, the output will be:
file1 file2 file3
The other commands are incorrect for the following reasons:
- gzip archive.tgz | tar xvf -: This command will decompress the archive using gzip and pipe it to tar, which will extract the files to the current directory. The - option tells tar to read the archive from the standard input. This command does not display the contents of the archive, but rather extracts them.
- gzip -d archive.tgz | tar tvf -: This command is similar to the previous one, except that it uses the -d option for gzip to decompress the archive instead of compressing it, and the -t option for tar to list the contents instead of extracting them. However, this command is redundant and inefficient, as tar can handle compressed archives directly with the -z option. Also, the -d option for gzip will delete the original archive file after decompression, which may not be desirable.
- tar cf archive.tgz: This command will create a new archive named archive.tgz from the files and directories given as arguments. However, this command does not use the -z option, so the archive will not be compressed with gzip. Also, this command does not display the contents of the archive, but rather creates it.
Which of the following regular expressions represents a single upper-case letter?
Options:
:UPPER:
[A-Z]
!a-z
%C
{AZ}
Answer:
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
Which of the following vi commands deletes two lines, the current and the following line?
Options:
d2
2d
2dd
dd2
de12
Answer:
CExplanation:
The correct answer is C, 2dd. This command will delete two lines, the current and the following line, in vi editor. The syntax of the command is:
[number]dd
The number specifies how many lines to delete, starting from the current line. The dd command deletes the lines and puts them in a buffer, which can be pasted later with the p command. If no number is given, the command will delete only the current line.
The other commands are incorrect for the following reasons:
- A, d2: This command will delete two characters, not two lines. The syntax of the command is:
d[motion]
The motion specifies how many characters to delete, starting from the current cursor position. The 2 motion means two characters to the right. The d command deletes the characters and puts them in a buffer, which can be pasted later with the p command.
- B, 2d: This command is incomplete and will not work. The d command requires a motion argument to specify how many characters to delete. The 2 argument is only a number, not a motion. The command will wait for another keystroke to complete the motion.
- D, dd2: This command will delete the current line and then move the cursor two lines down. The syntax of the command is:
dd[number]
The dd command deletes the current line and puts it in a buffer, which can be pasted later with the p command. The number specifies how many lines to move the cursor down, after deleting the current line. If no number is given, the command will move the cursor to the next line.
- E, de12: This command will delete from the current cursor position to the end of the word, and then move the cursor to the 12th line. The syntax of the command is:
d[motion][number]
The d command deletes the characters specified by the motion and puts them in a buffer, which can be pasted later with the p command. The e motion means the end of the word. The number specifies the line number to move the cursor to, after deleting the characters.
References:
- vi/vim delete commands and examples | alvinalexander.com
- How to Delete Lines in Vim / Vi | Linuxize
- How can I delete multiple lines in vi? - Stack Overflow
Given a log file loga.log with timestamps of the format DD/MM/YYYY:hh:mm:ss, which command filters out all log entries in the time period between 8:00 am and 8:59 am?
Options:
grep –E ‘:08:[09]+:[09]+’ loga.log
grep –E ‘:08:[00]+’ loga.log
grep –E loga.log ‘:08:[0-9]+:[0-9]+’
grep loga.log ‘:08:[0-9]:[0-9]’
grep –E ‘:08:[0-9]+:[0-9]+’ loga.log
Answer:
EExplanation:
The command that filters out all log entries in the time period between 8:00 am and 8:59 am is grep -E ‘:08:[0-9]+:[0-9]+’ loga.log. The grep command is used to search for a pattern in a file or standard input and print the matching lines. The -E or --extended-regexp option enables the use of extended regular expressions, which support more operators and syntax than the basic regular expressions. The pattern ‘:08:[0-9]+:[0-9]+’ is an extended regular expression that matches a colon followed by 08, followed by another colon, followed by one or more digits, followed by another colon, followed by one or more digits. This pattern matches any timestamp that has 08 as the hour part, which corresponds to the time period between 8:00 am and 8:59 am. The loga.log file is the name of the log file that contains the timestamps of the format DD/MM/YYYY:hh:mm:ss. For example, running grep -E ‘:08:[0-9]+:[0-9]+’ loga.log will produce an output like this:
01/01/2023:08:00:01 User logged in 01/01/2023:08:15:23 User performed an action 01/01/2023:08:30:45 User logged out 01/01/2023:08:45:12 User logged in again
The other commands are either invalid or do not perform the desired task. The grep -E ‘:08:[09]+:[09]+’ loga.log command will only match timestamps that have 0 or 9 as the minute and second parts, which is too restrictive. The grep -E ‘:08:[00]+’ loga.log command will only match timestamps that have 0 as the minute and second parts, which is too specific. The grep -E loga.log ‘:08:[0-9]+:[0-9]+’ command will not work, as the file name should come after the pattern, not before it. The grep loga.log ‘:08:[0-9]:[0-9]’ command will not work, as it uses a basic regular expression without the -E option, and it will only match timestamps that have one digit as the minute and second parts, which is too narrow.
Which of the following commands lists the dependencies of the RPM package file foo.rpm?
Options:
rpm –qpR foo.rpm
rpm –dep foo
rpm –ld foo.rpm
rpm –R foo.rpm
rpm –pD foo
Answer:
AExplanation:
The command that lists the dependencies of the RPM package file foo.rpm is rpm -qpR foo.rpm. The rpm command is the low-level tool for managing RPM packages on Linux systems. The -q or --query option isused to query information about installed or uninstalled packages. The -p or --package option is used to specify a package file instead of an installed package name. The -R or --requires option is used to list the capabilities that the package requires. The capabilities are usually the names of other packages, libraries, or files that the package depends on. The rpm command is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program .
The other options are either invalid or do not perform the desired task. The rpm -dep foo command does not exist, as -dep is not a valid option for rpm. The rpm -ld foo.rpm command does not list the dependencies of the package file, but the files in the package. The rpm -R foo.rpm command does not list the dependencies of the package file, but the capabilities that the package provides. The rpm -pD foo command does not exist, as -pD is not a valid option for rpm. References:
- Linux Essentials - Linux Professional Institute Certification Programs
- Exam 101 Objectives - Linux Professional Institute
- rpm(8) - Linux manual page
- RPM Package Manager - Wikipedia
Which command must be entered before exiting vi to save the current file as filea.txt?
Options:
%s filea.txt
%w filea.txt
:save filea.txt
:w filea.txt
:s filea.txt
Answer:
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
Which of the following commands displays the output of the foo command on the screen and also writes it to a file called /tmp/foodata?
Options:
foo | less /tmp/foodata
foo | cp /tmp/foodata
foo > /tmp/foodata
foo | tee /tmp/foodata
foo > stdout >> /tmp/foodata
Answer:
DExplanation:
This command will display the output of the foo command on the screen and also write it to a file called /tmp/foodata. The syntax of the command is:
foo | tee [options] [file]
The foo command is any command that produces some output. The | symbol is a pipe operator that redirects the standard output of one command to the standard input of another command. The tee command reads from the standard input and writes to both the standard output and one or more files. The options can modify the behavior of the tee command, such as appending to the file instead of overwriting it, or ignoring interrupt signals. The file is the name of the file to which the output is written. If no file is given, the tee command will only write to the standard output.
Therefore, the command foo | tee /tmp/foodata will run the foo command, pipe its output to the tee command, which will display the output on the screen and write it to the file /tmp/foodata.
The other commands are incorrect for the following reasons:
- A, foo | less /tmp/foodata: This command will not write the output of the foo command to a file, but it will display the output of the foo command on the screen in a pager. The less command is a program that allows the user to view and scroll through a file or the output of a command. The syntax of the command is:
foo | less [options] [file]
The foo command is any command that produces some output. The | symbol is a pipe operator that redirects the standard output of one command to the standard input of another command. The less command reads from the standard input or a file and displays it on the screen in a pager. The options can modify the behavior of the less command, such as setting the number of lines per screen, or searching for a pattern. The file is the name of the file to be viewed. If no file is given, the less command will read from the standard input.
Therefore, the command foo | less /tmp/foodata will run the foo command, pipe its output to the less command, which will display the output on the screen in a pager. However, the /tmp/foodata argument will be ignored by the less command, because it will read from the standard input instead of the file. The command will not write anything to the file /tmp/foodata.
- B, foo | cp /tmp/foodata: This command will not work as expected, because it has several errors. First, the cp command is not a valid command to write the output of a command to a file. The cp command is used to copy files or directories from one location to another. The syntax of the command is:
cp [options] source destination
The options can modify the behavior of the cp command, such as preserving the attributes of the files, or creating backups of the existing files. The source is the name of the file or directory to be copied. The destination is the name of the file or directory where the source is copied to.
Second, the pipe operator is not a valid way to redirect the output of a command to the cp command. The pipe operator redirects the standard output of one command to the standard input of another command. However, the cp command does not read from the standard input, but from the source argument. Therefore, the command foo | cp /tmp/foodata will run the foo command, pipe its output to the cp command, which will ignore the standard input and report an error for missing the destination argument. The command will not write anything to the file /tmp/foodata.
- C, foo > /tmp/foodata: This command will not display the output of the foo command on the screen, but it will write it to a file called /tmp/foodata. The > symbol is a redirection operator that redirects the standard output of a command to a file or device, overwriting any existing content. The syntax of the command is:
foo > file
The foo command is any command that produces some output. The > symbol redirects the standard output of the foo command to the file. The file is the name of the file to which the output is written.
Therefore, the command foo > /tmp/foodata will run the foo command, redirect its output to the file /tmp/foodata, and overwrite any previous content. The command will not display anything on the screen.
- E, foo > stdout >> /tmp/foodata: This command will not work as expected, because it has several errors. First, the stdout argument is not a valid file name or device name. The stdout is an abbreviation for the standard output, which is a stream that a program uses to write its output. However, the stdout is not a file or device that can be used as a destination for the redirection operator. Second, 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 syntax of the command is:
foo >> file
The foo command is any command that produces some output. The >> symbol redirects the standard output of the foo command to the file. The file is the name of the file to which the output is appended.
Therefore, the command foo > stdout >> /tmp/foodata will run the foo command, redirect its output to the stdout argument, which will cause an error, and then redirect its output again to the file /tmp/foodata, which will append the output to the file. The command will not display anything on the screen.
References:
- Linux Tee Command with Examples | Linuxize
- tee command in Linux with examples - GeeksforGeeks
- Linux tee command explained for beginners (6 examples) - HowtoForge
- Command Options and Examples of Tee Command in Linux - UbuntuPIT
- Linux tee Command Explained for Beginners (6 Examples) - Linux Handbook.
Given the following input stream:
txt1.txt
atxt.txt
txtB.txt
Which of the following regular expressions turns this input stream into the following output stream?
txt1.bak.txt
atxt.bak.txt
txtB.bak.txt
Options:
s/^.txt/.bak/
s/txt/bak.txt/
s/txt$/bak.txt/
s/^txt$/.bak^/
s/[.txt]/.bak$1/
Answer:
CExplanation:
The correct answer is C, s/txt$/bak.txt/. This regular expression will turn the input stream into the desired output stream by using the s command, which is used to substitute or replace a pattern with another pattern. The syntax of the s command is:
s/pattern/replacement/
The pattern is the regular expression that matches the text to be replaced, and the replacement is the text that replaces the matched text. The / symbol is used as a delimiter to separate the pattern and the replacement, but other characters can be used as well.
The pattern in this regular expression is txt$, which means that it will match the string txt at the end of the line. The $ symbol is an anchor that matches the end of the line. The replacement in this regular expression is bak.txt, which means that it will replace the matched string with the string bak.txt.
Therefore, the command s/txt$/bak.txt/ will replace the string txt at the end of each line with the string bak.txt, resulting in the following output stream:
txt1.bak.txt atxt.bak.txt txtB.bak.txt
The other regular expressions are incorrect for the following reasons:
- A, s/^.txt/.bak/: This regular expression will not work as expected, because it has several errors. First, the pattern in this regular expression is ^.txt, which means that it will match the string .txt at the beginning of the line. The ^ symbol is an anchor that matches the beginning of the line. However, none of the lines in the input stream start with .txt, so the pattern will not match anything. Second,the replacement in this regular expression is .bak, which means that it will replace the matched string with the string .bak. However, this will not produce the desired output, because it will not append the string .txt to the end of the line, but rather replace the existing string with .bak.
- B, s/txt/bak.txt/: This regular expression will not work as expected, because it has several errors. First, the pattern in this regular expression is txt, which means that it will match the string txt anywhere in the line, not just at the end. This will cause unwanted replacements in the middle of the words, such as atxt and txtB. Second, the replacement in this regular expression is bak.txt, which means that it will replace the matched string with the string bak.txt. However, this will not produce the desired output, because it will not preserve the original string, but rather replace it with bak.txt.
- D, s/txt$/.bak/: This regular expression will not work as expected, because it has several errors. First, the pattern in this regular expression is ^txt$, which means that it will match the string txt only if it is the entire line. The ^ and $ symbols are anchors that match the beginning and the end of the line, respectively. However, none of the lines in the input stream are exactly txt, so the pattern will not match anything. Second, the replacement in this regular expression is .bak^, which means that it will replace the matched string with the string .bak^. However, this will not produce the desired output, because it will not append the string .txt to the end of the line, but rather replace the existing string with .bak^, which is not a valid file name.
- E, s/[.txt]/.bak$1/: This regular expression will not work as expected, because it has several errors. First, the pattern in this regular expression is [.txt], which means that it will match any one of the characters inside the brackets, which are ., t, and x. This will cause unwanted replacements of single characters, such as the dot in the file extension or the letter t in the word atxt. Second, the replacement in this regular expression is .bak$1, which means that it will replace the matched character with the string .bak followed by the first backreference. A backreference is a way to refer to a part of the pattern that was captured by parentheses. However, there are no parentheses in the pattern, so the backreference $1 is invalid and will not work. Third, the replacement in this regular expression will not produce the desired output, because it will not append the string .txt to the end of the line, but rather replace the existing character with .bak$1, which is not a valid file name.
References:
- How to Use Regular Expressions (regexes) on Linux - How-To Geek
- How to Use Regular Expressions (RegEx) on Linux - GeeksforGeeks
- A beginner’s guide to regular expressions with grep - Red Hat Developer
- [Regular Expressions - Linux Documentation Project]
- [Regular Expressions in Linux Explained with Examples - Linux Handbook].
What is true regarding the configuration of yum? (Choose two.)
Options:
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
Answer:
C, DExplanation:
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 command uninstalls a package but keeps its configuration files in case the package is re-installed?
Options:
dpkg –s pkgname
dpkg –L pkgname
dpkg –P pkgname
dpkg –v pkgname
dpkg –r pkgname
Answer:
EExplanation:
The command that uninstalls a package but keeps its configuration files in case the package is re-installed is dpkg -r pkgname. The dpkg command is the low-level tool for installing, building, removing, and managing Debian packages. The -r or --remove option removes an installed package from the system, but it does not delete the configuration files and other data that belong to the package. This way, if the package is re-installed later, the previous settings are preserved. The dpkg command is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12.
The other options are either invalid or do not perform the desired task. The dpkg -s pkgname command shows the status of an installed package, but it does not uninstall it. The dpkg -L pkgname command lists the files that belong to an installed package, but it does not uninstall it. The dpkg -P pkgname command purges an installed or removed package, which means it deletes the configuration files and other data that belong to the package. The dpkg -v pkgname command shows the version of an installed package, but it does not uninstall it.
Which is the default percentage of reserved space for the root user on new ext4 filesystems?
Options:
10%
3%
15%
0%
5%
Answer:
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.)
Options:
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
Answer:
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 command displays the current disk space usage for all mounted file systems? (Specify ONLY the command without any path or parameters.)
Options:
Answer:
df
Explanation:
The command df displays the current disk space usage for all mounted file systems. It shows the size, used space, available space, percentage of usage, and mount point of each file system. By default, the output is in 1K blocks, but it can be changed with options like -h (human-readable), -B (block size), -i (inodes), and -T (type). The command df 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 Institute
A faulty kernel module is causing issues with a network interface card. Which of the following actions ensures that this module is not loaded automatically when the system boots?
Options:
Using lsmod --remove --autoclean without specifying the name of a specific module
Using modinfo –k followed by the name of the offending module
Using modprobe –r followed by the name of the offending module
Adding a blacklist line including the name of the offending module to the file /etc/modprobe.d/blacklist.conf
Deleting the kernel module’s directory from the file system and recompiling the kernel, including its modules
Answer:
DExplanation:
The action that ensures that a faulty kernel module is not loaded automatically when the system boots is adding a blacklist line including the name of the offending module to the file /etc/modprobe.d/blacklist.conf. This file contains a list of kernel modules that are prevented from loading by the modprobe command, which is used to load and unload modules from the running kernel. By adding a line like blacklist
- Linux Essentials - Linux Professional Institute Certification Programs1
- Exam 101 Objectives - Linux Professional Institute2
- Linux Kernel Module Management 101 - Linux.com1
- Chapter 2. Managing kernel modules - Red Hat Customer Portal2
What does the command mount --bind do?
Options:
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
Answer:
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 are valid stream redirection operators within Bash? (Choose two.)
Options:
<
#>
%>
>>>
2>&1
Answer:
A, EExplanation:
The stream redirection operators within Bash are used to redirect the input and output of commands to files, devices, or other commands. The valid stream redirection operators within Bash are:
- < : This operator redirects the standard input (STDIN) of a command from a file or device. For example, wc -l < file.txt counts the number of lines in file.txt by using it as the input for the wc command.
- > : This operator redirects the standard output (STDOUT) of a command to a file or device, overwriting any existing content. For example, echo "Hello World" > file.txt writes the string “Hello World” to file.txt, replacing any previous content.
- >> : This operator redirects the standard output (STDOUT) of a command to a file or device, appending to any existing content. For example, echo "Hello World" >> file.txt writes the string “Hello World” to file.txt, without deleting any previous content.
- >& : This operator redirects one file descriptor to another file descriptor. A file descriptor is a number that represents an open file or device. The standard input (STDIN) has the file descriptor 0, the standard output (STDOUT) has the file descriptor 1, and the standard error (STDERR) has the file descriptor 2. For example, command > file 2>&1 redirects both the standard output and standard error of the command to the file.
- <& : This operator redirects one file descriptor from another file descriptor. For example, command <&3 redirects the standard input of the command from the file descriptor 3.
The other operators are not valid stream redirection operators within Bash. They will cause syntax errors or unexpected behavior. For example, #> is a comment followed by a redirection operator, %> is a modulo operator followed by a redirection operator, and >>> is a bitwise right shift operator followed by a redirection operator.
References:
- Redirections (Bash Reference Manual)
- Guide to Stream Redirections in Linux | Baeldung on Linux
- Standard Streams in Bash | Delft Stack
- Bash Tutorial => Redirection
- stream redirection order and what os perform in details
You are having some trouble with a disk partition and you need to do maintenance on this partition but your users home directories are on it and several are logged in. Which command would disconnect the users and allow you to safely execute maintenance tasks?
Options:
telinit 1
shutdown -r now
killall -9 inetd
/bin/netstop --maint
/etc/rc.d/init.d/network stop
Answer:
AExplanation:
The command that would disconnect the users and allow you to safely execute maintenance tasks on a disk partition is telinit 112. The telinit command is used to change the runlevel of the system, which is a mode of operation that defines what processes and services are running3. The runlevel 1, also known as single-user mode, is a mode that allows only the root user to log in, and disables all network services and graphical interfaces4. This mode is useful for performing system maintenance and recovery tasks, such as repairing a disk partition5.
The other options in the question are not correct because:
- B. shutdown -r now: This command would reboot the system immediately, without disconnecting the users gracefully or allowing you to do any maintenance tasks.
- C. killall -9 inetd: This command would kill the inetd process, which is a daemon that manages network services. This would not disconnect the users who are already logged in, and it would not stop other processes that might interfere with the maintenance tasks.
- D. /bin/netstop --maint: There is no such command in Linux.
- E. /etc/rc.d/init.d/network stop: This command would stop the network service, which would disconnect the users who are logged in remotely, but not the ones who are logged in locally. It would also not stop other processes that might interfere with the maintenance tasks.
References:
1: How to Change Runlevels (targets) in SystemD - Tecmint 2: How to Boot into Single User Mode in CentOS/RHEL 7 - Tecmint 3: Runlevel - Wikipedia 4: Single-user mode - Wikipedia 5: How to Repair a Corrupted Linux File System - Linux.com : [shutdown(8) - Linux manual page] : [inetd(8) - Linux manual page] : [How to Start/Stop or Enable/Disable firewalld on CentOS 7 - Tecmint]
Which command displays the contents of the Kernel Ring Buffer on the command line? (Provide only the command name without any options or path information)
Options:
Answer:
dmesg,
Explanation:
The command that displays the contents of the Kernel Ring Buffer on the command line is dmesg12. The dmesg command is a Linux utility that displays kernel-related messages retrieved from the kernel ring buffer12. The ring buffer stores information about hardware, device driver initialization, and messages fromkernel modules that take place during system startup12. The dmesg command is invaluable when troubleshooting hardware-related errors, warnings, and for diagnosing device failure2.
The dmesg command can be used with various options to control the output format, filter the messages by facility or level, clear the ring buffer, or follow the new messages in real time123. For example, the following command displays the last 10 messages from the kernel ring buffer:
$ dmesg | tail -10
The following command displays the messages from the kernel ring buffer in a human-readable format with colored output:
$ dmesg -H --color
The following command displays the messages from the kernel ring buffer that have the facility kern and the level emerg:
$ dmesg -f kern -l emerg
The following command clears the ring buffer:
$ dmesg --clear
The following command keeps dmesg running and waiting for new messages:
$ dmesg -w
References:
1: dmesg Linux Command {Syntax, Options and Examples} - phoenixNAP 2: Ubuntu Manpage: dmesg - print or control the kernel ring buffer 3: Display Recent Kernel Messages (console, kernel ring buffer, facilities)
The message "Hard Disk Error" is displayed on the screen during Stage 1 of the GRUB boot process. What does this indicate?
Options:
The kernel was unable to execute /bin/init
The next Stage cannot be read from the hard disk because GRUB was unable to determine the size and geometry of the disk
One or more of the filesystems on the hard disk has errors and a filesystem check should be run
The BIOS was unable to read the necessary data from the Master Boot Record to begin the boot process
Answer:
BExplanation:
The GRUB boot process consists of three stages1:
- Stage 1: This stage is located in the Master Boot Record (MBR) of the first hard disk or the boot sector of a partition. Its main function is to load either Stage 1.5 or Stage 22.
- Stage 1.5: This stage is located in the first 30 KB of hard disk immediately following the MBR or in the boot sector of a partition. It contains the code to access the file system that contains the GRUB configuration file. Its main function is to load Stage 22.
- Stage 2: This stage is located in an ordinary file system, usually in the /boot/grub directory. It contains the code to display the GRUB menu and to load the kernel and initrd images. It can also load additional modules to support other file systems or features2.
The message “Hard Disk Error” is displayed on the screen during Stage 1 of the GRUB boot process. This indicates that the next Stage (either Stage 1.5 or Stage 2) cannot be read from the hard disk because GRUB was unable to determine the size and geometry of the disk3. This could occur because the BIOS translated geometry has been changed by the user or the disk is moved to another machine or controller after installation, or GRUB was not installed using itself (if it was, the Stage 2 version of this error would have been seen during that process and it would not have completed the install)3.
The other options in the question are not correct because:
- A. The kernel was unable to execute /bin/init: This error would occur in Stage 2, after the kernel and initrd images are loaded, not in Stage 14.
- C. One or more of the filesystems on the hard disk has errors and a filesystem check should be run: This error would also occur in Stage 2, when GRUB tries to access the file system that contains the GRUB configuration file, not in Stage 15.
- D. The BIOS was unable to read the necessary data from the Master Boot Record to begin the boot process: This error would prevent GRUB from starting at all, not in Stage 16.
References:
1: GRUB - ArchWiki 2: GNU GRUB Manual 0.97 3: Stage1 errors - GNU GRUB Manual 0.97 4: [Kernel panic - Wikipedia] 5: [Stage2 errors - GNU GRUB Manual 0.97] 6: [Master Boot Record - Wikipedia] : How to Fix GRUB Load Errors and Recover Data? - MiniTool Home Data Recovery
Which of the following information is stored within the BIOS? (Choose TWO correct answers.)
Options:
Boot device order
Linux kernel version
Timezone
Hardware configuration
The system's hostname
Answer:
A, DExplanation:
The BIOS (Basic Input/Output System) is a firmware that is stored in a ROM chip on the motherboard and is responsible for initializing the hardware and loading the bootloader. The BIOS has a setup utility that allows the user to configure various settings, such as the boot device order, the hardware configuration, the system date and time, the security options, etc. The BIOS does not store information about the Linux kernel version, the time zone, or the system’s hostname, as these are part of the operating system and are not relevant for the BIOS. References: LPI Linux Essentials - 1.101.1, LPI Linux Administrator - 102.1
Which of the following kernel parameters instructs the kernel to suppress most boot messages?
Options:
silent
verbose=0
nomesg
quiet
Answer:
DExplanation:
The quiet kernel parameter instructs the kernel to suppress most boot messages, except for critical errors12. The quiet parameter can be added to the GRUB_CMDLINE_LINUX_DEFAULT variable in the /etc/default/grub file and then run sudo update-grub to apply the changes3. The quiet parameter can also be used in combination with other parameters, such as splash, to enable a graphical boot screen4.
The other options in the question are not valid or do not have the same functionality as the quiet parameter:
- silent: There is no such kernel parameter in Linux.
- verbose=0: This parameter is used to set the verbosity level of the kernel messages, but it does not suppress them completely. The valid values for this parameter are from 0 (quiet) to 7 (debug)5.
- nomesg: This parameter is used to disable all kernel messages on the console, including the emergency ones. This parameter is not recommended for normal use, as it can hide critical errors and prevent troubleshooting.
References:
1: Getting the Kernel Command-Line Parameters | Baeldung on Linux 2: How to mute kernel messages at startup in Arch Linux? 3: boot - How to turn off the filesystem check message which occures while booting - Ask Ubuntu 4: [How to enable a graphical boot screen on Ubuntu 18.04 LTS - LinuxConfig.org] 5: [Kernel parameters - ArchWiki] : [Linux Kernel Parameters - SysTutorials]
Which command will display messages from the kernel that were output during the normal boot sequence?
Options:
Answer:
dmesg
Explanation:
The command dmesg will display messages from the kernel that were output during the normal boot sequence. The dmesg command reads the kernel ring buffer, which is a data structure that stores the most recent messages generated by the kernel. The dmesg command can also be used to display messages from the kernel that were output after the boot sequence, such as hardware events, driver messages, or system errors. The dmesg command has various options to filter, format, or save the output. For example, dmesg -T will display human-readable timestamps for each message, and dmesg -w will display the messages in real time as they occur. References:
- 1: How to view all boot messages in Linux after booting? - Super User
- 2: dmesg(1) - Linux manual page
- 3: Kernel ring buffer - Wikipedia
Which of the following commands reboots the system when using SysV init? (Choose TWO correct answers.)
Options:
shutdown -r now
shutdown -r "rebooting"
telinit 6
telinit 0
shutdown -k now "rebooting"
Answer:
A, CExplanation:
The shutdown command is used to bring the system down in a safe and controlled way. It can take various options and arguments, such as the time of shutdown, the message to broadcast to users, the halt or reboot mode, etc. The option -r instructs the shutdown command to reboot the system after shutting down. The argument now means to shut down immediately. Therefore, shutdown -r now will reboot the system without delay. The telinit command is used to change the run level of the system. It takes a single argument that specifies the new run level. The run level 6 is reserved for rebooting the system. Therefore, telinit 6 will also reboot the system. The other options are either incorrect or irrelevant. shutdown -r “rebooting” will also reboot the system, but with a delay of one minute and a message to the users. telinit 0 will halt the system, not reboot it. shutdown -k now “rebooting” will only send a warning message to the users, but not actually shut down or reboot the system. References: LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 101.3
During a system boot cycle, what program is executed after the BIOS completes its tasks?
Options:
The bootloader
The inetd program
The init program
The kernel
Answer:
AExplanation:
The bootloader is a program that is executed by the BIOS after it completes its tasks of initializing the hardware and performing the POST (Power-On Self Test). The bootloader is responsible for loading the kernel and other necessary files into memory and passing control to the kernel. The bootloader can be either installed in the Master Boot Record (MBR) of the disk or in a separate partition. Some examples of bootloaders are GRUB, LILO, and SYSLINUX. References: LPI Linux Essentials - 1.101.1, LPI Linux Administrator - 102.1
Which of the following are init systems used within Linux systems? (Choose THREE correct answers.)
Options:
startd
systemd
Upstart
SysInit
SysV init
Answer:
B, C, EExplanation:
systemd, Upstart, and SysV init are all init systems used within Linux systems. An init system is the first process executed by the kernel at boot time, which has a process ID (PID) of 1, and is responsible for starting and managing all other processes on the system. Different init systems have different features, advantages, and disadvantages. Some of the most common init systems are:
- systemd: A relatively new and modern init system that aims to provide a unified and efficient way of managing system and service states. It is compatible with SysV and LSB init scripts, and supports features such as parallel processing, socket activation, logging, job scheduling, and more. It is the default init system for many popular Linux distributions, such as Fedora, Debian, Ubuntu, Arch Linux, and others12.
- Upstart: An event-based init system developed by Ubuntu as a replacement for SysV init. It starts and stops system tasks and processes based on events, such as hardware changes, network availability, filesystem mounting, etc. It is a hybrid init system that uses both SysV and systemd scripts, and supports features such as parallel processing, dependency tracking, logging, and more. It is the default init system for some older versions of Ubuntu, and some other Linux distributions, such as Linux Mint and Chrome OS12.
- SysV init: A mature and traditional init system that follows the System V (SysV) design of Unix operating systems. It uses a series of runlevels to define the state of the system, and executes scripts in the /etc/rc.d or /etc/init.d directories according to the current runlevel. It is simple and stable, but lacks some features of modern init systems, such as parallel processing, event handling, dependency tracking, etc. It is still used by some Linux distributions, such as Slackware, Gentoo, and others12.
References: 1: 6 Best Modern Linux ‘init’ Systems (1992-2023) - Tecmint 2: 10 Best Linux init systems as of 2023 - Slant.
Which of the following statements is correct when talking about /proc/?
Options:
All changes to files in /proc/ are stored in /etc/proc.d/ and restored on reboot.
All files within /proc/ are read-only and their contents cannot be changed.
All changes to files in /proc/ are immediately recognized by the kernel.
All files within /proc/ are only readable by the root user.
Answer:
CExplanation:
The /proc/ directory is a virtual filesystem that provides a view of the kernel’s data structures and parameters. It contains information about processes, hardware, memory, modules, and other aspects of thesystem. The files in /proc/ are not stored on disk, but are generated on the fly by the kernel when they are accessed. Therefore, any changes to files in /proc/ are immediately recognized by the kernel and affect its behavior. For example, writing a value to /proc/sys/kernel/hostname will change the system’s hostname without rebooting. The files in /proc/ are not all read-only; some of them can be modified by the root user or by processes with the appropriate permissions. The files in /proc/ are readable by any user, unless restricted by the kernel or by the mount options. References: LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 102.3
You suspect that a new ethernet card might be conflicting with another device. Which file should you check within the /proc tree to learn which IRQs are being used by which kernel drivers?
Options:
Answer:
proc/interrupts
Explanation:
The file that you should check within the /proc tree to learn which IRQs are being used by which kernel drivers is /proc/interrupts1 Comprehensive Explanation: The /proc/interrupts file is a virtual file that provides information about the number and type of interrupts per CPU per I/O device12. It displays the IRQ number, the number of that interrupt handled by each CPU core, the interrupt type, and a comma-delimited list of drivers that are registered to receive that interrupt12. For example, the following output shows the contents of /proc/interrupts on a system with two CPUs and several devices:
The first column shows the IRQ number, followed by one column for each CPU core showing the number of interrupts handled by that core. The last column shows the interrupt type and the driver name. Some interrupt types are:
- IO-APIC-edge: An edge-triggered interrupt from the I/O Advanced Programmable Interrupt Controller (APIC), which is a hardware device that handles and distributes interrupts.
- IO-APIC-fasteoi: A fast end-of-interrupt from the I/O APIC, which means that the interrupt is acknowledged early to allow nesting interrupts.
- PCI-MSI-edge: A Message Signaled Interrupt (MSI) from the Peripheral Component Interconnect (PCI) bus, which is a hardware bus that connects devices to the system. MSI is a method of sending interrupts using special messages instead of dedicated lines.
- NMI: A Non-Maskable Interrupt, which is a hardware interrupt that cannot be ignored by the CPU and usually indicates a critical error.
- LOC: A Local timer interrupt, which is a periodic interrupt generated by a local APIC on each CPU core for scheduling purposes.
- RES: A Rescheduling interrupt, which is a type of inter-processor interrupt (IPI) that is sent to a CPU core to force it to reschedule its current task.
To check if a new ethernet card might be conflicting with another device, you can look for the driver name of the ethernet card in the /proc/interrupts file and see if it shares the same IRQ number with another device. If so, you can try to change the IRQ assignment of the devices or use the smp_affinity file to control which CPU cores can handle the interrupt12.
References:
1: 4.3. Interrupts and IRQ Tuning - Red Hat Customer Portal 2: What are the non-numeric IRQs in /proc/interrupts?
Which SysV init configuration file should be modified to disable the ctrl-alt-delete key combination?
Options:
/etc/keys
/proc/keys
/etc/inittab
/proc/inittab
/etc/reboot
Answer:
CExplanation:
The /etc/inittab file is used by the SysV init system to configure the behavior of different runlevels and the actions to be taken when certain events occur. One of the events that can be configured is the ctrl-alt-delete key combination, which by default triggers a system reboot. To disable this feature, the /etc/inittab file should be modified to comment out or remove the line that starts with ca::ctrlaltdel:. References: LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 101.1