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:
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 of the following commands can be used to perform a full text search on all available packages on a Debian system?
apt
apt-cache
apt-get
apt-search
dpkg
The command apt-cache can be used to perform a full text search on all available packages on a Debian system. It searches the package names and the descriptions for an occurrence of the regular expression given as a keyword and prints out the package name and the short description1. The syntax is: apt-cache search keyword. For example, apt-cache search openssh will return a list of packages related to OpenSSH2. The other commands are not suitable for this task because:
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 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:
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:
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 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:
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 baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
References:
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:
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 chown command will change the ownership to dave and the group to staff on a file named data.txt?
chown dave/staff data.txt
chown –u dave –g staff data.txt
chown --user dave --group staff data.txt
chown dave:staff data.txt
The chown command is used to change the owner and group of files and directories in Linux. The basic syntax of the chown command is:
chown [options] user[:group] file…
The user is the name or the numeric ID of the new owner of the file. The group is the name or the numeric ID of the new group of the file. The file is the name or the path of the file or directory to be changed. The user and group are separated by a colon (:), not a slash (/). The group is optional, and if it is omitted, the group will not be changed. The options are optional, and they can modify the behavior of the chown command, such as changing the ownership recursively, silently, or verbosely.
In this question, the user is dave and the group is staff. The file is data.txt. Therefore, the correct command to change the ownership to dave and the group to staff on data.txt is:
chown dave:staff data.txt
This command will change the owner of data.txt to dave and the group of data.txt to staff. You can verify the changes by using the ls -l command to view the owner and group of data.txt.
The other options are not correct because:
chown: invalid user: ‘dave/staff’
chown: invalid option – ‘u’ Try ‘chown --help’ for more information.
chown: unrecognized option ‘–user’ Try ‘chown --help’ for more information.
References:
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:
After running the command umount /mnt, the following error message is displayed:
umount: /mnt: device is busy.
What is a common reason for this message?
The kernel has not finished flushing disk writes to themounted device.
A user has a file open in the /mnt directory.
Another file system still contains a symlink to a file inside /mnt.
The files in /mnt have been scanned and added to the locate database.
The kernel thinks that a process is about to open a file in /mnt for reading.
One of the common reasons for the error message “device is busy” when trying to unmount a file system is that a user or a process has a file open in the mounted directory. This prevents the kernel from releasing the file system resources and detaching the device. To find out which user or process is holding the file system, one can use the lsof or fuser commands12. For example, lsof /mnt or fuser -m /mnt will list the processes that have open files in /mnt. To force the unmounting of a busy file system, one can use the -l option of the umount command, which will perform a lazy unmount. This means that the file system will be detached as soon as it is not busy anymore3. References: 1: How to solve “device is busy” problem in Linux 2: How to Find Out Which Process Is Using a File in Linux 3: umount(8) - Linux man page
Which of the following commands will produce the following output?
jobs
proclist
netstat
ps
The ps command will produce the output shown in the image. The ps command displays information about the processes running on the system. The output format can be customized by using different options. For example, ps -aux will show all processes with detailed information, such as user, PID, CPU, memory, command, and so on. The output in the image matches the format of ps -aux. The jobs command will show the status of jobs in the current shell. The proclist command is not a valid Linux command. The netstat command will show network connections, routing tables, and statistics. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, ps command, jobs command, netstat command
Which option to the tee command will cause the output to be concatenated on the end of the output file instead of overwriting the existing file contents?
–a
–c
--no-clobber
--continue
The -a option to the tee command will cause the output to be appended to the end of the output file instead of overwriting the existing file contents. The tee command reads from standard input (STDIN) and writes to standard output (STDOUT) and one or more files simultaneously. For example, ls | tee file.txt will display the output of the ls command and also write it to file.txt. If file.txt already exists, it will be overwritten unless the -a option is used. References: LPI Exam 101 Detailed Objectives, Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.3: Perform basic file management, tee command
Which command is used to query information about the available packages on a Debian system?
apt-cache
apt-get
apt-search
dpkg
dpkg-search
The command apt-cache is used to query information about the available packages on a Debian system. This command can perform various operations on the package cache, such as searching for packages that match a given pattern, showing detailed information about a specific package, displaying the dependencies of a package, and more. The apt-cache command does not require root privileges and does not modify the system state12.
The other commands are either invalid or do not perform the same function as the correct answer. For example:
References:
Which of the following are filesystems which can be used on Linux root partitions? (Choose two.)
NTFS
ext3
XFS
VFAT
swap
The Linux root partition is the partition that contains the root filesystem, which is the top-level directory of the filesystem hierarchy. The root filesystem contains the essential files and directories that are needed to boot the system, such as the kernel, the init system, the configuration files, the libraries, the binaries, and the device files. The root partition can be formatted with different filesystems, depending on the support of the kernel and the boot loader. Some of the common filesystems that can be used on Linux root partitions are:
The other options are not valid filesystems for Linux root partitions, because:
References:
Which of the following commands will load a kernel module along with any required dependency modules?
depmod
insmod
modprobe
module_install
loadmod
The modprobe command is used to add or remove modules from the Linux kernel. The modprobe command can automatically resolve and load the dependencies of a module, which are the other modules that the module depends on. The modprobe command reads the modules.dep file, which is generated by the depmod command, to determine the dependencies of a module. The syntax of the modprobe command is:
modprobe [options] module [module parameters]
The module is the name of the module to be loaded or removed. The module parameters are optional arguments that can modify the behavior of the module. The options are optional, and they can modify the behavior of the modprobe command, such as displaying the dependencies, listing the modules, or specifying the configuration file.
For example, to load the e1000e module, which is a driver for Intel Gigabit Ethernet adapters, along with any required dependency modules, use the following command:
modprobe e1000e
This command will load the e1000e module and any other modules that it depends on, such as the crc32c module. You can verify the loaded modules by using the lsmod command, which lists the modules and their dependencies, sizes, and usage counts.
The other options are not correct because:
References:
Which command is used to create and initialize the files used to store quota information? (Specify ONLY the command without any path or parameters.)
quotacheck
The command that is used to create and initialize the files used to store quota information is quotacheck. This command scans one or more file systems for disk usage, creates, checks, and repairs quota files. The quota files are named aquota.user and aquota.group and are located in the root of the file system. The quotacheck command should be run before using quotaon to enable disk quotas.
How is a symbolic link called bar.conf pointing to foo.conf created?
ln –s foo.conf bar.conf
ln foo.conf bar.conf
ln –s bar.conf foo.conf
ln bar.conffoo.conf
To create a symbolic link, also known as a symlink or a soft link, you need to use the ln command with the -s option. The syntax of the ln command is:
ln -s target link
The target is the file or directory that the link will point to, and the link is the name of the link. The link can be either an absolute or a relative path. If the link is omitted, the link will have the same name as the target in the current directory.
In this question, the target is foo.conf and the link is bar.conf. Therefore, the correct command to create a symbolic link called bar.conf pointing to foo.conf is:
ln -s foo.conf bar.conf
This command will create a file named bar.conf in the current directory, which will point to the file foo.conf in the same directory. If you want to specify a different directory for the target or the link, you need to provide the full path. For example, if you want to create a symbolic link called bar.conf in the /etc directory, pointing to the file foo.conf in the /home/user directory, you need to run:
ln -s /home/user/foo.conf /etc/bar.conf
The other options are not correct because:
ln: failed to access ‘bar.conffoo.conf’: No such file or directory
References:
What does the command grub-install /dev/sda do?
GRUB creates partitions on the device/dev/sdato be used with Linux.
GRUB sets the default BIOS boot device to/dev/sda.
GRUB installs all required files and configures the boot loader on device/dev/sda.
GRUB recompiles the Linux Kernel and installs it on the Master Boot Record of device/dev/sda.
The grub-install command is used to install the GRUB boot loader on a device, such as a hard disk or a floppy disk. The command takes one argument, which is the device name where the boot loader should be installed. The command copies the GRUB files from the /boot/grub directory to the device and writes the boot code to the Master Boot Record (MBR) or the boot sector of the device. The command also creates a device map file in /boot/grub/device.map, which maps the BIOS device names to the Linux device names. The grub-install command is useful for setting up a dual-boot system or for repairing a broken GRUB installation. The command can also take various options to customize the installation, such as --boot-directory, --efi-directory, --removable, --force-lba, and --no-floppy. References:
Which of the following commands creates an ext3 filesystem on /dev/sdb1? (Choose TWO correct answers.)
/sbin/mke2fs -j /dev/sdb1
/sbin/mkfs -t ext3 /dev/sdb1
/sbin/mkfs -c ext3 /dev/sdb1
/sbin/mke3fs -j /dev/sdb1
The correct commands to create an ext3 filesystem on /dev/sdb1 are /sbin/mke2fs -j /dev/sdb1 and /sbin/mkfs -t ext3 /dev/sdb1. These commands format the partition /dev/sdb1 with the ext3 filesystem type. The first command uses the mke2fs utility with the -j option, which enables journaling. The second command uses the mkfs utility with the -t option, which specifies the filesystem type. Both commands are equivalent and can be used interchangeably. The other options are incorrect because they use the wrong syntax or parameters for the commands. Option C is wrong because the -c option for the mkfs command checks the device for bad blocks, not the filesystem type. Option D is wrong because there is no such utility as mke3fs. The correct utility name is mke2fs.
Which of the following commands prints a list of available package updates when using RPM-based package management?
dpkg list
yum list
dpkg check-update
yum check-update
yum list-update
The command yum check-update prints a list of available package updates when using RPM-based package management. This command queries all enabled repositories and shows the packages that have updates available, along with the new version number. This command does not actually update any packages, but only lists them. To update the packages, the command yum update can be used. The other commands are either invalid or belong to a different package management system. dpkg is a low-level tool for Debian-based package management, and yum list shows all available packages in the repositories, not just the ones that have updates. References:
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 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
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 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 of the following commands will write a message to the terminals of all logged in users?
bcast
mesg
wall
yell
The wall command is a command-line utility that displays messages to all logged-in users on the terminal12. The wall command takes the following basic syntax:
$ wall OPTION { file | message }
The OPTION can be one of the following:
The file or message argument is the source of the message to be displayed. If a file is specified, the wall command will read the message from the file. If a message is specified, the wall command will read the message from the standard input. The message can be terminated by pressing Ctrl+D.
The other commands in the options are not valid or do not have the same functionality as the wall command:
References:
1: How to Send a Message to Logged Users in Linux Terminal - Tecmint 2: How to Send Broadcast Messages to Users in Linux Terminal
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
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 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 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
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 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 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)
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:
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
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 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 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 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:
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:
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:
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)
Which of the following commands installs all packages with a name ending with the string foo?
zypper get “*foo”
zypper update “foo?”
zypper force “foo*”
zypper install “*foo”
zypper add “.*foo”
The command that installs all packages with a name ending with the string foo is zypper install “*foo”. The zypper command is the command line interface of the ZYpp package manager for SUSE Linux. The install (in) subcommand is used to install packages with specified capabilities or RPM files with specified location. The argument “*foo” is a glob pattern that matches any package name that ends with foo. For example, zypper install “foo" will install packages like barfoo, bazfoo, and foo itself. The other commands are either invalid or do not perform the desired task. The zypper get, zypper update, zypper force, and zypper add subcommands do not exist. The “foo?” and "foo” arguments are also invalid glob patterns, as they do not match the end of the package name. The “.*foo” argument is a valid glob pattern, but it matches any package name that contains foo, not just the ones that end with foo. References:
When considering the use of hard links, what are valid reasons not to use hard links?
Hard links are not available on all Linux systems because traditional filesystems, such as ext4, do not support them
Each hard link has individual ownership, permissions and ACLs which can lead to unintended disclosure of file content
Hard links are specific to one filesystem and cannot point to files on another filesystem
If users other than root should be able to create hard links, suln has to be installed and configured
When a hard linked file is changed, a copy of the file is created and consumes additional space
The only valid reason not to use hard links is that they are specific to one filesystem and cannot point to files on another filesystem. This means that if you want to link files across different partitions or devices, you cannot use hard links. You have to use symbolic links instead, which are pointers to file names rather than inodes. The other options are either false or irrelevant. Hard links are available on most Linux systemsand traditional filesystems, such as ext4, do support them1. Each hard link shares the same ownership,permissions and ACLs as the original file, which can be an advantage or a disadvantage depending on the use case2. There is no such thing as suln, and users other than root can create hard links as long as they have write permission on the directory where the link is created3. When a hard linked file is changed, no copy of the file is created and no additional space is consumed. The changes are reflected on all the hard links pointing to the same inode4. References:
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 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 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:
Consider the following directory:
drwxrwxr-x 2 root sales 4096 Jan 1 15:21 sales
Which command ensures new files created within the directory sales are owned by the group sales? (Choose two.)
chmod g+s sales
setpol –R newgroup=sales sales
chgrp –p sales sales
chown --persistent *.sales sales
chmod 2775 sales
The command chmod g+s sales sets the setgid bit on the directory sales, which means that any new file or subdirectory created within sales will inherit the group ownership of the directory. The command chmod 2775 sales does the same thing, but also sets the permissions of the directory to rwxrwxr-x, whichmeans that the owner, group, and others can read, write, and execute files in the directory. Both commands ensure that new files created within the directory sales are owned by the group sales. The other commands are either invalid or do not affect the group ownership of new files. References:
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:
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.
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:
What command will generate a list of user names from /etc/passwd along with their login shell?
column -s : 1,7 /etc/passwd
chop -c 1,7 /etc/passwd
colrm 1,7 /etc/passwd
cut -d: -f1,7 /etc/passwd
The cut command is used to extract sections from each line of a file or input stream. The -d option specifies the delimiter that separates the fields in each line. The -f option specifies the fields to select. In this case, the delimiter is a colon (:) and the fields are 1 and 7. The first field is the user name and the seventh field is the login shell. Therefore, the cut command with these options will generate a list of user names and their login shells from /etc/passwd. References:
In Bash, inserting 1>&2 after a command redirects
standard error to standard input.
standard input to standard error.
standard output to standard error.
standard error to standard output.
standard output to standard input.
In Bash, inserting 1>&2 after a command redirects standard output to standard error. This means that the output of the command that normally goes to the standard output stream (file descriptor 1) will be sent to the standard error stream (file descriptor 2) instead. This can be useful if we want to capture or discard both the normal output and the error output of a command. For example, if we want to run a command and send both its output and error to /dev/null (a special device that discards any data written to it), we can use:
command > /dev/null 1>&2
This will redirect the standard output of command to /dev/null, and then redirect the standard error of command to the same place as the standard output, which is /dev/null. The other options are not correct because:
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 will reduce all consecutive spaces down to a single space?
tr '\s' ' ' < a.txt > b.txt
tr -c ' ' < a.txt > b.txt
tr -d ' ' < a.txt > b.txt
tr -r ' ' '\n' < a.txt > b.txt
tr -s ' ' < a.txt > b.txt
The command that will reduce all consecutive spaces down to a single space is tr -s ’ ’ < a.txt > b.txt. This command uses the following options and syntax:
The output of this command will be a new file called b.txt that contains the same text as a.txt, except that any sequence of multiple spaces will be replaced by a single space. For example, if the file a.txt contains the following text:
This is a text file with multiple spaces.
The file b.txt will contain the following text:
This is a text file with multiple spaces.
The other commands are incorrect for the following reasons:
References:
Which of the following commands will print the last 10 lines of a text file to the standard output?
cat -n 10 filename
dump -n 10 filename
head -n 10 filename
tail -n 10 filename
The tail command prints the last part of a file to the standard output. The -n option specifies the number of lines to print. Therefore, tail -n 10 filename will print the last 10 lines of the file named filename. The other commands are either invalid or do not perform the desired task. The cat command concatenates files and prints them to the standard output, but it does not have a -n option. The dump command is used to backup filesystems, not to print files. The head command prints the first part of a file, not the last part. 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 www.howtogeek.com).
1- Running sleep 10 & 2+ Stopped ping www.howtogeek.com
References:
In a nested directory structure, which find command line option would be used to restrict the command to searching down a particular number of subdirectories?
-dirmax
-maxdepth
-maxlevels
-n
-s
The find command is used to search for files and directories that match certain criteria. The option -maxdepth can be used to restrict the command to searching down a particular number of subdirectories. The argument to -maxdepth is a positive integer that specifies the maximum depth of the directory tree to be searched. For example, -maxdepth 0 means only the current directory, -maxdepth 1 means the current directory and its direct subdirectories, and so on1. The option -maxdepth should be placed before any other expressions, as it affects the behavior of the whole command2. For example, to find all the files with the extension .txt in the current directory and its direct subdirectories, the command would be:
find . -maxdepth 1 -type f -name “*.txt”
The other options are not correct because:
When running the command
sed -e "s/a/b/" /tmp/file >/tmp/file
While /tmp/file contains data, why is /tmp/file empty afterwards?
The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
The command sed did not match anything in that file therefore the output is empty.
When the shell establishes the redirection it overwrites the target file before the redirected command starts and opens it for reading.
Redirection for shell commands do not work using the > character. It only works using the | character instead.
The problem with the command
sed -e “s/a/b/” /tmp/file >/tmp/file
is that it tries to read and write from the same file, which results in overwriting the file before the command can process it. The shell sets up the redirection by opening the file /tmp/file for writing and truncating it to zero length. Then it executes the sed command, which tries to read from the same file, but finds it empty. Therefore, the output is also empty and the file remains empty. A possible solution is to use a temporary file for the output and then rename it to the original file name. For example:
sed -e “s/a/b/” /tmp/file >/tmp/file.tmp && mv /tmp/file.tmp /tmp/file
This way, the original file is not overwritten until the sed command finishes successfully. The other options are either incorrect or not applicable. The file order is correct, the sed command does match something in the file, and the > character is valid for redirection. The | character is used for piping, not redirection. References:
Which grep command will print only the lines that do not end with a / in the file foo?
grep'/$' foo
grep '/#' foo
grep -v '/$' foo
grep -v '/#' foo
∗∗Thegrepcommandthatwillprintonlythelinesthatdonotendwitha/inthefilefooisgrep−v′/’ foo. This command uses the following options and pattern:
-v: Inverts the matching, meaning that it only outputs the lines that do not match the pattern. /:Matchesa/characterattheendofaline.The symbol represents the end of a line in regular expressions. foo: The name of the file to search.
The output of this command will show all the lines in the file foo that do not have a / as the last character. For example, if the file foo contains the following lines:
/home/user/ /var/log/messages /etc/passwd /usr/bin/
The output of the command will be:
/var/log/messages /etc/passwd
The other commands are incorrect for the following reasons:
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:
What is the maximum niceness value that a regular user can assign to a process with the nice command when executing a new process?
9
19
49
99
The maximum niceness value that a regular user can assign to a process with the nice command when executing a new process is 19. The niceness value is a user-space value that controls the priority of a process. The lower the niceness value, the higher the priority, and vice versa. The niceness value range is -20 to +19, where -20 is the highest priority and +19 is the lowest priority. The default niceness value is 0. The nice command can be used to run a new process with a modified niceness value. The syntax is: nice -n value command, where value is the niceness value and command is the process to run. For example, nice -n 10 sleep 60 will run the sleep command with a niceness value of 10 for 60 seconds. However, regular users can only increase the niceness value of their processes, not decrease it. This means that they can only lower the priority of their processes, not raise it. The minimum niceness value that a regular user can assign is 0, and the maximum is 19. Only the root user can assign a negative niceness value, which means raising the priority of a process. For example, nice -n -10 sleep 60 will run the sleep command with a niceness value of -10 for 60 seconds, but only if the user is root. The other options are not correct because:
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:
TESTED 23 Dec 2024
Copyright © 2014-2024 DumpsTool. All Rights Reserved