Which of the following commands are common Linux commands for file management? (Choose three correct answers.)
copy
mv
move
cp
mkdir
The common Linux commands for file management are mv, cp and mkdir. The mv command moves or renames files and directories. The cp command copies files and directories. The mkdir command creates directories. The copy and move commands are not valid Linux commands. References:
What is the purpose of the Filesystem Hierarchy Standard?
It is a security model used to ensure files are organized according to their permissions and accessibility.
It provides unified tools to create, maintain and manage multiple filesystems in a common way.
It defines a common internal structure of inodes for all compliant filesystems.
Itis a distribution neutral description of locations of files and directories.
The Filesystem Hierarchy Standard is a distribution neutral description of locations of files and directories. According to the first result, it is a reference describing the conventions used for the layout of Unix-like systems. It is maintained by the Linux Foundation and the latest version is 3.0
Which of the following shell commands makes the already defined variable TEST visible to new child processes? (Choose two.)
visible TEST
declare +x TEST
declare –x TEST
export TEST
export –v TEST
The export command makes a shell variable available to child processes of the current shell. It can also be used to list all the exported variables. The -v option makes the export command print the variable name and value for each exported variable. The declare command can be used to set or display the attributes and values of shell variables. The -x option makes a variable exported to subsequent commands. The +x option removes the export attribute from a variable. The visible command is not a valid shell command. References:
Which of the following describes the correct order in which the components of the system boot process are started?
BIOS, kernel, bootloader, init system
BIOS, bootloader,kernel, init system
Bootloader, BIOS, kernel, init system
BIOS, bootloader, init system, kernel
Bootloader, BIOS, init system, kernel
The system boot process is the sequence of steps that the system follows when it is powered on or restarted. The system boot process can be divided into four main components: BIOS, bootloader, kernel, and init system. The order in which these components are started is:
Some common init systems for Linux systems are SysVinit, systemd, and Upstart.
References:
Which of the following options must be passed to a filesystem’s entry in /etc/fstab in order to mount the file system without root privileges?
auto
norestrict
noauto
user
The correct option to pass to a filesystem’s entry in /etc/fstab in order to mount the file system without root privileges is:
D. user
The /etc/fstab file is a configuration file that contains information about the filesystems on a Linux system. The /etc/fstab file defines how and when the filesystems are mounted by the mount command or the system. The /etc/fstab file has six fields for each filesystem entry, separated by whitespace. The fields are:
The user option is a mount option that allows any non-root user to mount the filesystem. By default, only the root user can mount filesystems, unless they are specified in the /etc/fstab file with the user option. For example, to allow any user to mount a USB drive with the device name /dev/sdb1 to the directory /mnt/usb, the /etc/fstab entry would look like:
/dev/sdb1 /mnt/usb vfat user 0 0
The user option also implies the noexec, nosuid, and nodev options, which prevent the execution of binaries, the setuid and setgid bits, and the device files on the mounted filesystem, respectively. These options can be overridden by using the exec, suid, and dev options after the user option.
The other options are not correct because:
Which signal is sent by the kill command by default?
SIGHUP(1)
SIGQUIT(3)
SIGKILL(9)
SIGTERM(15)
The signal that is sent by the kill command by default is SIGTERM(15). The kill command sends a signal to a process to terminate it. The signal can be specified by name or number as an option to the kill command. If no signal is specified, the default signal is SIGTERM(15), which means terminate. The process can catch this signal and perform any necessary cleanup before exiting. The SIGHUP(1) signal means hang up and is usually sent when the terminal or network connection is disconnected. The SIGQUIT(3) signal means quit and is usually sent when the user presses Ctrl-\ on the keyboard. The SIGKILL(9) signal means kill and is used to force the process to terminate immediately, without any chance to catch the signal or perform any cleanup. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, kill command, Signal List
Which of the following commands enables the setuid (suid) permission on the executable /bin/foo?
chmod 1755 /bin/foo
chmod 4755 /bin/foo
chmod u-s /bin/foo
chmod 755+s /bin/foo
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:
Therefore, the numeric mode for these permissions is 4755, where:
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:
chmod 1xxx directory
where xxx is the combination of the user, group, and others permissions.
chmod u-s file
chmod: invalid mode: ‘755+s’ Try ‘chmod --help’ for more information.
References:
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
What is the purpose of the xargs command?
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.
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
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:
Which of the following commands is used to change metadata and options for ext3 filesystems?
mod3fs
tune3fs
mod2fs
tune2fs
dump2fs
The tune2fs command is used to change metadata and options for ext2, ext3, and ext4 filesystems. The tune2fs command can adjust various parameters such as the maximum mount count, the check interval, the reserved blocks percentage, the volume label, and the UUID. The tune2fs command can also enable or disable some filesystem features, such as the journal, the dir_index, the acl, and the user_xattr. The tune2fs command requires the device name or the UUID of the filesystem as an argument, and one or more options to specify the changes to be made. For example, to change the volume label of an ext3 filesystem on /dev/sda1 to “data”, use the following command:
tune2fs -L data /dev/sda1The other options are not valid commands or options. The mod3fs and mod2fs commands do not exist on a standard Linux system. The tune3fs command is a synonym for tune2fs, but it is not commonly used. The dump2fs command is used to display the superblock and blocks group information for ext2, ext3, and ext4 filesystems, but it does not change any parameters or options. 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:
What does the command mount -a do?
It ensures that all file systems listed with the option noauto in /etc/fstab are mounted.
It shows all mounted file systems that have been automatically mounted.
It opens an editor with root privileges and loads /etc/fstab for editing.
It ensures that all file systems listed with the option auto in /etc/fstab are mounted.
It ensures that all file systems listed in /etc/fstab are mounted regardless of their options.
The command mount -a ensures that all file systems listed with the option auto in /etc/fstab are mounted. The /etc/fstab file contains the information about the file systems that can be mounted automatically or manually. The option auto means that the file system can be mounted automatically at boot time or when the command mount -a is issued. The option noauto means that the file system can only be mounted manually by specifying the device or mount point. The command mount -a ignores the file systems with the noauto option and mounts the rest of the file systems that are not already mounted. The other options are incorrect because they do not describe the correct behavior of the command mount -a. Option A is wrong because the command mount -a ignores the file systems with the noauto option. Option B is wrong because the command mount -a does not show any output, unless the -v option is used. To show the mounted file systems, the command mount without any arguments can be used. Option C is wrong because the command mount -a does not open any editor. To edit the /etc/fstab file, a text editor such as vi, nano, or gedit can be used. Option E is wrong because the command mount -a does not mount all file systems listed in /etc/fstab, but only those with the auto option. References:
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?
mod2fs
fsck
tune2fs
mke2fs
fixe2fs
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:
Pressing the Ctrl-C combination on the keyboard while a command is executing in the foreground sends which of the following signal codes?
1(SIGHUP)
2(SIGINT)
3(SIGQUIT)
9(SIGKILL)
15(SIGTERM)
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
What is true regarding UEFI firmware? (Choose two.)
It can read and interpret partition tables
It can use and read certain file systems
It stores its entire configuration on the /boot/ partition
It is stored in a special area within the GPT metadata
It is loaded from a fixed boot disk position
UEFI firmware is a software program that provides the interface between the hardware and the operating system on a computer. UEFI stands for Unified Extensible Firmware Interface and it is a replacement for the traditional BIOS (Basic Input/Output System). UEFI firmware has several advantages over BIOS, such asfaster boot times, better security, larger disk support, and graphical user interface. Some of the features of UEFI firmware are12:
The other options are false or irrelevant. UEFI firmware does not read and interpret partition tables, it relies on the operating system to do that. UEFI firmware does not store its entire configuration on the /boot/ partition, it stores some of its settings in the NVRAM (Non-Volatile Random Access Memory) on the motherboard and some of its files on the ESP. UEFI firmware is not stored in a special area within the GPT (GUID Partition Table) metadata, it is stored in a ROM chip and an ESP. GPT is a partitioning scheme that supports larger disks and more partitions than the legacy MBR scheme. References:
Which of the following directories on a 64-bit Linux system typically contain shared libraries? (Choose two.)
~/.lib64/
/usr/lib64/
/var/lib64/
/lib64/
/opt/lib64/
The directories on a 64 bit Linux system that typically contain shared libraries are /usr/lib64/ and /lib64/. Shared libraries are binary files that provide reusable functions, routines, classes, data structures, and so on for programs and applications. They are loaded into memory before the program starts and shared by multiple processes that use the same library. Shared libraries are usually stored in standard locations in the file system, such as /usr/lib, /usr/local/lib, /lib, and /lib64 for 32 bit systems, and /usr/lib64, /usr/local/lib64, /lib64, and /lib for 64 bit systems12. The /usr/lib64 and /lib64 directories contain the shared libraries for the system and user applications, respectively. The other directories are either non-existent or do not contain shared libraries. The ~/.lib64/ directory is not a standard location for shared libraries, and it is unlikely that a user would have such a directory in their home directory. The /var/lib64/ directory is also not a standard location for shared libraries, and it is usually used for variable data files that are specific to a package or application. The /opt/lib64/ directory is not a standard location for shared libraries, and it is usually used for optional software packages that are installed in the /opt directory3. 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.
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?
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
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.
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:
What is true regarding the command
ls > files
if files do not exist?
The output of ls is printed to the terminal
files is created and contains the output of ls
An error message is shown and ls is not executed
The command files is executed and receives the output of ls
Any output of ls is discarded
The command ls > files uses the output redirection operator > to send the output of the ls command to a file named files. If the file does not exist, it will be created and will contain the output of the ls command, which is the list of files and directories in the current working directory. This is explained in the first web search result 1 and the second web search result 2. References: 1: Input Output & Error Redirection in Linux [Beginner’s Guide] 2: Redirections (Bash Reference Manual)
Consider the following output from the command ls –i:
How would a new file named c.txt be created with the same inode number as a.txt (Inode 525385)?
ln –h a.txt c.txt
ln c.txt a.txt
ln a.txt c.txt
ln –f c.txt a.txt
ln –i 525385 c.txt
This command creates a hard link to a.txt with the name c.txt. The new file c.txt will have the same inode number as a.txt (Inode 525385).
A hard link is a directory entry that points to the same data blocks as another file. A hard link is indistinguishable from the original file, and it shares the same inode number, permissions, ownership, and timestamps. A hard link can only be created within the same file system, and it cannot link to directories or special files. A hard link increases the link count of the file, which is the number of directory entries that refer to the file. The link count can be seen by using the ls -l command. The file is only deleted when the link count reaches zero, which means that all the hard links to the file are removed.
The ln command is used to create hard links or symbolic links. The syntax of the ln command is:
ln [options] source target
The source is the name of the existing file, and the target is the name of the new link. By default, the ln command creates a hard link, unless the -s option is used to create a symbolic link. A symbolic link is a special file that contains the path to another file or directory. A symbolic link is different from a hard link, as ithas its own inode number, permissions, ownership, and timestamps. A symbolic link can link to any file or directory, even across file systems, and it does not affect the link count of the file. A symbolic link can be identified by the ls -l command, as it shows the link name followed by an arrow and the target name.
For example, to create a hard link to a.txt with the name c.txt, use the following command:
ln a.txt c.txt
This command will create a new file c.txt that has the same inode number as a.txt (Inode 525385). The output of the ls -i command will show something like:
525385 a.txt 525385 c.txt
To create a symbolic link to a.txt with the name b.txt, use the following command:
ln -s a.txt b.txt
This command will create a new file b.txt that has a different inode number than a.txt (Inode 526053), and contains the path to a.txt. The output of the ls -i command will show something like:
525385 a.txt 526053 b.txt -> a.txt
References:
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 command uninstalls a package but keeps its configuration files in case the package is re-installed?
dpkg –s pkgname
dpkg –L pkgname
dpkg –P pkgname
dpkg –v pkgname
dpkg –r pkgname
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 of the following commands installs GRUB 2 into the master boot record on the third hard disk?
grub2 install /dev/sdc
grub-mkrescue /dev/sdc
grub-mbrinstall /dev/sdc
grub-setup /dev/sdc
grub-install /dev/sdc
The command that installs GRUB 2 into the master boot record on the third hard disk is grub-install /dev/sdc. The grub-install command is the high-level tool for installing GRUB 2 on a disk or a partition. It takes a device name as an argument and writes the GRUB 2 boot loader information to the specified location. If the device name is a disk, such as /dev/sdc, the boot loader information is written to the master boot record (MBR) of the disk, which is the first sector that contains the boot code and the partition table. If the device name is a partition, such as /dev/sdc1, the boot loader information is written to the boot sectorof the partition, which is the first sector of the partition that contains the boot code and the file system information. The grub-install command is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12.
The other commands are either invalid or do not perform the desired task. The grub2 install command does not exist, as grub2 is not a valid command name. The grub-mkrescue command is used to create a bootable GRUB 2 rescue image, not to install GRUB 2 on a disk or a partition3. The grub-mbrinstall command does not exist, as mbrinstall is not a valid subcommand for grub. The grub-setup command is a low-level tool for installing GRUB 2 on a disk or a partition, but it is not recommended for normal use, as it requires specifying the location of the GRUB 2 core image file4. References:
The command dbmaint & was used to run dbmaint in the background. However, dbmaint is terminated after logging out of the system. Which alternative dbmaint invocation lets dbmaint continue to run even when the user running the program logs out?
job –b dmaint
dbmaint &>/dev/pts/null
nohup dbmaint &
bg dbmaint
wait dbmaint
This command will run dbmaint in the background and make it immune to hangup signals, which means it will continue to run even when the user logs out of the system. The nohup command prefixes the command with nohup, which intercepts the SIGHUP signal that is sent to the process when the terminal sessionends. The output of the command is redirected to a file called nohup.out by default, unless specified otherwise. The & symbol puts the command in the background, allowing the user to run other commands in the same shell.
The other commands are incorrect for the following reasons:
References:
Which program runs a command in specific intervals and refreshes the display of the program’s output? (Specify ONLY the command without any path or parameters.)
watch
The program that runs a command in specific intervals and refreshes the display of the program’s output is watch. This command is used to run any designated command at regular intervals and displays the output of the command on the terminal window. It is useful when you have to execute a command repeatedly and watch the command output change over time. The syntax of the watch command is:
watch [options] command
The options can modify the behavior of the watch command, such as how to format the output, how to handle signals, or how to enable color. The command is the command that you want to run and monitor. The default interval between each execution of the command is 2 seconds, but you can change it with the -n or --interval option. For more help using the watch command and its options, run man watch or visit this link.
Which of the following commands lists the dependencies of the RPM package file foo.rpm?
rpm –qpR foo.rpm
rpm –dep foo
rpm –ld foo.rpm
rpm –R foo.rpm
rpm –pD foo
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:
Which of the following vi commands deletes two lines, the current and the following line?
d2
2d
2dd
dd2
de12
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:
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.
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.
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:
Which of the following are valid stream redirection operators within Bash? (Choose two.)
<
#>
%>
>>>
2>&1
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:
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:
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:
In the vi editor, how can commands such as moving the cursor or copying lines into the buffer be issued multiple times or applied to multiple rows?
By using the command: repeat followed by the number and the command.
By specifying the number right in front of a command such as 4l or 2yj.
By selecting all affected lines using the shift and cursor keys before applying the command.
By issuing a command such as: set repetition=4 which repeats every subsequent command 4 times.
In the vi editor, one of the ways to issue commands multiple times or apply them to multiple rows is to specify the number right in front of a command. This will repeat the command as many times as the number indicates. For example, the command 4l will move the cursor four characters to the right, and the command 2yj will copy two lines from the current line to the buffer. This method can be used for most of the vi commands that operate on single characters, words, lines, or blocks of text. Another way to issue commands multiple times or apply them to multiple rows is to use the . (dot) command, which repeats the last command. For example, after deleting a line with dd, pressing . will delete another line. However, this method is less precise and efficient than specifying the number before the command. References:
Which of the following commands is used to change options and positional parameters for a running Bash?
history
set
bashconf
setsh
envsetup
The command that is used to change options and positional parameters for a running Bash is set. The set command allows the user to modify the behavior of the shell by enabling or disabling various options, such as -x (trace mode), -e (exit on error), -u (treat unset variables as errors), and others. The set command can also be used to assign values to the positional parameters, which are the arguments passed to the shell or a shell script. The positional parameters are denoted by $1, $2, $3, and so on, up to $9. The special parameter 0referstothenameoftheshellortheshellscript.Thespecialparameter# refers to the number of positional parameters. The special parameter $@ refers to all the positional parameters as a list.
To change the positional parameters, the set command can be used with the – option, followed by the new arguments. For example, the following command will set the positional parameters to “a”, “b”, and “c”:
set – a b c
After this command, $1 will be “a”, $2 will be “b”, 3willbe"c",# will be 3, and $@ will be “a b c”. The – option signals the end of options and prevents any argument that starts with a - from being interpreted as an option. Alternatively, the set command can be used with the - option, followed by the new arguments. However, this will also disable the -x and -v options, if they were previously enabled. For example, the following command will set the positional parameters to “-a”, “-b”, and “-c”, and turn off the trace and verbose modes:
set - -a -b -c
The set command can also be used without any option or argument, in which case it will display the names and values of all shell variables and functions.
The other commands are not valid or relevant for changing options and positional parameters for a running Bash. The history command displays the history list of commands entered by the user. The bashconf command does not exist. The setsh command does not exist. The envsetup command does not exist.
References:
What is the default action of the split command on an input file?
It will break the file into new files of 1,024 byte pieces each.
It will break the file into new files of 1,000 line pieces each.
It will break the file into new files of 1,024 kilobyte pieces each.
It will break the file into new files that are no more than 5% of the size of the original file.
The split command in Linux is used to split large files into smaller files. The default action of the split command on an input file is to break the file into new files of 1,000 line pieces each. The names of the new files are PREFIXaa, PREFIXab, PREFIXac, and so on. By default, the PREFIX of the new files is x, but it can be changed with the -a option. For example, the following command will split the file someLogFile.log into new files of 1,000 lines each with the prefix log:
split someLogFile.log -a 3 log
The new files will be named logaaa, logaab, logaac, and so on. To verify the number of lines in each new file, we can use the wc command with the -l option. For example, the following command will show the number of lines in the first and the last new file:
wc -l logaaa logaas
The output will be:
1000 logaaa 170 logaas
This means that the original file had 17,170 lines and was split into 18 new files. 17 of them have 1,000 lines each, and the last one has the remaining 170 lines. 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:
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:
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:
Regarding the command:
nice -5 /usr/bin/prog
Which of the following statements is correct?
/usr/bin/prog is executed with a nice level of -5.
/usr/bin/prog is executed with a nice level of 5.
/usr/bin/prog is executed with a priority of -5.
/usr/bin/prog is executed with a priority of 5.
The nice command is used to start a process with a modified scheduling priority. The scheduling priority is a value that determines how much CPU time a process will receive from the kernel. The lower the priority, the more CPU time a process will get. The priority is also known as the nice value, because a process with a high nice value is being nice to other processes by giving up CPU time. The nice value ranges from -20 to 19, with -20 being the highest priority and 19 being the lowest. By default, processes are started with a nice value of 0, which means normal priority.
The nice command takes 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.
Therefore, the command:
nice -5 /usr/bin/prog
is equivalent to:
nice -n -5 /usr/bin/prog
and will start the /usr/bin/prog process with a nice value of -5, which means a higher priority than the default. This means that the correct answer is B. /usr/bin/prog is executed with a nice level of 5.
References:
Which command displays a list of all background tasks running in the current shell? (Specify ONLY the command without any path or parameters.)
jobs
The jobs command displays a list of all background tasks running in the current shell. A background task is a process that is started with the & operator or suspended with Ctrl+Z and resumed with the bg command. The jobs command shows the job number, the status, and the command name of each background task. For example, the following output shows two background tasks: one is running (sleep 10) and one is stopped (ping
1- Running sleep 10 & 2+ Stopped ping
References:
What does the + symbol mean in the following grep regular expression:
grep '^d[aei]\+d$' /usr/share/dict/words
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.
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:
Which of the following commands can be used to create a USB storage media from a disk image?
gdisk
dd
cc
fdisk
mount
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:
Which of the following signals is sent to a process when the key combination CTRL+C is pressed on the keyboard?
SIGTERM
SIGINT
SIGSTOP
SIGKILL
The SIGINT signal is sent to a process when the user presses the key combination CTRL+C on the keyboard. This signal is used to interrupt the process and cause it to terminate, unless the process catches or ignores the signal. The SIGTERM signal is the default signal sent by the kill command to request a process to terminate gracefully. The SIGSTOP signal is used to pause a process and make it stop executing until it receives a SIGCONT signal. The SIGKILL signal is used to force a process to terminate immediately and cannot be caught or ignored by the process. References:
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:
What happens after issuing the command vi without any additional parameters?
vi starts and loads the last file used andmoves the cursor to the position where vi was when it last exited.
vi starts and requires the user to explicitly either create a new or load an existing file.
vi exits with an error message as it cannot be invoked without a file name to operate on.
vi starts in command mode and opens a new empty file.
vi starts and opens a new file which is filled with the content of the vi buffer if the buffer contains text.
The vi command is a text editor that operates in two modes: command mode and insert mode. Command mode is used to enter commands to manipulate the text, such as saving, quitting, copying, pasting, etc. Insert mode is used to enter text into the file. When the vi command is invoked without any additional parameters, it starts in command mode and opens a new empty file. To enter text, the user has to press i to switch to insert mode. To return to command mode, the user has to press Esc. To save and quit, the user has to enter :wq in command mode. The other options are either incorrect or not applicable. The vi command does not load the last file used or the content of the vi buffer by default. It also does not require the user to explicitly create or load a file. It does not exit with an error message unless there is a problem with the terminal or the system. 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:
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.)
dpkg-reconfigure
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:
After modifying GNU GRUB's configuration file, which command must be run for the changes to take effect?
kill -HUP $(pidof grub)
grub-install
grub
No action is required
After modifying GNU GRUB’s configuration file, which is usually located at /etc/default/grub, the command that must be run for the changes to take effect is grub-install12. The grub-install command is used to install GRUB on a device or partition, and to update the boot sector and the core image of GRUB3. The command takes the following basic syntax:
$ grub-install [options] install_device
The install_device argument specifies the device or partition where GRUB should be installed, such as /dev/sda or /dev/sda1. The options can be used to control various aspects of the installation, such as the target platform, the boot directory, the force mode, the verbosity level, etc3.
The grub-install command also invokes the grub-mkconfig command, which generates the GRUB configuration file (usually located at /boot/grub/grub.cfg) based on the settings in /etc/default/grub and the scripts in /etc/grub.d4. The grub-mkconfig command can also be run separately to update the GRUB configuration file without reinstalling GRUB on the device or partition4.
The other options in the question are not correct because:
References:
1: How to Update Grub on Ubuntu and Other Linux Distributions - It’s FOSS 2: How to Configure the GRUB2 Boot Loader’s Settings 3: Ubuntu Manpage: grub-install - install GRUB on a device 4: [GNU GRUB Manual 2.06: Invoking grub-mkconfig] : [GNU GRUB Manual 2.06: Invoking grub] : [kill(1) - Linux manual page] : [pidof(8) - Linux manual page] : [grub(8) - Linux manual page]
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.)
/tmp
Answer:tmp,
Answer:/var/tmp/
Answer:/var/tmp/
Answer:A
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:
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:
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:
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)
/var
/var/,
Var
var/
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:
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:
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:
The dpkg-____ command will ask configuration questions for a specified package, just as if the package were being installed for the first time.
dpkg-reconfigure
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:
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:
In which directory must definition files be placed to add additional repositories to yum?
B
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:
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 file should be edited to select the network locations from which Debian installation package files are loaded?
/etc/dpkg/dpkg.cfg
/etc/apt/apt.conf
/etc/apt/apt.conf.d
/etc/apt/sources.list
/etc/dpkg/dselect.cfg
The /etc/apt/sources.list file is the main configuration file for the Advanced Package Tool (apt), which is used to manage Debian installation package files. This file contains a list of repositories, or sources, from which apt can download and install packages. Each repository is specified by a line that has the following format:
type uri suite [component1] [component2] […]
Where:
For example, a typical sources.list file for Debian stable could look like this:
deb stable main contrib non-free deb-src stable main contrib non-free
deb stable/updates main contrib non-free deb-src stable/updates main contrib non-free
deb stable-updates main contrib non-free deb-src stable-updates main contrib non-free
The first two lines specify the main repository for Debian stable, with both binary (deb) and source (deb-src) packages. The next two lines specify the security updates repository for Debian stable, which contains important security fixes. The last two lines specify the stable-updates repository, which contains packages that have been updated after the release of Debian stable.
By editing the /etc/apt/sources.list file, one can select the network locations from which Debian installation package files are loaded. However, it is recommended to use a graphical or command-line tool, such as aptitude or synaptic, to manage the sources.list file, as they can handle the syntax and avoid errors.
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
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:
The USB device filesystem can be found under /proc/______/usb/. (Please fill in the blank with the single word only)
bus
The USB device filesystem can be found under /proc/bus/usb/1. This is a virtual filesystem that provides information about the USB devices and buses connected to the system12. It contains files and directories that correspond to the USB host controllers, hubs, and devices12. For example, the following output shows the contents of /proc/bus/usb/ on a system with one USB host controller and two USB devices:
The directories 001 and 002 represent the USB buses, and each contain files that represent the USB devices on that bus. The file devices contains a summary of all the USB devices and their configurations. The file drivers contains a list of the USB drivers and the devices they are bound to12.
The /proc/bus/usb/ filesystem is deprecated and should not be used anymore3. It has been replaced by the /sys/bus/usb/ filesystem, which is a sysfs mount that provides more detailed and structured information about the USB devices and buses3 .
References:
1: USB in a NutShell - Chapter 5 - Linux USB 2: Linux USB FAQ 3: Alternative to /proc/bus/usb/devices - Super User : [What is the difference between /dev/usb, /proc/bus/usb and /sys/bus/usb? - Super User]
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
Which of the following options for the kernel's command line changes the systemd boot target to rescue.target instead of the default target?
systemd.target=rescue.target
systemd.runlevel=rescue.target
systemd.service=rescue.target
systemd.default=rescue.target
systemd.unit=rescue.target
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
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
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 information is stored within the BIOS? (Choose TWO correct answers.)
Boot device order
Linux kernel version
Timezone
Hardware configuration
The system's hostname
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 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 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)
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 command will display messages from the kernel that were output during the normal boot sequence?
dmesg
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:
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?
proc/interrupts
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:
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?
Copyright © 2014-2024 Examstrust. All Rights Reserved