Which of the following commands is used to update the list of available packages when using dpkg based package management?
apt-get update
apt-get upgrade
apt-cache update
apt-get refresh
apt-cache upgrade
The command that is used to update the list of available packages when using dpkg based package management is apt-get update12. The apt-get command is a high-level tool that works with dpkg and provides a user-friendly interface for managing packages3. The apt-get update command is used to synchronize the package index files from the sources specified in the /etc/apt/sources.list file12. This command does not install or upgrade any packages, but only downloads the information about the latest versions and dependencies of the packages12. The apt-get update command is usually run before the apt-get upgrade or apt-get install commands, which are used to upgrade or install packages respectively12.
The other options in the question are not correct because:
References:
1: How To Manage Packages Using apt-get, apt-cache, apt-file and dpkg Commands In Debian Based Systems 2: Ubuntu Manpage: apt-get - APT package handling utility – command-line interface 3: dpkg - Debian Wiki 4: Ubuntu Manpage: apt-cache - query the APT cache
Which option to the yum command will update the entire system? (Specify ONLY the option name without any additional parameters.)
update/upgrade
The yum command is a tool for managing software packages on Red Hat Enterprise Linux and other RPM-based systems. The yum update option will update the entire system by checking the versions of the installed packages and installing the latest available versions from the repositories. The yum upgrade option will do the same, but it will also remove any obsolete packages that are no longer needed by the system. Both options will prompt the user to confirm before proceeding with the update or upgrade process. References:
To prevent users from being able to fill up the / partition, the ____________ directory should be on a separate partition if possible because it is world writeable.
/tmp
tmp
The /tmp directory should be on a separate partition if possible because it is world writable. This means that any user can create, modify, or delete files and directories in /tmp. This can pose a risk of filling up the / partition, which can cause system instability or failure. By having /tmp on a separate partition, we can limit the amount of disk space that can be used by temporary files and prevent users from affecting the / partition. The /tmp 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. The /tmp directory is one of the few directories that are world writable by default, according to the Filesystem Hierarchy Standard (FHS)1. The other directories that are usually world writable are /var/tmp and /var/lock, which are also used for temporary or lock files. However, these directories are not as frequently used or as large as /tmp, so they are less likely to fill up the / partition. The /tmp directory also has the sticky bit set, which means that only the owner of a file or directory can delete or rename it2. This prevents users from deleting or modifying other users’ files in /tmp. However, this does not prevent users from creating new files or directories in /tmp, which can still consume disk space and resources. Therefore, it is advisable to have /tmp on a separate partition if possible. References:
Which command will disable swapping on a device? (Specify ONLY the command without any path or parameters.)
A
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:
Which of the following commands lists the dependencies of a given dpkg package?
apt-cache depends-onpackage
apt-cache dependencies package
apt-cache depends package
apt-cache requires package
The apt-cache command is used to query the APT cache for information about packages. The depends option shows a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. For example, apt-cache depends ubuntu-restricted-extras will show the dependencies of the ubuntu-restricted-extras package. The other options are not valid for the apt-cache command. References:
What is the name of the main configuration file for GNU GRUB? (Specify the file name only without any path.)
C
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:
To what environment variable will you assign or append a value if you need to tell the dynamic linker to look in a build directory for some of a program's shared libraries?
LD_LOAD_PATH
LD_LIB_PATH
LD_LIBRARY_PATH
LD_SHARE_PATH
LD_RUN_PATH
The environment variable LD_LIBRARY_PATH is used to tell the dynamic linker to look in a specific directory for some of a program’s shared libraries. It is a colon-separated list of directories that are searched by the dynamic linker when looking for a shared library to load1. The directories are searched in the order they are mentioned in. For example, if we have a program that depends on a shared library libfoo.so that is located in /home/user/build/lib, we can run the program with:
LD_LIBRARY_PATH=/home/user/build/lib ./program
This will instruct the dynamic linker to search for libfoo.so in /home/user/build/lib before the default directories. The environment variable LD_LIBRARY_PATH can also be appended to an existing value with the += operator, for example:
LD_LIBRARY_PATH+=:/home/user/build/lib
This will add /home/user/build/lib to the end of the LD_LIBRARY_PATH list. The other options are not valid environment variables for the dynamic linker. LD_LOAD_PATH, LD_LIB_PATH, and LD_SHARE_PATH are not recognized by the dynamic linker. LD_RUN_PATH is a linker option that can be used to embed a librarysearch path in the executable at link time, but it is not an environment variable that can be set or modified at run time2. References:
Which of the following commands overwrites the bootloader located on /dev/sda without overwriting the partition table or any data following it?
dd if=/dev/zero of=/dev/sda bs=512
dd if=/dev/zero of=/dev/sda bs=512 count=1
dd if=/dev/zero of=/dev/sda bs=440 count=1
dd if=/dev/zero of=/dev/sda bs=440
The dd command is used to copy data from one device or file to another, with optional parameters to specify the block size (bs), the number of blocks to copy (count), and other options. The bootloader is typically located in the first 440 bytes of the disk, which is the Master Boot Record (MBR) area. The MBR also contains the partition table, which starts at byte 446 and occupies 64 bytes. Therefore, to overwrite the bootloader without affecting the partition table or any data following it, the command should copy 440 bytes from /dev/zero (a special device that provides null bytes) to /dev/sda (the disk device) and stop after one block. This is achieved by the command: dd if=/dev/zero of=/dev/sda bs=440 count=1 References:
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?
hidemenu
splash
timeout
showmenu
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:
Which of the following commands updates the linker cache of shared libraries?
mkcache
soconfig
mkldconfig
lddconfig
ldconfig
The command that updates the linker cache of shared libraries is ldconfig. This command creates, updates, and removes the necessary links and cache for the run-time linker, ld.so, to the most recent shared libraries found in the specified directories. To add a new library directory to the cache, you need to edit the /etc/ld.so.conf file and rerun ldconfig. You can use the -p option to print the current cache contents1.
The other commands are either invalid or unrelated to the linker cache. mkcache, soconfig, and mkldconfig are not standard Linux commands. lddconfig is a typo for ldd, which is a command that prints the shared libraries required by a program2.
References:
Which function key is used to start Safe Mode in Windows NT?
F10
F8
F6
Windows NT does not support Safe Mode
The function key that is used to start Safe Mode in Windows NT is none of the above, because Windows NT does not support Safe Mode. Safe Mode is a diagnostic mode of Windows that starts the system with minimal drivers and services, allowing the user to troubleshoot problems and restore the system to anormal state1. Safe Mode was introduced in Windows 95 and later versions, but not in Windows NT 4.0 and earlier2.
The other options are incorrect for the following reasons:
References:
When removing a package, which of the following dpkg options will completely remove the files including configuration files?
--clean
--delete
--purge
–remove
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:
What can the Logical Volume Manager (LVM) be used for? (Choose THREE correct answers.)
To create RAID 9 arrays.
To dynamically change the size of logical volumes.
To encrypt logical volumes.
To create snapshots.
To dynamically create or delete logical volumes.
The Logical Volume Manager (LVM) is a tool that allows the creation and management of logical volumes on Linux systems. Logical volumes are partitions that can span multiple physical disks and can be resized or deleted without affecting the rest of the system. Some of the benefits of using LVM are:
LVM cannot be used for the following purposes:
References:
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.)
Timestamps
MD5 checksums
Inodes
File sizes
GnuPG signatures
When using rpm --verify to check files created during the installation of RPM packages, the following information is taken into consideration:
RPM does not take into consideration the following information:
References:
You want to preview where the package file, apache-xml.i386.rpm, will install its files before installing it. What command do you issue?
rpm -qp apache-xml.i386.rpm
rpm -qv apache-xml.i386.rpm
rpm -ql apache-xml.i386.rpm
rpm -qpl apache-xml.i386.rpm
The message "Hard Disk Error" is displayed on the screen during Stage 1 of the GRUB boot process. What does this indicate?
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
The GRUB boot process consists of three stages1:
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:
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 command displays the contents of the Kernel Ring Buffer on the command line? (Provide only the command name without any options or path information)
dmesg,
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)
Which of the following statements is correct when talking about /proc/?
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.
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
Which of the following kernel parameters instructs the kernel to suppress most boot messages?
silent
verbose=0
nomesg
quiet
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:
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 run levels should never be declared as the default run level when using SysV init? (Choose TWO correct answers.)
0
1
3
5
6
Run levels are predefined modes of operation in the SysV init system that determine which processes and services are started or stopped. The default run level is the one that the system enters after booting. It is usually specified in the /etc/inittab file with a line like id:5:initdefault:. The run levels 0 and 6 should never be declared as the default run level because they are used to halt and reboot the system, respectively. If they are set as the default, the system will enter an endless loop of shutting down and restarting. The other run levels (1-5) have different meanings depending on the distribution, but they usually correspond to single-user mode, multi-user mode, network mode, graphical mode, etc. References: LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 101.3
What information can the lspci command display about the system hardware? (Choose THREE correct answers.)
Device IRQ settings
PCI bus speed
System battery type
Device vendor identification
Ethernet MAC address
The lspci command can display information about the system hardware, such as:
References: 1: https://www.man7.org/linux/man-pages/man8/lspci.8.html 2: https://phoenixnap.com/kb/lspci-command 3: https://en.wikipedia.org/wiki/Lspci
Which of the following are init systems used within Linux systems? (Choose THREE correct answers.)
startd
systemd
Upstart
SysInit
SysV init
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:
References: 1: 6 Best Modern Linux ‘init’ Systems (1992-2023) - Tecmint 2: 10 Best Linux init systems as of 2023 - Slant.
Which SysV init configuration file should be modified to disable the ctrl-alt-delete key combination?
/etc/keys
/proc/keys
/etc/inittab
/proc/inittab
/etc/reboot
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
What of the following statements are true regarding /dev/ when using udev? (Choose TWO correct answers.)
Entries for all possible devices get created on boot even if those devices are not connected.
Additional rules for udev can be created by adding them to /etc/udev/rules.d/.
When using udev, it is not possible to create block orcharacter devices in /dev/ using mknod.
The /dev/ directory is a filesystem of type tmpfs and is mounted by udev during system startup.
The content of /dev/ is stored in /etc/udev/dev and is restored during system startup.
udev is a device manager that dynamically creates and removes device nodes in the /dev/ directory. It also handles device events, such as adding, removing, or changing the attributes of devices. udev uses rules to match devices and assign properties, permissions, names, symlinks, and other actions. The rules are stored in files under /lib/udev/rules.d/ and /etc/udev/rules.d/. The latter directory can be used to create additional or override existing rules. The /dev/ directory is not a regular directory on the root filesystem, but a virtual filesystem of type tmpfs that is mounted by udev during system startup. tmpfs is a filesystem that resides in memory and can grow and shrink dynamically. The content of /dev/ is not stored in /etc/udev/dev, but is created by udev based on the rules and the available devices. udev does not prevent the creation of block or character devices in /dev/ using mknod, but it may overwrite or remove them if they conflict with the rules or the device events. References: LPI Linux Essentials - 1.101.2, LPI Linux Administrator - 102.4
Which of the following commands brings a system running SysV init into a state in which it is safe to perform maintenance tasks? (Choose TWO correct answers.)
shutdown -R 1 now
shutdown -single now
init 1
telinit 1
runlevel 1
The commands init 1 and telinit 1 both bring a system running SysV init into a state in which it is safe to perform maintenance tasks. This state is also known as single-user mode or runlevel 1, where only the root user can log in and no network services are running. The command shutdown -R 1 now is incorrect, because it reboots the system instead of entering single-user mode. The command shutdown -single now is invalid, because the -single option does not exist for the shutdown command. The command runlevel 1 is also invalid, because runlevel is a command that displays the current and previous runlevels, not a command that changes the runlevel. References:
During a system boot cycle, what program is executed after the BIOS completes its tasks?
The bootloader
The inetd program
The init program
The kernel
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 file in the /proc filesystem lists parameters passed from the bootloader to the kernel? (Specify the file name only without any path.)
cmdline
The file in the /proc filesystem that lists the parameters passed from the bootloader to the kernel is /proc/cmdline. This file contains a single line of text that shows the command line arguments that were used to boot the kernel. These arguments can include various options, such as the root device, the init process, the console device, and more. The /proc/cmdline file is read-only and cannot be modified at runtime. The parameters in this file are determined by the bootloader configuration, such as GRUB or LILO, and can be changed by editing the corresponding files12.
References: 1: The /proc Filesystem — The Linux Kernel documentation 2: passing bootloader arguments to the kernel - Unix & Linux Stack Exchange
Which of the following commands reboots the system when using SysV init? (Choose TWO correct answers.)
shutdown -r now
shutdown -r "rebooting"
telinit 6
telinit 0
shutdown -k now "rebooting"
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
What is the first program that is usually started, at boot time, by the Linux kernel when using SysV init?
/lib/init.so
/sbin/init
/etc/rc.d/rcinit
/proc/sys/kernel/init
/boot/init
The first program that is usually started, at boot time, by the Linux kernel when using SysV init is /sbin/init. This program is responsible for reading the /etc/inittab file and executing the appropriate scripts and programs for each runlevel. The other options are not valid programs that are started by the kernel. /lib/init.so is a shared library that is used by some init programs, but not by SysV init. /etc/rc.d/rcinit is a script that is run by init, not by the kernel. /proc/sys/kernel/init is a kernel parameter that can be used to specify a different init program, but the default value is /sbin/init. /boot/init is not a standard location for an init program, and it is unlikely that the kernel would find it there. References:
During a system boot cycle, what is the program that is run after the BIOS completes its tasks?
The bootloader
The inetd program
The init program
The kernel
The program that is run after the BIOS completes its tasks is the bootloader12. The bootloader is a small program that loads the operating system into memory and executes it. The bootloader can be located in the Master Boot Record (MBR) of the first hard disk or the boot sector of a partition for BIOS systems, or in an .efi file on the EFI System Partition for UEFI systems12. The bootloader can also display a menu to allow the user to choose from different operating systems or kernel versions to boot12.
The other options in the question are not correct because:
References:
1: The Linux Booting Process - 6 Steps Described in Detail - freeCodeCamp.org 2: Guide to the Boot Process of a Linux System - Baeldung 3: [inetd - Wikipedia] : [init - Wikipedia] : [Linux kernel - Wikipedia]
Which of the following examples for Bash file globbing matches a file named root-can-do-this.txt when used in the directory holding that file? (Choose three correct answers.)
root*can?do-this.{txt,odt}
r[oOoO]t-can-do*.txt
{root,user,admin}-can-??-this.txt
root*can*do??this.txt
root***{can,may}-do-this.[tT][xX][tT]
The examples for Bash file globbing that match a file named root-can-do-this.txt are:
The examples that do not match are:
Instead of supplying an explicit device in /etc/fstab for mounting, what other options may be used to identify the intended partition? (Choose TWO correct answers.)
FIND
ID
LABEL
NAME
UUID
The correct answers are C and E. Instead of supplying an explicit device in /etc/fstab for mounting, you can also use LABEL or UUID to identify the intended partition. LABEL is a human-readable name that can be assigned to a partition using tools such as e2label, tune2fs, or gparted. UUID is a universally unique identifier that is automatically generated for each partition and can be obtained using tools such as blkid or lsblk. Using LABEL or UUID instead of device names can be useful for avoiding problems caused by device name changes, such as when adding or removing disks. For example, instead of writing something like this in /etc/fstab:
/dev/sda1 /mnt/example ext4 defaults 0 0
You can write something like this:
LABEL=example /mnt/example ext4 defaults 0 0
or
UUID=80b496fa-ce2d-4dcf-9afc-bcaa731a67f1 /mnt/example ext4 defaults 0 0
The other options are not valid ways to identify a partition in /etc/fstab. FIND, ID, and NAME are not supported by the mount command or the /etc/fstab file. For more information on how to use LABEL and UUID in /etc/fstab, you can refer to the following articles:
After successfully creating a hard link called bar to the ordinary file foo, foo is deleted from the filesystem. Which of the following describes the resulting situation?
foo and bar would both be removed.
foo would be removed while bar would remain accessible.
foo would be removed. bar would still exist but would be unusable.
Both foo and bar would remain accessible.
The user is prompted whether bar should be removed, too.
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. Therefore, when a hard link is created, the inode reference count is increased by one, and when a hard link is deleted, the inode reference count is decreased by one. The file content is only removed from the disk when the inode reference count reaches zero, meaning that there are no more hard links to the file. In this scenario, after successfully creating a hard link called bar to the ordinary file foo, foo and bar both refer to the same inode and the same file content. The inode reference count is two. When foo is deleted from the filesystem, the inode reference count is decreased by one, but it is still one, meaning that there is still one hard link to the file. Therefore, foo would be removed while bar would remain accessible. The file content would not be removed from the disk until bar is also deleted. The other options are either incorrect or not applicable. The user is not prompted whether bar should be removed, too. The bar link would still exist and be usable, not unusable. References:
Which command shows all shared libraries required by a binary executable or another shared library? (Specify ONLY the command without any path or parameters.)
ldd
The command that shows all shared libraries required by a binary executable or another shared library is ldd. This command queries the dynamic linker to find out which libraries are needed by the given file and displays them on the standard output. For example, to see the shared libraries required by the /bin/ls program, we can run:
ldd /bin/ls
The output will look something like this:
linux-vdso.so.1 (0x00007ffd8a7f6000)libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f0c5a6c4000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0c5a4d3000)libpcre2-8.so.0 => /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f0c5a445000)libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0c5a441000)/lib64/ld-linux-x86-64.so.2 (0x00007f0c5a8a5000)libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0c5a41e000)
The output shows the name and the path of each shared library, as well as the address where it is loaded in memory. If the library is not found, the output will show not found instead of the path. The linux-vdso.so.1 library is a special case, as it is a virtual library that is not actually present on the filesystem, but is injected by the kernel into every process12.
References:
In the vi editor, what vi command will copy (but not paste) from the current line at the cursor and the following 16 lines (17 lines total)? Specify the correct vi command without spaces.
17yy
The vi editor is a text editor that operates in two modes: command mode and insert mode. In command mode, the user can enter commands to perform various operations on the text, such as copying, pasting, deleting, moving, searching, etc. In insert mode, the user can type text into the file. To switch from command mode to insert mode, the user can press i, a, o, or other keys. To switch from insert mode to command mode, the user can press Esc. The yy command is used to copy (yank) the current line into a buffer. The number before the yy command specifies how many lines to copy, starting from the current line. Therefore, the command 17yy will copy the current line and the following 16 lines (17 lines total) into a buffer. The buffer can then be pasted into another location by using the p or P command. Note that the command 17yy does not paste the copied lines, it only copies them. References:
Where does the BIOS search for a bootloader?
On all connected storage media regardless of the boot device order.
On all connected storage media in the defined boot device order.
Only on hard disk drives in the defined boot device order.
Only on the last added storage media.
The BIOS is not responsible to search for a valid bootloader.
The BIOS (Basic Input/Output System) is a firmware program that is stored in a ROM chip on the motherboard, and it performs some basic tasks when the system is powered on, such as:
The boot device is the data carrier that contains the bootloader, which is a small program that is responsible for loading and executing the kernel. The boot device can be a hard disk, a USB drive, a CD-ROM, or a network device. The BIOS has a boot order list, which is a sequence of possible boot devices that the BIOS will search for a valid bootloader. The boot order list can be configured by the user through the BIOS setup utility, which is usually accessed by pressing a key such as F2, F10, or Del during the POST.
The BIOS will search for a bootloader by means of a special signature, which is a sequence of bytes that indicates the presence of a bootloader. The signature is usually located in the first sector of the boot device, which is called the boot sector or the master boot record (MBR). The BIOS will read the boot sector of each boot device in the boot order list, and check if the last two bytes are 0x55 and 0xAA, which are the standard boot signature. If the boot signature is found, the BIOS will load the boot sector into memory and execute it. If the boot signature is not found, the BIOS will move on to the next boot device in the boot order list. If none of the boot devices have a valid boot signature, the BIOS will display an error message such as:
No bootable device – insert boot disk and press any key
References:
Which of the following commands will mount an already inserted CD-ROM in /dev/sr0 onto an existing directory /mnt/cdrom when issued with root privileges?
mount /dev/cdrom /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
mount –t cdrom /dev/sr0 /mnt/cdrom
mount –l cdrom /dev/sr0 /mnt/cdrom
mount –f /dev/sr0/mnt/cdrom
The mount command is used to attach a filesystem to a directory on the system, which is called a mount point. The mount command requires the device name or the UUID of the filesystem as the first argument, and the mount point as the second argument. Optionally, the mount command can also take some options, such as the filesystem type, the mount options, and the label. The syntax of the mount command is:
mount [options] device mountpoint
In this question, the device name of the CD-ROM is /dev/sr0, and the mount point is /mnt/cdrom. Therefore, the correct command to mount the CD-ROM is:
mount /dev/sr0 /mnt/cdrom
This command will mount the CD-ROM as a read-only filesystem with the type iso9660, which is the standard format for optical discs. The mount command can automatically detect the filesystem type and the mount options, so there is no need to specify them explicitly. However, if you want to specify them, you can use the -t and -o options, respectively. For example, the following command is equivalent to the previous one:
mount -t iso9660 -o ro /dev/sr0 /mnt/cdrom
The other options are not correct because:
mount: unknown filesystem type ‘cdrom’
mount: can’t find /dev/sr0 in /etc/fstab
mount: /dev/sr0/mnt/cdrom: mount point does not exist.
References:
Which of the following commands set the sticky bit for the directory /tmp? (Choose TWO correct answers.)
chmod +s /tmp
chmod +t /tmp
chmod 1775 /tmp
chmod 4775 /tmp
chmod 2775 /tmp
The sticky bit is a special permission bit that can be set for directories. It prevents users from deleting or renaming files in the directory that they do not own, even if they have write permission on the directory. This is useful for shared directories like /tmp, where users can create temporary files but not interfere with other users’ files12. The command chmod +t /tmp sets the sticky bit for the directory /tmp by adding the letter t to the end of the permission string. The command chmod 1775 /tmp also sets the sticky bit for the directory /tmp by adding the number 1 to the beginning of the octal mode. The number 1 represents the sticky bit in the octal notation34. The commands chmod +s /tmp, chmod 4775 /tmp, and chmod 2775 /tmp do not set the sticky bit, but rather the setuid or setgid bits, which are different special permission bits that affect how programs are executed5. References: 1: Sticky bit - Wikipedia 2: Linux Sticky Bit Concept Explained with Examples 3: chmod(1) - Linux man page 4: Understanding Linux File Permissions 5: Setuid and Setgid on Linux - GeeksforGeeks
When using regular expressions, which of the following characters match the beginning of a line?
^
?
*
+
$
When using regular expressions, the ^ character matches the beginning of a line. For example, ^Hello will match any line that starts with Hello. The ? character matches zero or one occurrence of the preceding character or group. For example, colou?r will match both color and colour. The * character matches zero or more occurrences of the preceding character or group. For example, ab*c will match ac, abc, abbc, abbbc, and so on. The + character matches one or more occurrences of the preceding character or group. For example, ab+c will match abc, abbc, abbbc, and so on, but not ac. Thecharactermatchestheendofaline.Forexample,Worldwill match any line that ends with World.References:[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.7: Use regular expressions with the standard Linux utilities, Regular Expressions
Which command creates a swap space on a block device or a file? (Specify ONLY the command without any path or parameters.)
mkswap
Which of the following apt-get commands will install the newest versions of all currently installed packages?
auto-update
full-upgrade
dist-upgrade
install
update
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:
What command changes the nice level of a running process? (Specify ONLY the command without any path or parameters)
renice
The renice command changes the nice level of a running process. The nice level is a value that affects the scheduling priority of a process. A lower nice level means a higher priority and a higher nice level means a lower priority. The renice command requires the process ID (PID) of the target process and the new nice level as arguments. For example, renice -n 10 1234 will change the nice level of the process with PID 1234 to 10. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, renice command
Which of the following are modes of the vi editor? (Choose two.)
edit mode
insert mode
change mode
review mode
command mode
The modes of the vi editor that are correct are insert mode and command mode. The vi editor is a modal editor, which means that it has different modes for different operations. The insert mode allows the user to insert text into the file. The command mode allows the user to execute commands, such as saving, quitting,moving the cursor, searching, replacing, and so on. The user can switch between the modes by pressing certain keys, such as Esc, i, a, o, and others. The edit mode, change mode, and review mode are not valid modes of the vi editor. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.8: Use vi to create and edit files, vi editor
What does the command mount -a do?
It mounts all available filesystems onto the current directory.
It shows all mounted filesystems.
It mounts all user mountable filesystems for the current user.
It mounts all filesystems listed in /etc/fstab which have the option auto set.
It mounts all filesystems listed in /etc/fstab which have the option noauto set.
The command mount -a mounts all filesystems that are listed in the file /etc/fstab and have the option auto set. The option auto means that the filesystem can be mounted automatically by the mount -a command or at boot time. The option noauto means that the filesystem can only be mounted explicitly by the mount command with the device or mount point specified12. The file /etc/fstab containsinformation about the filesystems that are known to the system and how they can be mounted3. The command mount -a is useful for mounting all the filesystems that are needed by the system after a change in /etc/fstab or after a reboot4. References: 1: mount(8) - Linux man page 2: Linux mount and umount commands help and examples 3: fstab(5) - Linux man page 4: How to Use the mount Command on Linux
Which of the following command lines creates or, in case it already exists, overwrites a file called data with the output of ls?
ls 3> data
ls >& data
ls > data
ls >> data
The command line that will create or, in case it already exists, overwrite a file called data with the output of ls is ls > data. The > character is a redirection operator that redirects the standard output (STDOUT) of a command to a file. If the file does not exist, it will be created. If the file already exists, it will be overwritten. The 3> character is not a valid redirection operator. The >& character is a redirection operator that redirects both standard output (STDOUT) and standard error (STDERR) of a command to a file. The >> character is a redirection operator that appends the standard output (STDOUT) of a command to a file, without overwriting the existing file contents. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, Redirection
When redirecting the output of find to the xargs command, what option to find is useful if the filenames contain spaces?
–rep-space
-printnul
-nospace
–ignore-space
–print0
This option to the find command is useful if the filenames contain spaces when redirecting the output of find to the xargs command. The syntax of the option is:
find [where to start searching from] [expression determines what to find] -print0
The -print0 option tells the find command to print the full file name on the standard output, followed by a null character (ASCII code 0) instead of the newline character. This allows file names that contain spaces or other special characters to be correctly interpreted by the xargs command, which can use the -0 option to read items from the standard input that are terminated by a null character. The syntax of the xargs command with the -0 option is:
xargs -0 [command]
The -0 option tells the xargs command to expect the items from the standard input to be separated by a null character, and to execute the command using the items as arguments.
Therefore, the command find … -print0 | xargs -0 … will search for files and directories using the find command, print the results with a null character as the separator, pipe the output to the xargs command, which will read the items with a null character as the separator, and execute another command using the items as arguments. This will avoid any problems with filenames that contain spaces or other special characters.
The other options are incorrect for the following reasons:
References:
Which of the following commands redirects the output of ls to standard error?
ls >-1
ls <
ls >&2
ls >>2
ls |error
This command redirects the output of ls to standard error, which is file descriptor 2 by default. The syntax of the command is:
ls >& file_descriptor
The ls command is a utility that lists the files and directories in the current working directory or a specified directory. The >& symbol is a redirection operator that redirects the standard output of a command to another file descriptor, which can be a file, a device, or another stream. The file_descriptor is the number of the file descriptor to which the output is redirected.
Therefore, the command ls >&2 will run the ls command and redirect its output to file descriptor 2, which is standard error. This means that the output of ls will not be displayed on the screen, but sent to the standard error stream, which can be used for error handling or logging purposes.
The other commands are incorrect for the following reasons:
A 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?
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
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
Which daemon handles power management events on a Linux system?
acpid
batteryd
pwrmgntd
psd
inetd
The daemon that handles power management events on a Linux system is acpid. A daemon is a background process that runs continuously and performs certain tasks without user intervention. The acpid daemon listens for power management related events, such as switching between AC and battery power on a laptop, pressing the power button, closing the lid, etc., and executes various commands in response. The acpid daemon can be configured by editing the files in /etc/acpi/events and /etc/acpi/actions directories, or by using a graphical tool like gnome-power-manager or xfce4-power-manager. The acpid daemon is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12. References:
What is contained on the EFI System Partition?
The Linux root file system
The first stage boot loader
The default swap space file
The Linux default shell binaries
The user home directories
The EFI System Partition (ESP) is a special partition on a disk that contains the UEFI boot loaders, applications and drivers for the installed operating systems. The UEFI firmware will load these files from the ESP when the system boots. The ESP is mandatory for UEFI boot and it is usually formatted with a FAT file system. The ESP is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12.
The other options are false or irrelevant. The Linux root file system is not contained on the ESP, it is usually on a separate partition with a Linux file system, such as ext4 or btrfs. The default swap space file is not contained on the ESP, it is usually on a swap partition or a swap file on the Linux root file system. The Linux default shell binaries are not contained on the ESP, they are usually on the /bin directory of the Linux root file system. The user home directories are not contained on the ESP, they are usually on the /home directory of the Linux root file system or on a separate partition. References:
Which of the following commands list all files and directories within the /tmp/ directory and its subdirectories which are owned by the user root? (Choose two.)
find /tmp –user root -print
find –path /tmp –uid root
find /tmp –uid root -print
find /tmp –user root
find –path /tmp –user root -print
The find command can be used to search for files and directories that match certain criteria, such as ownership, permissions, size, type, name, etc. The syntax of the find command is:
find [options] [path...] [expression]
The options can modify the behavior of the find command, such as how to handle symbolic links, how to optimize the search, or how to enable debugging. The path argument specifies the starting point of the search, which can be one or more directories. The expression argument consists of one or more tests, actions, and operators that are applied to each file or directory that is found.
The -user test matches files or directories that are owned by a given user. The user can be specified by name or by numeric user ID (UID). The -print action prints the full file name of the matching file or directory on the standard output, followed by a newline. If no action is specified, -print is assumed by default.
Therefore, to list all files and directories within the /tmp/ directory and its subdirectories which are owned by the user root, we can use either of the following commands:
Both commands will search recursively from the /tmp/ directory and print the full file names of the files or directories that are owned by the user root. The -print action is optional in this case, since it is the default action.
The other commands are incorrect for the following reasons:
References:
Which umask value ensures that new directories can be read, written and listed by their owning user, read and listed by their owning group and are not accessible at all for everyone else?
0750
0027
0036
7640
0029
The umask value is a four-digit octal number that determines the default permissions for new files and directories created by a user. The umask value specifies the permissions that are not granted to the user, group, and others. The permissions are represented by three bits for each category, where 1 means execute, 2 means write, and 4 means read. The sum of these values indicates the combination of permissions. For example, 7 means read, write, and execute; 6 means read and write; 5 means read and execute; 4 means read only; 3 means write and execute; 2 means write only; 1 means execute only; and 0 means no permission.
The umask value is subtracted from the maximum permissions for files and directories, which are 666 and 777, respectively. The maximum permissions are then converted to binary and bitwise ANDed with the bitwise complement of the umask value. The result is the default permissions for the new files and directories. For example, if the umask value is 0027, the default permissions for a new file are:
666 - 027 = 639 639 in octal = 110 011 001 in binary 027 in octal = 000 010 111 in binary Bitwise complement of 027 = 111 101 000 in binary 110 011 001 AND 111 101 000 = 110 001 000 in binary 110 001 000 in binary = 608 in octal 608 in octal = rw- — —
The default permissions for a new directory are:
777 - 027 = 750 750 in octal = 111 101 000 in binary 027 in octal = 000 010 111 in binary Bitwise complement of 027 = 111 101 000 in binary 111 101 000 AND 111 101 000 = 111 101 000 in binary 111 101 000 in binary = 750 in octal 750 in octal = rwx r-x —
Therefore, the umask value of 0027 ensures that new files can be read and written by their owning user, and are not accessible at all for everyone else. New directories can be read, written and listed by their owning user, read and listed by their owning group, and are not accessible at all for everyone else.
References:
Which of the following properties of a Linux system should be changed when a virtual machine is cloned? (Choose two.)
The partitioning scheme
The file system
The D-Bus Machine ID
The permissions of /root/
The SSH host keys
The properties of a Linux system that should be changed when a virtual machine is cloned are the D-Bus Machine ID and the SSH host keys. The D-Bus Machine ID is a unique identifier for the system that is used by the D-Bus message bus system to communicate between applications. The D-Bus Machine ID is stored in the /etc/machine-id or /var/lib/dbus/machine-id file and it is generated during the first boot of the system. If a virtual machine is cloned without changing the D-Bus Machine ID, it can cause conflicts and errors with the D-Bus services on the clone and the original system. To change the D-Bus Machine ID, the file containing it must be deleted or emptied and the system must be rebooted12. The SSH host keys are cryptographic keys that are used by the SSH protocol to authenticate the identity of the system and establish a secure connection. The SSH host keys are stored in the /etc/ssh directory and they are generated during the first boot of the system or the installation of the openssh-server package. If a virtual machine is cloned without changing the SSH host keys, it can compromise the security and integrity of the SSH connections, as the clone and the original system will have the same keys. To change the SSH host keys, the files containing them must be deleted and the ssh-keygen command must be run to generate new keys34.
The other options are false or irrelevant. The partitioning scheme and the file system are not properties of a Linux system that need to be changed when a virtual machine is cloned, as they do not affect the functionality or the identity of the system. The permissions of /root/ are also not properties of a Linux system that need to be changed when a virtual machine is cloned, as they do not affect the security or the communication of the system. References:
What does the command mount --bind do?
It makes the contents of one directory available in another directory
It mounts all available filesystems to the current directory
It mounts all user mountable filesystems to the user’s home directory
It mounts all file systems listed in /etc/fstab which have the option userbind set
It permanently mounts a regular file to a directory
The 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:
References:
Which command displays the current disk space usage for all mounted file systems? (Specify ONLY the command without any path or parameters.)
df
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:
What output will be displayed when the user fred executes the following command?
echo ‘fred $USER’
fred fred
fred /home/fred/
‘fred $USER’
fred $USER
‘fred fred’
This output will be displayed when the user fred executes the following command:
echo 'fred $USER'
The echo command is a built-in Linux feature that prints out arguments as the standard output. The syntax of the echo command is:
echo [option] [string]
The option can modify the behavior of the echo command, such as enabling the interpretation of escape characters or omitting the newline after the output. The string is the text that is displayed as the output.
The single quotation marks (’ ') are used to enclose the string argument and prevent any expansion or substitution of the characters inside the quotation marks. This means that any variables, commands, or special characters inside the single quotation marks are treated as literal characters, not as expressions.
The $USER variable is a shell variable that holds the username of the current user. However, since it is enclosed in single quotation marks, it is not expanded to its value, but printed as it is.
Therefore, the command echo ‘fred $USER’ will print the string fred $USER as the output, without any changes. The output will be the same for any user who executes the command, not just fred.
The other outputs are incorrect for the following reasons:
References:
Which wildcards will match the following filenames? (Choose two.)
ttyS0
ttyS1
ttyS2
ttyS[1-5]
tty?[0-5]
tty*2
tty[A-Z][012]
tty[Ss][02]
[character list] matches any one of the characters in the list. ? matches any single character. * matches any number of characters, including none.
Therefore, the wildcard ttyS[1-5] will match any filename that starts with ttyS and ends with a digit from 1 to 5, such as ttyS1, ttyS2, ttyS3, ttyS4, or ttyS5. However, it will not match ttyS0, which has a 0 at the end.
The wildcard tty?[0-5] will match any filename that starts with tty, followed by any single character, followed by a digit from 0 to 5, such as ttyS0, ttyS1, ttyS2, ttyA0, ttyB5, or ttyZ4. This wildcard will match all the given filenames.
The wildcard tty*2 will match any filename that starts with tty and ends with 2, such as ttyS2, ttyA2, ttyB2, or ttyZZZ2. This wildcard will match ttyS2, but not the other two filenames.
The wildcard tty[A-Z][012] will match any filename that starts with tty, followed by a capital letter from A to Z, followed by a digit from 0 to 2, such as ttyA0, ttyB1, ttyC2, ttyZ0, or ttyZ2. This wildcard will match ttyS0 and ttyS2, but not ttyS1, which has a 1 at the end.
The wildcard tty[Ss][02] will match any filename that starts with tty, followed by either S or s, followed by either 0 or 2, such as ttyS0, ttyS2, ttys0, or ttys2. This wildcard will match ttyS0 and ttyS2, but not ttyS1, which has a 1 at the end.
Which of the following files exist in a standard GRUB 2 installation? (Choose two.)
/boot/grub/stages/stage0
/boot/grub/i386-pc/1vm.mod
/boot/grub/fstab
/boot/grub/grub.cfg
/boot/grub/linux/vmlinuz
The files that exist in a standard GRUB 2 installation are /boot/grub/i386-pc/1vm.mod and /boot/grub/grub.cfg. The /boot/grub/i386-pc/1vm.mod file is a GRUB 2 module that provides support forthe 1vm command, which allows loading a virtual machine image from a disk1. The /boot/grub/grub.cfg file is the main configuration file for GRUB 2, which contains the menu entries and options for the bootloader2. The other files are either non-existent or do not belong to GRUB 2. The /boot/grub/stages/stage0 file ispart of the GRUB legacy bootloader, which used a different architecture and naming scheme than GRUB 23. The /boot/grub/fstab file is not a valid file name, as fstab is the name of the file system table file that isusually located in /etc directory4. The /boot/grub/linux/vmlinuz file is also not a valid file name, as vmlinuz is the name of the compressed Linux kernel image that is usually located in /boot directory5. References:
Which of the following is true when a file system, which is neither listed in /etc/fstab nor known to system, is mounted manually?
systemd ignores any manual mounts which are not done using the systemctl mount command
The command systemctl mountsync can be used to create a mount unit based on the existing mount
systemd automatically generates a mount unit and monitors the mount point without changing it
Unless a systemd mount unit is created, systemd unmounts the file system after a short period of time
systemctl unmount must be used to remove the mount because system opens a file descriptor on the mount point
Systemd is a system and service manager for Linux systems, and it can manage the mounting and unmounting of file systems. Systemd can automatically create and start mount units for file systems that are listed in /etc/fstab or are known to the system. Mount units are unit files that encode information about a file system mount point controlled and supervised by systemd. Mount units must be named after the mount point directories they control, and they have the suffix .mount. For example, the mount point /home must be configured in a unit file home.mount.
Systemd can also handle file systems that are neither listed in /etc/fstab nor known to the system, but are mounted manually by the user. In this case, systemd automatically generates a transient mount unit and monitors the mount point without changing it. A transient mount unit is a unit that is created dynamically and temporarily, and is not backed by a unit file on disk. A transient mount unit has the same name and properties as a regular mount unit, but it is not persistent across reboots. Systemd does not interfere with the manual mount, and does not unmount it unless explicitly requested by the user. The user can use the mount command or the systemd-mount command to create a manual mount, and the umount command or the systemd-umount command to remove it. The user can also use the systemctl command to inspect and control the transient mount unit. For example, to show the status of the transient mount unit for the mount point /mnt, use the following command:
systemctl status mnt.mount
References:
What is the first program the Linux kernel starts at boot time when using System V init?
/lib/init.so
/proc/sys/kernel/init
/etc/rc.d/rcinit
/sbin/init
/boot/init
The first program the Linux kernel starts at boot time when using System V init is /sbin/init. System V init is a traditional init system that uses a series of shell scripts to initialize and manage the system services. The init program is the parent of all other processes and it is responsible for reading the /etc/inittab file and executing the appropriate scripts for each runlevel. The /sbin/init program is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12. References:
Which of the following commands kills the process with the PID 123 but allows the process to "clean up" before exiting?
kill -PIPE 123
kill -KILL 123
kill -STOP 123
kill -TERM 123
The command kill -TERM 123 kills the process with the PID 123 but allows the process to “clean up” before exiting. The option -TERM specifies the signal to be sent to the process, which is the termination signal (SIGTERM). This signal requests the process to terminate gracefully, which means that the process can perform any necessary actions before exiting, such as closing files, releasing resources, or saving data. The process can also catch the signal and ignore it or handle it in a different way, if it is programmed to do so. The syntax is: kill -TERM pid. For example, kill -TERM 123 will send the SIGTERM signal to the process with the PID 123, asking it to terminate nicely. The other options are not correct because:
You are trying to make a hard link to an ordinary file but ln returns an error. Which of the following could cause this?
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.
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:
Which of the following commands displays the contents of a gzip compressed tar archive?
gzip archive.tgz | tar xvf -
tar ztf archive.tgz
gzip -d archive.tgz | tar tvf -
tar cf archive.tgz
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:
Immediately after deleting 3 lines of text in vi and moving the cursor to a different line, which single character command will insert the deleted content below the current line?
i (lowercase)
P (uppercase)
p (lowercase)
U (uppercase)
u (lowercase)
The p command in vi inserts the content of the buffer below the current line. The buffer is where the deleted or yanked text is stored temporarily. The P command inserts the buffer above the current line. The i command enters the insert mode before the cursor position. The U command restores the current line to its original state. The u command undoes the last change made to the file. References:
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.)
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
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:
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.)
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
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:
References:
Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file?
fmt -f 1,4 /etc/passwd
split -c 1,4 /etc/passwd
cut -d : -f 1,4 /etc/passwd
paste -f 1,4 /etc/passwd
The cut command is used to extract selected fields from each line of a file. The -d option specifies the delimiter that separates the fields, and the -f option specifies the fields to print. The /etc/passwd file contains information about the users on the system, and each field is separated by a colon (:). Therefore, cut -d : -f 1,4 /etc/passwd will print the first and fourth fields of each line, which are the username and the primary group ID respectively. The other commands are either invalid or do not perform the desired task. The fmt command is used to reformat paragraphs of text, but it does not have a -f option. The split command is used to split a file into smaller files, but it does not have a -c option. The paste command is used to merge lines of files, but it does not have a -f option. References:
Which of the following characters can be combined with a separator string in order to read from the current input source until the separator string, which is on a separate line and without any trailing spaces, is reached?
<<
<|
!<
&<
The << character is used to create a here document, which is a special type of redirection that reads input from the current source until a line containing only the delimiter (with no trailing blanks) is seen. The delimiter is specified after the << operator, and can be any string. For example, the following command will print everything between the << EOF and EOF lines:
cat << EOF This is a here document It can span multiple lines EOF
The output is:
This is a here document It can span multiple lines
The < character is used for normal input redirection, which reads data from a file or another command. The <| and !< characters are not valid redirection operators in Linux. The &< character is used to duplicate input file descriptors, which is an advanced topic not covered by the Linux Essentials exam. References:
QUESTIONNO: 16
Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?
A. file /tmp/myfile.txt
B. echo "Hello" >/tmp/myfile.txt
C. sed -ie "s/1/2/" /tmp/myfile.txt
D. echo -n "Hello" >>/tmp/myfile.txt
E. touch/tmp/myfile.txt
Answer: A
The file command will not update the modify timestamp on the file /tmp/myfile.txt because it only reads the file content and determines its type. It does not write or change anything in the file.
The other commands will update the modify timestamp on the file /tmp/myfile.txt because they either overwrite the file content (B and C), append to the file content (D), or explicitly change the file timestamp (E).
What does the? symbol within regular expressions represent?
Match the preceding qualifier one or more times.
Match the preceding qualifier zero or more times.
Match the preceding qualifier zero or one times.
Match a literal? character.
The ? symbol within regular expressions represents an optional match of the preceding qualifier. A qualifier is a character or a group of characters that can be repeated a certain number of times, such as , +, ?, {n}, {n,}, or {n,m}. The ? symbol means that the qualifier can occur zero or one times, but not more. For example, the regular expression colou?r matches both “color” and “colour”, but not “colouur” or “colr”. The ? symbol can also be used to make other qualifiers lazy, meaning that they will match the smallest possible number of characters, instead of the largest (greedy). For example, the regular expression a.?b matches the shortest string that starts with “a” and ends with “b”, such as “ab” or “a-b”, but not “a-b-c”. References:
While editing a file in vi, the file changes due to another process. Without exiting vi, how can the file be reopened for editing with the new content?
:r
:n
:w
:e
The :e command in vi is used to edit a file. If the file name is not specified, it will edit the current file. If the file has been changed by another process, the :e command will reload the file with the new content, discarding any unsaved changes made in vi. Therefore, the :e command can be used to reopen the file for editing with the new content without exiting vi. The other options are either invalid or do not perform the desired task. The :r command is used to read the content of another file or command and insert it into the current file. The :n command is used to edit the next file in the argument list, if any. The :w command is used to write the current file to disk, optionally with a new name. References:
What is the purpose of the Bash built-in export command?
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.
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:
What is the default nice level when a process is started using the nice command?
-10
10
20
0
The default nice level when a process is started using the nice command is 10. This means that the process will have a lower priority than the normal processes, which have a nice level of 0. The nice command allows the user to adjust the priority of a process at the time of its execution. The syntax of the nice command is:
nice [-n {nice value increment}] [command]
The -n option specifies the nice value increment, which can be a positive or negative integer in the range of -20 to 19. The command is the name of the program or script to be executed. If the -n option is omitted, the default nice value increment is 10. For example, the following command will run the program ackermann with a nice value of 10:
nice ./ackermann
To verify the nice value of a running process, we can use the ps or top commands and look at the NI column. For example, the following command will show the nice value of the ackermann process:
ps -el | grep ackermann
References: