Which of the commands below might have produced the following output?
dig -t rax www.example.org
dig www.example.org
dig -t ns www.example.org
dig -t a www.example.org
dig -t soa www.example.org
Which environment variable is used by an X11 client to determine the X Server to connect to1? (Specify ONLY the variable name without any preceding commands or values.)
Display
What is true regarding public and pnvate SSH keys? (Choose TWO correct answers.)
For each user account, there is exactly one key pair that can be used to log into that account
The private key must never be revealed to anyone
Several different public keys may be generated for the same private key
To maintain the private key's confidentiality, the SSH key pair must be created by its owner
To allow remote logins, the user's private key must be copied to the remote server
Which directory holds configuration files for xinetd services? (Specify the full path to the directory)
/etc/xinetd,d/
Which of the following apt-get subcommands installs the newest versions of all currently installed packages?
auto-update
dist-upgrade
full-upgrade
install
update
The apt-get subcommand that installs the newest versions of all currently installed packages is dist-upgrade. The dist-upgrade subcommand performs the same function as the upgrade subcommand, which is to install the latest versions of the packages that are already installed on the system, but it also intelligently handles the dependencies and removes the obsolete packages if necessary. The dist-upgrade subcommand is useful when upgrading the entire system to a new release or distribution12.
The other options are either invalid or do not perform the desired task. The auto-update subcommand does not exist, and the update subcommand only updates the list of available packages from the repositories, but does not install any packages. The full-upgrade subcommand is an alias for the dist-upgrade subcommand, so it performs the same function, but it is not the standard name for the subcommand. The install subcommand installs new packages or specific versions of packages, but it does not upgrade all the currently installed packages. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
APT-GET Command in Linux {Detailed Tutorial With Examples} - phoenixNAP3
How do I get help on apt-get’s install subcommand?
APT Cheat Sheet | Packagecloud Blog
Which of the following commands lists all defined variables and functions within Bash?
env
export
env -a
set
echo $ENV
Which of the following sections exists in a systemd timer unit?
[Events]
[Timer]
[cron]
[Schedule]
[Trigger]
What is true regarding the configuration of yum? (Choose two.)
Changes to the repository configuration become active after running yum confupdate
Changes to the yum configuration become active after restarting the yumd service
The configuration of package repositories can be divided into multiple files
Repository configurations can include variables such as $basearch or $releasever
In case /etc/yum.repos.d/ contains files, /etc/yum.conf is ignored
The configuration of yum can be divided into multiple files, and repository configurations can include variables such as $basearch or $releasever. The main configuration file for yum is /etc/yum.conf, which contains the global options for yum and can also define repositories in the [repository] sections. However, it is recommended to define individual repositories in separate files in the /etc/yum.repos.d/ directory, which can be easier to manage and maintain. Each file in this directory should have a .repo extension and contain one or more [repository] sections with the repository name, URL, and other options12. Repository configurations can use yum variables to dynamically set values for certain options, such as the baseurl or the enabled. Yum variables are enclosed in curly braces and start with a dollar sign, such as {$basearch} or {$releasever}. These variables are replaced by their actual values at runtime, based on the system architecture, the operating system version, or other factors. Some of the common yum variables are34:
$basearch: The base architecture of the system, such as x86_64, i386, or arm.
$releasever: The release version of the operating system, such as 7, 8, or 9.
$arch: The exact architecture of the system, such as x86_64, i686, or armv7hl.
$uuid: A unique identifier for the system, generated by the product-id plugin.
$YUM0-$YUM9: Custom variables that can be set by the user in the /etc/yum/vars/ directory or the /etc/yum.conf file.
The other options are false or irrelevant. There is no yum confupdate command or yumd service, and changes to the yum configuration become active immediately after saving the files. The /etc/yum.conf file is not ignored if the /etc/yum.repos.d/ directory contains files, but the repository options in the /etc/yum.conf file can be overridden by the options in the .repo files. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
How to Use Yum Variables to Enhance your Yum Experience - Red Hat …3
Yum Variables - CentOS4
Which of the following commands displays the path to the executable file that would be executed when the command foo is invoked?
lsattr foo
apropos foo
locate foo
whatis foo
which foo
This command will display the path to the executable file that would be executed when the command foo is invoked. The syntax of the command is:
which [options] command
The which command is a utility that searches the directories listed in the PATH environment variable for the executable file that matches the given command. The options can modify the behavior of the which command, such as displaying all matches, ignoring aliases, or showing the version. The command is the name of the command to be located.
Therefore, the command which foo will search the PATH directories for the executable file named foo and print its full path on the standard output. If there are multiple matches, the command will print the first one found. If there is no match, the command will print nothing and return an exit status of 1.
The other commands are incorrect for the following reasons:
A, lsattr foo: This command will not display the path to the executable file, but it will display the file attributes of the file named foo in the current directory. The syntax of the command is:
lsattr [options] [file]
The lsattr command is a utility that lists the file attributes on a Linux second extended file system. The options can modify the behavior of the lsattr command, such as displaying the output in long format, recursing into subdirectories, or suppressing errors. The file is the name of the file whose attributes are to be listed. If no file is given, the command will list the attributes of all files in the current directory.
Therefore, the command lsattr foo will list the file attributes of the file named foo in the current directory, if it exists. If it does not exist, the command will report an error and return an exit status of 1.
B, apropos foo: This command will not display the path to the executable file, but it will display a list of manual page names and descriptions that contain the keyword foo. The syntax of the command is:
apropos [options] keyword
The apropos command is a utility that searches the whatis database for the keyword and prints the manual page names and descriptions that match. The whatis database is a set of files containing short descriptions of system commands and programs. The options can modify the behavior of the apropos command, such as using regular expressions, ignoring case, or displaying the section numbers. The keyword is the word to be searched in the whatis database.
Therefore, the command apropos foo will search the whatis database for the word foo and print the manual page names and descriptions that contain it. If there are no matches, the command will print nothing and return an exit status of 1.
C, locate foo: This command will not display the path to the executable file, but it will display a list of file names that contain the string foo. The syntax of the command is:
locate [options] pattern
The locate command is a utility that searches a database of file names and prints the file names that match the given pattern. The database is updated periodically by the updatedb command and may not reflect the current state of the file system. The options can modify the behavior of the locate command, such as using regular expressions, ignoring case, or limiting the number of results. The pattern is the string to be matched in the file names.
Therefore, the command locate foo will search the database of file names and print the file names that contain the string foo. If there are no matches, the command will print nothing and return an exit status of 1.
D, whatis foo: This command will not display the path to the executable file, but it will display a short description of the command or program named foo. The syntax of the command is:
whatis [options] name
The whatis command is a utility that searches the whatis database for the name and prints the manual page name and description that match. The whatis database is a set of files containing short descriptions of system commands and programs. The options can modify the behavior of the whatis command, such as displaying the section numbers, using wildcards, or searching in a specific section. The name is the name of the command or program to be described.
Therefore, the command whatis foo will search the whatis database for the name foo and print the manual page name and description that match. If there are no matches, the command will print nothing and return an exit status of 1.
Which of the following states can NetworkManager show regarding the system's network connectivity? (Choose TWO correct answers.)
up
portal
full
login-required
firewalled
What command is used to add OpenSSH private keys to a running ssh-agent instance? (Specify the command name only without any path.)
ssh-add
Which of the following getent invocations lists all existing users?
getent homes
getent uids
getent passwd
getent users
getent logins
Which of the following protocols is designed to access the video card output of a virtual machine?
KDE
X11
Xfce
SPICE
XDMCP
What is true regarding the statement beginning with #! that is found in the first line of a script? (Choose TWO correct answers.)
It prevents the script from being executed until the \ is removed
It triggers the installation of the scripts interpreter
It specifies the path and the arguments of the interpreter used to run the script
It defines the character encoding of the script
It is a comment that is ignored by the script interpreter
How do shadow passwords improve the password security in comparison to standard non-shadow passwords'?
Regular users do not have access to the password hashes of shadow passwords
Every shadow password is valid for 45 days and must be changed afterwards
The system's host key is used to encrypt all shadow passwords.
Shadow passwords are always combined with a public key that has to match the user's private key
Shadow passwords are stored in plain text and can be checked for weak passwords
Where is the systemd journal stored?
/var/jlog and /var/jlogd/
/proc/log and /proc/klog
/run/log/journal/ or /var/log/journal/
/var/log/syslog.bin or /var/log/syslog.jrn
/etc/systemd/journal/ or /usr/lib/systemd/journal/
If an alias Is exists, which of the following commands updates the ai as to point to dig contmfl nd is -1 instead of the alias's current target?
set ls-'ls -1"
alias ls=,ls -1'
alias --force ls='ls -1*
alias --update Is ls='ls -1'
realias Is-'Is -1'
What is the first program the Linux kernel starts at boot time when using System V init?
/lib/init.so
/proc/sys/kernel/init
/etc/rc.d/rcinit
/sbin/init
/boot/init
The first program the Linux kernel starts at boot time when using System V init is /sbin/init. System V init is a traditional init system that uses a series of shell scripts to initialize and manage the system services. The init program is the parent of all other processes and it is responsible for reading the /etc/inittab file and executing the appropriate scripts for each runlevel. The /sbin/init program is part of the 101.1 Determine and configure hardware settings topic of the LPI Linux Essentials certification program12. References:
Linux Essentials - Linux Professional Institute Certification Programs1
Exam 101 Objectives - Linux Professional Institute2
A guide to System V Init3
Linux Init Levels Explained: Init 0 - Init 64
Init Systems Unveiled — Understanding the Differences Between Systemd and SystemV5
Which of the following commands makes /bin/foo executable by everyone but writable only by its owner?
chmod u=rwx,go=rx /bin/foo
chmod o+rwx,a+rx /bin/foo
chmod 577 /bin/foo
chmod 775 /bin/foo
The correct command to make /bin/foo executable by everyone but writable only by its owner is chmod u=rwx,go=rx /bin/foo. This command uses the symbolic method to set the permissions for the user (u), group (g), and others (o) classes. The equal sign (=) means that the permissions are set exactly as specified, not added or removed. The letters r, w, and x represent the read, write, and execute permissions respectively. The comma (,) separates the different classes. The command means that the user has read, write, and execute permissions (rwx), while the group and others have only read and execute permissions (rx). The other options are incorrect because they use the wrong syntax or values for the chmod command. Option B uses the wrong indicators for the classes. The letter o means others, not owner. The letter a means all, not group. Option C uses the numeric method, but the value 577 is not correct. The numeric method uses octal numbers (0-7) to represent the permissions for each class. The first digit is for the user, the second for the group, and the third for others. Each digit is the sum of the values for the read (4), write (2), and execute (1) permissions. For example, 7 means rwx, 6 means rw-, 5 means r-x, and so on. The value 577 means that the user has read, write, and execute permissions (rwx), the group has read and execute permissions (r-x), but the others have only write and execute permissions (w-x), which is not what the question asked. Option D uses the numeric method, but the value 775 is not correct. The value 775 means that the user and the group have read, write, and execute permissions (rwx), while the others have only read and execute permissions (r-x). This means that the group can also write to the file, which is not what the question asked. References:
[LPI Linux Essentials - 1.3 Basic File Management]
[LPI Linux Essentials - 2.1 Using Devices, Linux Filesystems, Filesystem Hierarchy Standard]
[LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
[LPI Linux Essentials - 2.3 Disk Partitions]
How to Use the chmod Command on Linux - How-To Geek
Chmod Command in Linux (File Permissions) | Linuxize
Chmod command in Linux with examples - GeeksforGeeks
Which of the following statements is correct for a command line ending with a & character?
The command’s output is redirected to/dev/null.
The result of the command defines if the next command will be run.
Thecommand is run in background of the current shell.
The command is run as a direct child of theinitprocess.
The statement that is correct for a command line ending with a & character is that the command is run in background of the current shell. The & character tells the shell to run the command in the background, which means that the shell does not wait for the command to finish and returns the prompt immediately. The command’s output is not redirected to /dev/null, unless explicitly specified. The result of the command does not define if the next command will be run, unless the commands are separated by a logical operator such as && or ||. The command is not run as a direct child of the init process, unless the shell is the init process itself. References: [LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Weight: 25, Objective 103.1: Work on the command line, Background Processes
How can the list of files that would be installed by the RPM package file apache-xml.rpm be previewed?
rpm –qp apache-xml.rpm
rpm –qv apache-xml.rpm
rpm –ql apache-xml.rpm
rpm –qpl apache-xml.rpm
The command rpm -qpl apache-ql.rpm is used to preview the list of files that would be installed by the RPM package file apache-xml.rpm. This command queries the package file without installing it and lists the contents of the package. Here’s what each part of the command means:
rpm is the command-line tool used for managing RPM packages on Linux systems.
-qpl are options for the rpm command.
q stands for query mode
l stands for list the contents of the package.
p specifies that the package being queried is not installed, but is a file located on the system.
apache-xml.rpm is the name of the RPM package file you want to query.
So, when you run this command, it will display a list of all the files that are included in the apache-xml.rpm package file, without installing it. This can be useful for checking what files are included in the package before installing it or comparing it with another version of the package.
The other commands are either invalid or do not perform the same function as the correct answer. For example:
rpm -qp apache-xml.rpm will only display the name and version of the package, not the list of files.
rpm -qv apache-xml.rpm will display the verbose information about the package, such as the description, license, and changelog, but not the list of files.
rpm -ql apache-xml.rpm will list the files that are installed on the system by the apache-xml.rpm package, but only if the package is already installed. If the package is not installed, it will return an error.
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:
APT-GET Command in Linux {Detailed Tutorial With Examples} - phoenixNAP
Using apt-get Commands in Linux [Ultimate Guide] - It’s FOSS
Ubuntu ‘apt-get’ list of commands (list, update, upgrade, cheatsheet …
Which of the following commands changes the number of days before the ext3 filesystem on /dev/sda1 has to run through a full filesystem check while booting?
tune2fs -d 200 /dev/sda1
tune2fs -c 200 /dev/sda1
tune2fs -i 200 /dev/sda1
tune2fs -n 200 /dev/sda1
tune2fs --days 200 /dev/sda1
The correct command to change the number of days before the ext3 filesystem on /dev/sda1 has to run through a full filesystem check while booting is tune2fs -i 200 /dev/sda1. This command sets the interval between two filesystem checks to 200 days. The tune2fs command allows you to view and change various filesystem parameters on Linux ext2, ext3, or ext4 filesystems. The -i option specifies the time interval between checks. The other options are incorrect because they use the wrong parameters for the tune2fs command. Option A is wrong because the -d option is not supported by the tune2fs command. Option B is wrong because the -c option sets the maximum number of mounts, not days, before a check. Option D is wrong because the -n option is not supported by the tune2fs command. Option E is wrong because the --days option is not supported by the tune2fs command. References:
[LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
15 tune2fs command examples in Linux [Cheat Sheet] - GoLinuxCloud
Linux tune2fs command With Examples - GeeksforGeeks
tune2fs command-file system management - Linuxstar
tune2fs Command Examples - Gianforte School of Computing
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
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. The charactermatchestheendofaline.Forexample,World will 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 of the following commands will change all CR-LF pairs in an imported text file, userlist.txt, to Linux standard LF characters and store it as newlist.txt?
tr ‘\r\n’ ‘’ < userlist.txt > newlist.txt
tr –c ‘\n\r’ ‘’ < newlist.txt > userlist.txt
tr –d ‘\r’ < userlist.txt > newlist.txt
tr ‘\r’ ‘\n’ userlist.txt newlist.txt
tr –s ‘^M’ ‘^J’ userlist.txt newlist.txt
The tr command is used to translate, squeeze, or delete characters from a file or a stream. The -d option is used to delete characters that appear in the first operand. The \r and \n are escape sequences that represent the carriage return and the line feed characters, respectively. The CR-LF pair is the standard line ending for Windows text files, while the LF character is the standard line ending for Linux text files. Therefore, the command tr –d ‘\r’ < userlist.txt > newlist.txt will delete all the CR characters from the userlist.txt file and redirect the output to the newlist.txt file, effectively converting the line endings from Windows to Linux format. The other commands are incorrect because they either use the wrong syntax, the wrong operands, or the wrong redirection. References:
LPI 101-500 Exam Objectives, Topic 103.7, Weight 4
LPI Learning Materials, Chapter 3.7, Basic Scripting
Web Search Results, 1
QUESTIONNO: 54
When in Normal mode invi, which character can be used to begin a reverse search of the text?
A.?
B./
C.F
D.r
Answer: A
In vi, the ? character can be used to begin a reverse search of the text. This means that the search will start from the current cursor position and move backwards towards the beginning of the file. The search pattern can be any regular expression that matches the desired text. To repeat the search, the user can press n for the previous match or N for the next match. The / character can be used to begin a forward search of the text, which means that the search will start from the current cursor position and move forwards towards the end of the file. The F and r characters are not used for searching, but for other commands in vi. The F command is used to move the cursor to a previous occurrence of a specified character in the current line. The r command is used to replace the character under the cursor with another character. References:
LPI 101-500 Exam Objectives, Topic 103.8, Weight 4
LPI Learning Materials, Chapter 3.8, Advanced Scripting
Web Search Results,
Which of the following commands will mount an already inserted CD-ROM in /dev/sr0 onto an existing directory /mnt/cdrom when issued with root privileges?
mount /dev/cdrom /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
mount –t cdrom /dev/sr0 /mnt/cdrom
mount –l cdrom /dev/sr0 /mnt/cdrom
mount –f /dev/sr0/mnt/cdrom
The mount command is used to attach a filesystem to a directory on the system, which is called a mount point. The mount command requires the device name or the UUID of the filesystem as the first argument, and the mount point as the second argument. Optionally, the mount command can also take some options, such as the filesystem type, the mount options, and the label. The syntax of the mount command is:
mount [options] device mountpoint
In this question, the device name of the CD-ROM is /dev/sr0, and the mount point is /mnt/cdrom. Therefore, the correct command to mount the CD-ROM is:
mount /dev/sr0 /mnt/cdrom
This command will mount the CD-ROM as a read-only filesystem with the type iso9660, which is the standard format for optical discs. The mount command can automatically detect the filesystem type and the mount options, so there is no need to specify them explicitly. However, if you want to specify them, you can use the -t and -o options, respectively. For example, the following command is equivalent to the previous one:
mount -t iso9660 -o ro /dev/sr0 /mnt/cdrom
The other options are not correct because:
A. mount /dev/cdrom /mnt/cdrom: This command may work on some systems, but it is not guaranteed to be correct. The /dev/cdrom is usually a symbolic link to the actual device name of the CD-ROM, which can vary depending on the system. For example, on some systems, the /dev/cdrom may point to /dev/sr0, but on others, it may point to /dev/scd0 or /dev/hdc. Therefore, it is better to use the actual device name of the CD-ROM, which can be found by using the lsblk or the dmesg command.
C. mount -t cdrom /dev/sr0 /mnt/cdrom: This command is not valid because cdrom is not a valid filesystem type. The filesystem type for optical discs is iso9660, not cdrom. The mount command will fail with an error message saying:
mount: unknown filesystem type ‘cdrom’
D. mount -l cdrom /dev/sr0 /mnt/cdrom: This command is not valid because -l is not a valid option for the mount command. The -l option is used to list all the mounted filesystems, not to mount a filesystem. The mount command will fail with an error message saying:
mount: can’t find /dev/sr0 in /etc/fstab
E. mount -f /dev/sr0/mnt/cdrom: This command is not valid because it is missing a space between the device name and the mount point. The mount command requires two separate arguments for the device name and the mount point, separated by a space. Also, the -f option is used to fake the mount operation, not to perform the actual mount. The mount command will fail with an error message saying:
mount: /dev/sr0/mnt/cdrom: mount point does not exist.
Which of the following commands changes the ownership of file.txt to the user dan and the group staff?
chown dan/staff file.txt
chown dan:staff file.txt
chown -u dan -g staff file.txt
chown dan -g staff file.txt
The correct command to change the ownership of file.txt to the user dan and the group staff is chown dan:staff file.txt. This command uses the colon (:) as a separator between the user and the group. The other options are incorrect because they use the wrong syntax or options for the chown command. Option A uses a slash (/) instead of a colon, which is not valid. Option C uses the -u and -g options, which are not supported by the chown command. Option D uses the -g option, which only changes the group, not the user. References:
[LPI Linux Essentials - 1.3 Basic File Management]
[LPI Linux Essentials - 2.1 Using Devices, Linux Filesystems, Filesystem Hierarchy Standard]
[LPI Linux Essentials - 2.2 Mounting, Unmounting Filesystems]
[LPI Linux Essentials - 2.3 Disk Partitions]
Chown Command in Linux: How to Change File Ownership - phoenixNAP
chown command in Linux with Examples - GeeksforGeeks
Chown Command in Linux: How to Use It - Help Desk Geek
Chown Command in Linux (File Ownership) | Linuxize
What is the process ID number of the init process on a SysV init based system?
-1
0
1
It is different with each reboot.
It is set to the current run level.
The process ID number of the init process on a SysV init based system is 1. The init process is the first process that runs on the system, and it is responsible for initializing the user-space environment and spawning all other processes. The init process is always the first process that runs on the system, and it has the process ID (PID) of 1. The PID is a unique identifier for each process on the system, and it is assigned by the kernel. The PID of the init process is always 1, regardless of the reboot or the run level. You can verify the PID of the init process by using the ps command, which shows information about the processes on the system. For example, to show the PID, the user, the command, and the arguments of the init process, use the following command:
ps -p 1 -o pid,user,cmd
The output of the command will show something like:
PID USER CMD 1 root /sbin/init
This shows that the init process has the PID of 1, the user of root, and the command of /sbin/init.
Which SysV init configuration file is commonly used to set the default run level? (Specify the full name of the file, including path.)
/etc/inittab
The /etc/inittab file is a plain text file that contains information about the initialization process of the system. It defines the default run level, the available run levels, and the actions to be taken when entering or leaving a run level. The default run level is the mode of operation that the system starts up into, and it determines which services and processes are running. The default run level is specified by a line similar to the following in the /etc/inittab file:
id:5:initdefault:
The number after the first colon indicates the default run level, which can range from 0 to 6. The meaning of each run level is:
0 — Halt
1 — Single-user text mode
2 — Not used (user-definable)
3 — Full multi-user text mode
4 — Not used (user-definable)
5 — Full multi-user graphical mode (with an X-based login screen)
6 — Reboot
To change the default run level, edit the /etc/inittab file as root and change the number to the desired run level. For example, to change the default run level to 3, use the following command:
sudo nano /etc/inittab
And change the line to:
id:3:initdefault:
Then save and exit the file. The changes will take effect on the next reboot.
Which command reads and displays the current contents of the Kernel Ring Buffer on the command line? (Specify ONLY the command without any path or parameters.)
dmesg
The dmesg command is used to print or control the kernel ring buffer. The kernel ring buffer is a special kind of buffer that stores the messages generated by the kernel, such as the boot messages, the hardware errors, the driver information, etc. The kernel ring buffer is a fixed-size circular buffer, which means that when it is full, the oldest messages are overwritten by the new ones. The dmesg command can show the messages in the kernel ring buffer, as well as filter, save, or clear them. The syntax of the dmesg command is:
dmesg [options]
The options are optional, and they can modify the behavior of the dmesg command, such as changing the output format, the timestamp, the level, the facility, the color, etc. For more information, see the dmesg man page1 or the Linuxize tutorial2.
What do the permissions -rwSr-xr-x mean for a binary file when it is executed as a command?
The command is SetUID and it will be executed with the effective rights of the owner.
The command will be executed with the effective rights of the group instead of the owner.
The execute flag is not set for the owner. Therefore, the SetUID flag is ignored.
The command will be executed with the effective rights of the owner and group.
The permissions -rwSr-xr-x mean that the file is readable and writable by the owner, readable and executable by the group, and readable and executable by others. The S in the owner’s permissions indicates that the file has the SetUID bit set, which means that when the file is executed as a command, it will run with the effective user ID of the file owner, rather than the user who executed it. This allows the command to perform privileged operations that the user normally cannot do. For example, the /bin/passwd command has the SetUID bit set, so that it can modify the /etc/shadow file, which is only writable by root. References: LPI Linux Administrator, File Permissions and Attributes
Which umask value will result in the default access permissions of 600 (rw-------) for files and 700 (rwx------) for directories? (Specify only the numerical umask value.)
0077, 077
The umask value that will result in the default access permissions of 600 (rw-------) for files and 700 (rwx------) for directories is 077. This is because the umask value is an octal number that represents the permissions that are not given to the files or directories. To calculate the umask value, we need to subtract the desired permissions from the maximum permissions, which are 666 for files and 777 for directories. For example, if we want the files to have the permissions 600 (rw-------), which means read and write for the owner and no permissions for the group and others, we need to subtract 600 from 666, which gives us 066. Similarly, if we want the directories to have the permissions 700 (rwx------), which means read, write, and execute for the owner and no permissions for the group and others, we need to subtract 700 from 777, which gives us 077. The umask value is the minimum of these two values, which is 077. The first digit of the umask value is for the special permissions, such as setuid, setgid, and sticky bit, and it is usually set to 0. Therefore, the final umask value is 077. For more information on how to use the umask command, you can refer to the following articles:
What Is umask in Linux, and How Do You Use It? - How-To Geek
Umask command in Linux with examples - GeeksforGeeks
What is UMASK and how to set UMASK in Linux/Unix?
How to Set and Update the Default Umask Value - phoenixNAP
In the vi editor, what vi command will copy (but not paste) from the current line at the cursor and the following 16 lines (17 lines total)? Specify the correct vi command without spaces.
17yy
The vi editor is a text editor that operates in two modes: command mode and insert mode. In command mode, the user can enter commands to perform various operations on the text, such as copying, pasting, deleting, moving, searching, etc. In insert mode, the user can type text into the file. To switch from command mode to insert mode, the user can press i, a, o, or other keys. To switch from insert mode to command mode, the user can press Esc. The yy command is used to copy (yank) the current line into a buffer. The number before the yy command specifies how many lines to copy, starting from the current line. Therefore, the command 17yy will copy the current line and the following 16 lines (17 lines total) into a buffer. The buffer can then be pasted into another location by using the p or P command. Note that the command 17yy does not paste the copied lines, it only copies them. References:
LPI 101-500 Exam Objectives, Topic 103.8, Weight 4
LPI Learning Materials, Chapter 3.8, Advanced Scripting
Web Search Results, 1
Which of the following commands will display the inode usage of each mounted filesystem?
du –i
df –i
lsfs –i
printfs –i
The df command is used to report the disk space usage of the filesystems on a Linux system. The -i option is used to display the inode usage of each mounted filesystem. An inode is a data structure that stores the metadata of a file or directory, such as its size, owner, permissions, etc. Each filesystem has a fixed number of inodes, which limits the number of files and directories that can be created on it. The df -i command shows the total number of inodes, the number of used and free inodes, and the percentage of inode usage for each filesystem. For example:
[tcarrigan@rhel ~]$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1310720 83167 1227553 7% / devtmpfs 249974 386 249588 1% /dev tmpfs 251374 1 251373 1% /dev/shm tmpfs 251374 570 250804 1% /run tmpfs 251374 16 251358 1% /sys/fs/cgroup /dev/sda1 524288 312 523976 1% /boot tmpfs 251374 1 251373 1% /run/user/1000
The other options are not valid commands or options. The du command is used to estimate the disk usage of files and directories, but it does not have an -i option. The lsfs and printfs commands do not exist on a standard Linux system. References:
Inodes and the Linux filesystem | Enable Sysadmin
filesystems - Find where inodes are being used - Unix & Linux Stack …
filesystems - How much space does an inode occupy? - Unix & Linux Stack …
When planning a partition scheme, which of the following directories could be considered for separate partitions? (Choose three.)
/etc
/home
/var
/lib
/opt
When planning a partition scheme, it is advisable to consider creating separate partitions for some directories that may contain large amounts of data, have different backup or security requirements, or benefit from being on different filesystems. Some of the common directories that could be considered for separate partitions are:
/home: This directory contains the personal files and settings of the users. Creating a separate partition for /home can make it easier to backup, restore, or upgrade the system without affecting the user data. It can also improve security by allowing different mount options such as noexec or nosuid. Additionally, it can help to prevent the system from becoming unusable if the users fill up their disk space with personal files123.
/var: This directory contains variable data such as logs, caches, spool files, databases, and web server content. Creating a separate partition for /var can prevent the system from crashing or becoming unresponsive if the /var partition fills up due to excessive logging or caching. It can also improve performance by allowing different filesystem options such as noatime or nodiratime. Furthermore, it can enhance security by isolating the data that may be modified by external sources such as web applications or mail servers124.
/opt: This directory contains optional software packages that are not part of the standard distribution. Creating a separate partition for /opt can make it easier to manage, backup, or remove these packages without affecting the rest of the system. It can also allow different filesystem types or features that may be required by some of the software installed in /opt125.
Other directories that could be considered for separate partitions are /boot, /tmp, /usr, and /srv, depending on the system requirements and preferences12 . References:
Linux Partitioning Recommendations | Average Linux User
Linux Disk Partitioning Schemes - Land of Linux
C.3. Recommended Partitioning Scheme - Debian
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 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 from kernel 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
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
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
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:
IO-APIC-edge: An edge-triggered interrupt from the I/O Advanced Programmable Interrupt Controller (APIC), which is a hardware device that handles and distributes interrupts.
IO-APIC-fasteoi: A fast end-of-interrupt from the I/O APIC, which means that the interrupt is acknowledged early to allow nesting interrupts.
PCI-MSI-edge: A Message Signaled Interrupt (MSI) from the Peripheral Component Interconnect (PCI) bus, which is a hardware bus that connects devices to the system. MSI is a method of sending interrupts using special messages instead of dedicated lines.
NMI: A Non-Maskable Interrupt, which is a hardware interrupt that cannot be ignored by the CPU and usually indicates a critical error.
LOC: A Local timer interrupt, which is a periodic interrupt generated by a local APIC on each CPU core for scheduling purposes.
RES: A Rescheduling interrupt, which is a type of inter-processor interrupt (IPI) that is sent to a CPU core to force it to reschedule its current task.
To check if a new ethernet card might be conflicting with another device, you can look for the driver name of the ethernet card in the /proc/interrupts file and see if it shares the same IRQ number with another device. If so, you can try to change the IRQ assignment of the devices or use the smp_affinity file to control which CPU cores can handle the interrupt12.
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:
Device IRQ settings1: The lspci command can show the interrupt request (IRQ) number assigned to each device by using the -v option. The IRQ number indicates how the device communicates with the CPU.
PCI bus speed2: The lspci command can show the speed of the PCI bus by using the -vv option. The speed is expressed in megahertz (MHz) or gigahertz (GHz) and indicates how fast the data can be transferred between the device and the bus.
Device vendor identification3: The lspci command can show the name and identification number of the device vendor by using the -n or -nn option. The vendor identification helps to identify the manufacturer and model of the device.
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:
-n or --nobanner: Suppress the banner (the header line with the hostname, date, and time) from the output. This option can only be used by the root user.
-v or --version: Display version information and exit.
-h or --help: Display help message and exit.
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:
bcast: There is no such command in Linux.
mesg: This command is used to control write access to the terminal. It does not send messages to other users.
print: This command is used to print files or data to a printer. It does not send messages to other users.
yell: There is no such command in Linux.
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 the system. 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 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:
Stage 1: This stage is located in the Master Boot Record (MBR) of the first hard disk or the boot sector of a partition. Its main function is to load either Stage 1.5 or Stage 22.
Stage 1.5: This stage is located in the first 30 KB of hard disk immediately following the MBR or in the boot sector of a partition. It contains the code to access the file system that contains the GRUB configuration file. Its main function is to load Stage 22.
Stage 2: This stage is located in an ordinary file system, usually in the /boot/grub directory. It contains the code to display the GRUB menu and to load the kernel and initrd images. It can also load additional modules to support other file systems or features2.
The message “Hard Disk Error” is displayed on the screen during Stage 1 of the GRUB boot process. This indicates that the next Stage (either Stage 1.5 or Stage 2) cannot be read from the hard disk because GRUB was unable to determine the size and geometry of the disk3. This could occur because the BIOS translated geometry has been changed by the user or the disk is moved to another machine or controller after installation, or GRUB was not installed using itself (if it was, the Stage 2 version of this error would have been seen during that process and it would not have completed the install)3.
The other options in the question are not correct because:
A. The kernel was unable to execute /bin/init: This error would occur in Stage 2, after the kernel and initrd images are loaded, not in Stage 14.
C. One or more of the filesystems on the hard disk has errors and a filesystem check should be run: This error would also occur in Stage 2, when GRUB tries to access the file system that contains the GRUB configuration file, not in Stage 15.
D. The BIOS was unable to read the necessary data from the Master Boot Record to begin the boot process: This error would prevent GRUB from starting at all, not in Stage 16.
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.
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 .
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:
systemd: A relatively new and modern init system that aims to provide a unified and efficient way of managing system and service states. It is compatible with SysV and LSB init scripts, and supports features such as parallel processing, socket activation, logging, job scheduling, and more. It is the default init system for many popular Linux distributions, such as Fedora, Debian, Ubuntu, Arch Linux, and others12.
Upstart: An event-based init system developed by Ubuntu as a replacement for SysV init. It starts and stops system tasks and processes based on events, such as hardware changes, network availability, filesystem mounting, etc. It is a hybrid init system that uses both SysV and systemd scripts, and supports features such as parallel processing, dependency tracking, logging, and more. It is the default init system for some older versions of Ubuntu, and some other Linux distributions, such as Linux Mint and Chrome OS12.
SysV init: A mature and traditional init system that follows the System V (SysV) design of Unix operating systems. It uses a series of runlevels to define the state of the system, and executes scripts in the /etc/rc.d or /etc/init.d directories according to the current runlevel. It is simple and stable, but lacks some features of modern init systems, such as parallel processing, event handling, dependency tracking, etc. It is still used by some Linux distributions, such as Slackware, Gentoo, and others12.
Which of the following commands brings a system running SysV init into a state in which it is safe to perform maintenance tasks? (Choose TWO correct answers.)
shutdown -R 1 now
shutdown -single now
init 1
telinit 1
runlevel 1
The commands init 1 and telinit 1 both bring a system running SysV init into a state in which it is safe to perform maintenance tasks. This state is also known as single-user mode or runlevel 1, where only the root user can log in and no network services are running. The command shutdown -R 1 now is incorrect, because it reboots the system instead of entering single-user mode. The command shutdown -single now is invalid, because the -single option does not exist for the shutdown command. The command runlevel 1 is also invalid, because runlevel is a command that displays the current and previous runlevels, not a command that changes the runlevel. References:
1: SysVinit - ArchWiki
2: Linux: How to write a System V init script to start, stop, and restart my own application or service - nixCraft
3: sysvinit - Gentoo wiki
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 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:
1: SysVinit - ArchWiki
2: Linux: How to write a System V init script to start, stop, and restart my own application or service - nixCraft
3: sysvinit - Gentoo wiki
You are having some trouble with a disk partition and you need to do maintenance on this partition but your users home directories are on it and several are logged in. Which command would disconnect the users and allow you to safely execute maintenance tasks?
telinit 1
shutdown -r now
killall -9 inetd
/bin/netstop --maint
/etc/rc.d/init.d/network stop
The command that would disconnect the users and allow you to safely execute maintenance tasks on a disk partition is telinit 112. The telinit command is used to change the runlevel of the system, which is a mode of operation that defines what processes and services are running3. The runlevel 1, also known as single-user mode, is a mode that allows only the root user to log in, and disables all network services and graphical interfaces4. This mode is useful for performing system maintenance and recovery tasks, such as repairing a disk partition5.
The other options in the question are not correct because:
B. shutdown -r now: This command would reboot the system immediately, without disconnecting the users gracefully or allowing you to do any maintenance tasks.
C. killall -9 inetd: This command would kill the inetd process, which is a daemon that manages network services. This would not disconnect the users who are already logged in, and it would not stop other processes that might interfere with the maintenance tasks.
D. /bin/netstop --maint: There is no such command in Linux.
E. /etc/rc.d/init.d/network stop: This command would stop the network service, which would disconnect the users who are logged in remotely, but not the ones who are logged in locally. It would also not stop other processes that might interfere with the maintenance tasks.
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:
silent: There is no such kernel parameter in Linux.
verbose=0: This parameter is used to set the verbosity level of the kernel messages, but it does not suppress them completely. The valid values for this parameter are from 0 (quiet) to 7 (debug)5.
nomesg: This parameter is used to disable all kernel messages on the console, including the emergency ones. This parameter is not recommended for normal use, as it can hide critical errors and prevent troubleshooting.
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:
1: How to view all boot messages in Linux after booting? - Super User
2: dmesg(1) - Linux manual page
3: Kernel ring buffer - Wikipedia
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:
Timestamps. RPM compares the modification time of the installed files with the original time stored in the RPM database. If the file has been modified after installation, the timestamp will differ and RPM will report it with an M flag1.
MD5 checksums. RPM calculates the MD5 checksum of the installed files and compares it with the original checksum stored in the RPM database. If the file has been altered in any way, the checksum will differ and RPM will report it with an 5 flag1.
File sizes. RPM compares the size of the installed files with the original size stored in the RPM database. If the file has been truncated or appended, the size will differ and RPM will report it with an S flag1.
RPM does not take into consideration the following information:
Inodes. RPM does not check the inode number of the installed files, as it is not a reliable indicator of file identity. The inode number can change if the file is moved, copied, or restored from a backup2.
GnuPG signatures. RPM does not verify the GnuPG signatures of the installed files, as they are not part of the RPM package format. The GnuPG signatures are used to verify the authenticity and integrity of the RPM package files before installation, not after3.
Which function key is used to start Safe Mode in Windows NT?
F10
F8
F6
Windows NT does not support Safe Mode
The function key that is used to start Safe Mode in Windows NT is none of the above, because Windows NT does not support Safe Mode. Safe Mode is a diagnostic mode of Windows that starts the system with minimal drivers and services, allowing the user to troubleshoot problems and restore the system to a normal state1. Safe Mode was introduced in Windows 95 and later versions, but not in Windows NT 4.0 and earlier2.
The other options are incorrect for the following reasons:
F10. This function key is used to access the Recovery Console in Windows XP, which is a command-line interface that allows the user to perform various administrative tasks, such as repairing the boot sector, restoring the registry, or copying files3. The Recovery Console is not the same as Safe Mode, and it is not available in Windows NT.
F8. This function key is used to access the Advanced Boot Options menu in Windows Vista and later versions, which allows the user to choose from various boot modes, including Safe Mode, Last Known Good Configuration, Debugging Mode, and others4. In Windows NT, pressing F8 during startup only displays a simple menu with three options: Normal, VGA mode, and Boot Logging5. None of these options are equivalent to Safe Mode.
F6. This function key is used to load additional drivers during the installation of Windows, such as SCSI or RAID drivers, from a floppy disk or a USB flash drive6. This function key has nothing to do with Safe Mode, and it is not relevant after the installation is completed.
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:
B. apt-get upgrade: This command is used to upgrade the installed packages to the latest versions, not to update the list of available packages12.
C. apt-cache update: There is no such command in Linux. The apt-cache command is used to query and display information about the packages, not to update them4.
D. apt-get refresh: There is no such command in Linux. The closest command is apt-get update, which is the correct answer.
E. apt-cache upgrade: There is no such command in Linux. The closest command is apt-get upgrade, which is not the correct answer.
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:
Filesystem Hierarchy Standard
What is the difference between the --remove and the --purge action with the dpkg command?
--remove removes the program, --purge also removes the config files
--remove only removes the program, --purge only removes the config files
--remove removes a package, --purge also removes all packages dependent on it
--remove removes only the package file itself, --purge removes all files related to the package
The dpkg command is a tool to install, build, remove and manage Debian packages. The option --remove is used to remove an installed package, but it does not remove the configuration files that may have been modified by the user. The option --purge is used to remove an installed package and also delete its configuration files. This can be useful if the user wants to completely uninstall a package and start from scratch if it is reinstalled later. The syntax is: dpkg --remove package or dpkg --purge package. For example, dpkg --remove nginx will remove the nginx web server package, but it will leave the configuration files in /etc/nginxdpkg --purge nginx will remove the nginx package and also delete the configuration files in /etc/nginx1. The other options are not correct because:
–remove only removes the program, --purge only removes the config files: This is false, because --purge also removes the program, not just the config files.
–remove removes a package, --purge also removes all packages dependent on it: This is false, because --purge does not remove any other packages, only the specified one. To remove a package and its dependencies, the apt-get command can be used with the option --auto-remove2.
–remove removes only the package file itself, --purge removes all files related to the package: This is false, because --remove also removes the files that are installed by the package, not just the package file itself. --purge only removes the configuration files that are not removed by --remove. References:
dpkg(1) — dpkg — Debian buster — Debian Manpages
How to remove a package and its dependencies with dpkg? - Ask Ubuntu
Which of the following commands lists the dependencies of a given dpkg package?
apt-cache depends-onpackage
apt-cache dependencies package
apt-cache depends package
apt-cache requires package
The apt-cache command is used to query the APT cache for information about packages. The depends option shows a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. For example, apt-cache depends ubuntu-restricted-extras will show the dependencies of the ubuntu-restricted-extras package. The other options are not valid for the apt-cache command. References:
How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions
Check DEB package dependencies on Ubuntu / Debian
Which command will disable swapping on a device? (Specify ONLY the command without any path or parameters.)
Swapoff
/sbin/swapoff
A
The swapoff command is used to disable swapping on a device or a file. It takes the path of the device or file as an argument, or -a to disable all swaps. Disabling swap can improve the performance of the system if there is enough physical memory, or it can be necessary if the swap size needs to be changed. However, disabling swap can also cause problems if the system runs out of memory and has no swap space to use. References:
How to Disable Swap in Linux - Linux Handbook
How to Permanently Disable Swap in Linux? - GeeksforGeeks
LPI Linux Essentials - 1.1 Operating System Basics
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:
To dynamically change the size of logical volumes. LVM allows the user to increase or decrease the size of a logical volume without having to repartition the disk or reboot the system. This can be useful for allocating more space to a volume that is running out of space, or freeing up space from a volume that is not needed anymore.
To create snapshots. LVM allows the user to create a snapshot of a logical volume, which is a copy of the volume at a certain point in time. Snapshots can be used for backup purposes, as they can be restored to the original volume if needed. Snapshots can also be used for testing purposes, as they can be mounted as read-only or read-write volumes without affecting the original volume.
To dynamically create or delete logical volumes. LVM allows the user to create or delete logical volumes on the fly, without having to repartition the disk or reboot the system. This can be useful for creating temporary volumes for specific purposes, or deleting volumes that are no longer needed.
LVM cannot be used for the following purposes:
To create RAID 9 arrays. RAID 9 is not a valid RAID level, and LVM does not support RAID functionality. RAID is a technique that uses multiple disks to provide redundancy, performance, or both. RAID can be implemented at the hardware level, by using a RAID controller, or at the software level, by using tools such as mdadm or dmraid. LVM can work on top of RAID devices, but it cannot create them.
To encrypt logical volumes. LVM does not provide encryption functionality. Encryption is a technique that protects data from unauthorized access by using a secret key to transform the data into an unreadable form. Encryption can be implemented at the disk level, by using tools such as dm-crypt or LUKS, or at the file system level, by using tools such as eCryptfs or EncFS. LVM can work on top of encrypted devices, but it cannot encrypt them.
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 library search path in the executable at link time, but it is not an environment variable that can be set or modified at run time2. References:
LPI Exam 101 Detailed Objectives, section 1.101.3
ld-linux(8) — Linux manual page
Setting the dynamic linker with an environment variable - narkive
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:
dpkg-reconfigure(8) - Linux man page
Linux Professional Institute: Exam 101 Objectives
In which directory must definition files be placed to add additional repositories to yum?
/etc/yum.repos.d
/etc/yum.repos.d/
yum.repos.d
yum.repos.d/
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
Which of the following commands can be used to download the RPM package kernel without installing it?
yum download --no-install kernel
yumdownloader kernel
rpm --download --package kernel
rpmdownload kernel
The command that can be used to download the RPM package kernel without installing it is yumdownloader kernel. This command is part of the yum-utils package, which contains a suite of helper tools for yum package manager. To use this command, you need to install the yum-utils package first1. The downloaded package will be saved in the current directory. You need to use root privilege because yumdownloader will update package index files during downloading. Unlike yum command, yumdownloader will not download any dependent packages1.
The other commands are either invalid or do not have the desired functionality. yum download --no-install kernel is not a valid yum command, as yum does not have a --no-install option2. rpm --download --package kernel is not a valid rpm command, as rpm does not have a --download or a --package option3. rpmdownload kernel is not a standard Linux command. rpm has a native support to download a package from a URL and install it, but not to download a package without installing it4.
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:
apt is a high-level command-line tool that provides a user-friendly way to manage packages, but it does not have a search option3.
apt-get is a low-level command-line tool that handles the installation and removal of packages, but it does not have a search option4.
apt-search is not a valid command.
dpkg is a tool to install, build, remove and manage Debian packages, but it does not have a search option5. It can only list the installed packages with the option -l4. References:
How To Search For Available Packages From Command Line In Debian, Ubuntu Or Linux Mint [APT] - Linux Uprising Blog
apt(8) — apt — Debian buster — Debian Manpages
How to List Installed Packages on Debian | Linuxize
Debian / Ubuntu Linux search package names with apt-cache command
dpkg(1) — dpkg — Debian buster — Debian Manpages
Which option to the yum command will update the entire system? (Specify ONLY the option name without any additional parameters.)
update
upgrade
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:
Yum Command Cheat Sheet for Red Hat Enterprise Linux
"yum update" Explained for Beginners!
How to Install Updates on CentOS 7
Which option to the yum command will update the entire system?
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:
type is the access method, such as http, ftp, file, etc.
uri is the Uniform Resource Identifier (URI) of the repository, such as http://deb.debian.org/debian
suite is the distribution code name or archive name, such as stable, testing, unstable, etc.
component is an optional section of the repository, such as main, contrib, non-free, etc.
For example, a typical sources.list file for Debian stable could look like this:
deb http://deb.debian.org/debian stable main contrib non-free deb-src http://deb.debian.org/debian stable main contrib non-free
deb http://deb.debian.org/debian-security/ stable/updates main contrib non-free deb-src http://deb.debian.org/debian-security/ stable/updates main contrib non-free
deb http://deb.debian.org/debian stable-updates main contrib non-free deb-src http://deb.debian.org/debian 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.
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:
A. kill -HUP $(pidof grub): This command would send the hangup signal (HUP) to the process ID (PID) of grub, which is a command-line interface for GRUB. This would not update the GRUB configuration file or install GRUB on the device or partition.
C. grub: This command would run the command-line interface for GRUB, which allows the user to interact with GRUB and execute various commands. This would not update the GRUB configuration file or install GRUB on the device or partition, unless the user explicitly runs the appropriate commands within the interface.
D. No action is required: This option is false, because modifying the /etc/default/grub file alone does not affect the GRUB configuration file or the GRUB installation. The user needs to run either grub-install or grub-mkconfig to apply the changes.
Which of the following apt-get commands will install the newest versions of all currently installed packages without removing any packages or installing new packages that are not already installed?
auto-update
upgrade
dist-upgrade
install
update
The apt-get command upgrade will install the newest versions of all currently installed packages without removing any packages or installing new packages that are not already installed. It will only upgrade packages that can be upgraded without changing the dependencies1. The syntax is: apt-get upgrade. For example, apt-get upgrade nginx will update the nginx package to the latest version available in the repositories, if there is one2. The other options are not correct because:
auto-update is not a valid apt-get command.
dist-upgrade will also install new packages or remove existing packages if that is required to resolve a package conflict1. It is more aggressive than upgrade and may change the system in unexpected ways3.
install will install new packages or upgrade existing packages to the specified version1. It may also install or remove dependencies as needed4.
update will only resynchronize the package index files from the sources, but it will not install or upgrade any packages1. References:
apt-get(8) — apt — Debian buster — Debian Manpages
How to Update Nginx on Ubuntu 18.04 | Linuxize
What is “dist-upgrade” and why does it upgrade more than “upgrade”? - Ask Ubuntu
How to Install Specific Version of Package using apt-get - TecAdmin
Which of the following is correct when talking about mount points?
Every existing directory can be used as a mount point.
Only empty directories can be used as a mount point.
Directories need to have the SetUID flag set to be used as a mount point.
Files within a directory are deleted when the directory is used as a mount point.
The correct answer when talking about mount points is that every existing directory can be used as a mount point. A mount point is a directory in the Linux file-system where a file system, partition, or storage device can be attached and accessed1. To create a mount point, you need root privileges. Mounting means making the contents of the attached file system, partition, or storage device available in the mount point directory1.
The other options are incorrect for the following reasons:
Only empty directories can be used as a mount point. This is not true, as any directory can be used as a mount point, regardless of whether it contains files or not. However, if the directory is not empty, the files inside it will be hidden by the mounted file system until it is unmounted2. Therefore, it is recommended to use empty directories as mount points to avoid confusion and data loss2.
Directories need to have the SetUID flag set to be used as a mount point. This is not true, as the SetUID flag is a special permission that allows a file to be executed with the privileges of its owner, regardless of who runs it3. This flag has nothing to do with mounting file systems, and it is not required for a directory to be used as a mount point4.
Files within a directory are deleted when the directory is used as a mount point. This is not true, as the files within a directory are not deleted when the directory is used as a mount point. They are only hidden by the mounted file system until it is unmounted2. The files are still present on the disk and can be recovered by unmounting the file system or using another mount point to access them2.
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.
In the vi editor, which of the following commands will copy the current line into the vi buffer?
c
cc
1c
yy
1y
The command that will copy the current line into the vi buffer is yy. The yy command is a shorthand for yank yank, which means to yank (copy) the current line. The vi buffer is a temporary storage area where the copied text is stored until it is pasted somewhere else. The yy command can also be preceded by a number to indicate how many lines to copy. For example, the command 3yy will copy the current line and the next two lines into the buffer.
The other commands are incorrect for the following reasons:
A. c: This command is a shorthand for change, which means to delete the text specified by the following motion and enter insert mode. For example, the command cw will delete the current word and allow the user to type a new one.
B. cc: This command is a shorthand for change change, which means to delete the current line and enter insert mode. This command is similar to dd followed by i, but it is faster and more convenient.
C. 1c: This command is not valid, as it is missing a motion after the change command. The motion specifies what text to delete and replace. For example, the command 1cw will delete one word and enter insert mode.
E. 1y: This command is also not valid, as it is missing a motion after the yank command. The motion specifies what text to copy into the buffer. For example, the command 1yw will copy one word into the buffer.
What is the output of the following command?
echo "Hello World" | tr -d aieou
Hello World
eoo
Hll Wrld
eoo Hll Wrld
The tr command is used to translate or delete characters from a given input. The -d option specifies that the characters in the second argument should be deleted from the input. In this case, the second argument is aieou, which are the vowels in the English alphabet. Therefore, the tr command will delete any vowel from the input, which is Hello World. The output will be the input without any vowels, which is Hll Wrld. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of tr to perform basic text transformations.
[LPI Linux Essentials Certification All-in-One Exam Guide], Chapter 5: Working with Files, Page 165, Using the tr Command.
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:
A. standard error to standard input: This is not possible, because standard input is a read-only stream, and we cannot redirect output to it.
B. standard input to standard error: This is not what 1>&2 does, because 1 refers to standard output, not standard input. To redirect standard input to standard error, we would need to use 0>&2, where 0 refers to standard input.
D. standard error to standard output: This is not what 1>&2 does, because it would require the opposite order of file descriptors: 2>&1. This would redirect standard error to standard output, not the other way around.
E. standard output to standard input: This is not possible, for the same reason as option A. References:
Bash redirections cheat sheet
How to redirect stderr to a file - Linuxize
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
Which character, added to the end of a command, runs that command in the background as a child process of the current shell?
!
+
&
%
#
The character that, added to the end of a command, runs that command in the background as a child process of the current shell is the ampersand symbol (&). This means that the command will not block the shell and the user can enter other commands while the background command is running. The background command will also not receive any input from the keyboard or the terminal. The shell will print the job number and the process ID of the background command, and the user can use the jobs command to list the status of all background jobs in the current shell session. To bring a background job to the foreground, the user can use the fg command with the job number or the process ID. To terminate a background job, the user can use the kill command with the process ID.
The other characters are not valid or relevant for running a command in the background. The exclamation mark (!) is used to access the command history or to negate a condition. The plus sign (+) is used for arithmetic operations or to append text. The percent sign (%) is used for arithmetic operations or to refer to a job number. The hash sign (#) is used for comments or to specify a hexadecimal number.
Which of the following files, located in the user home directory, is used to store the Bash history?
.bash_history
.bash_histfile
.history
.bashrc_history
.history_bash
The .bash_history file, located in the user home directory, is used to store the Bash history. The Bash history is a list of commands that the user has entered in the Bash shell. The .bash_history file is created when the user first starts a Bash session, and is updated when the user exits the session or runs the history command with the -a or -w option. The user can view the contents of the .bash_history file with the cat command, or use the history command to see the numbered list of commands. The user can also edit, delete, or clear the .bash_history file with various commands and options. The location and name of the history file can be changed by setting the HISTFILE environment variable to a different value. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.1: Work on the command line, Weight: 4, Key Knowledge Areas: Use of history and HISTFILE.
Where is bash’s history stored?, Topic: Bash maintains the list of commands internally in memory while it’s running.
QUESTIONNO: 26
Which Bash environment variable defines in which file the user history is stored when exiting a Bash process? (Specify ONLY the variable name.)
Answer: HISTFILE
The HISTFILE environment variable defines in which file the user history is stored when exiting a Bash process. The user history is a list of commands that the user has entered in the Bash shell. By default, the HISTFILE variable is set to ~/.bash_history, which means that the history is stored in a hidden file called .bash_history in the user’s home directory. The user can change the value of the HISTFILE variable to store the history in a different file or location. For example, the following command will set the HISTFILE variable to ~/my_history:
export HISTFILE=~/my_history
This will cause the history to be stored in a file called my_history in the user’s home directory. The user can also unset the HISTFILE variable to disable the history saving feature. For example, the following command will unset the HISTFILE variable:
unset HISTFILE
This will prevent the history from being written to any file when the Bash process exits. The user can view the value of the HISTFILE variable by using the echo command. For example, the following command will display the value of the HISTFILE variable:
echo $HISTFILE
The output will be something like:
/home/user/.bash_history
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:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of split and cat to split or join files.
[Split Command in Linux: 9 Useful Examples], Topic: Split Files
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:
LPIC-1 Exam 101 Objectives, Topic 103: GNU and Unix Commands, 103.4 Use streams, pipes and redirects
LPIC-1 Linux Administrator 101-500 Exam FAQ, LPIC-1 Exam 101 Objectives, GNU and Unix Commands (Total Weight: 25)
Which of the following commands kills the process with the PID 123 but allows the process to "clean up" before exiting?
kill -PIPE 123
kill -KILL 123
kill -STOP 123
kill -TERM 123
The command kill -TERM 123 kills the process with the PID 123 but allows the process to “clean up” before exiting. The option -TERM specifies the signal to be sent to the process, which is the termination signal (SIGTERM). This signal requests the process to terminate gracefully, which means that the process can perform any necessary actions before exiting, such as closing files, releasing resources, or saving data. The process can also catch the signal and ignore it or handle it in a different way, if it is programmed to do so. The syntax is: kill -TERM pid. For example, kill -TERM 123 will send the SIGTERM signal to the process with the PID 123, asking it to terminate nicely. The other options are not correct because:
A. kill -PIPE 123: This command sends the broken pipe signal (SIGPIPE) to the process, which is not used to kill the process, but to notify it that the other end of a pipe has been closed. This signal is usually ignored by the process, unless it is writing to the pipe, in which case it will cause the process to terminate1.
B. kill -KILL 123: This command sends the kill signal (SIGKILL) to the process, which is the most powerful way to kill the process, but it does not allow the process to “clean up” before exiting. The SIGKILL signal cannot be caught, blocked, or ignored by the process, and it forces the process to terminate immediately, without performing any actions. This command should be used as a last resort, when the process is unresponsive or causing harm to the system2.
C. kill -STOP 123: This command sends the stop signal (SIGSTOP) to the process, which is not used to kill the process, but to pause it. The SIGSTOP signal cannot be caught, blocked, or ignored by the process, and it suspends the execution of the process until it receives a continue signal (SIGCONT). This command can be used to temporarily stop a process from running, without terminating it3. References:
What is the purpose of the SIGPIPE signal? - Stack Overflow
How to kill a process in Linux - LinuxConfig.org
Linux Signals - GeeksforGeeks
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.
Which of the following characters can be combined with a separator string in order to read from the current input source until the separator string, which is on a separate line and without any trailing spaces, is reached?
<<
<|
!<
&<
The << character is used to create a here document, which is a special type of redirection that reads input from the current source until a line containing only the delimiter (with no trailing blanks) is seen. The delimiter is specified after the << operator, and can be any string. For example, the following command will print everything between the << EOF and EOF lines:
cat << EOF This is a here document It can span multiple lines EOF
The output is:
This is a here document It can span multiple lines
The < character is used for normal input redirection, which reads data from a file or another command. The <| and !< characters are not valid redirection operators in Linux. The &< character is used to duplicate input file descriptors, which is an advanced topic not covered by the Linux Essentials exam. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.4: Use streams, pipes and redirects, Weight: 4, Key Knowledge Areas: Redirecting standard input, standard output and standard error.
[LPI Linux Essentials Certification All-in-One Exam Guide], Chapter 5: Working with Files, Page 167, Using Here Documents.
QUESTIONNO: 16
Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?
A. file /tmp/myfile.txt
B. echo "Hello" >/tmp/myfile.txt
C. sed -ie "s/1/2/" /tmp/myfile.txt
D. echo -n "Hello" >>/tmp/myfile.txt
E. touch/tmp/myfile.txt
Answer: A
The file command will not update the modify timestamp on the file /tmp/myfile.txt because it only reads the file content and determines its type. It does not write or change anything in the file.
The other commands will update the modify timestamp on the file /tmp/myfile.txt because they either overwrite the file content (B and C), append to the file content (D), or explicitly change the file timestamp (E).
What does the? symbol within regular expressions represent?
Match the preceding qualifier one or more times.
Match the preceding qualifier zero or more times.
Match the preceding qualifier zero or one times.
Match a literal? character.
The ? symbol within regular expressions represents an optional match of the preceding qualifier. A qualifier is a character or a group of characters that can be repeated a certain number of times, such as , +, ?, {n}, {n,}, or {n,m}. The ? symbol means that the qualifier can occur zero or one times, but not more. For example, the regular expression colou?r matches both “color” and “colour”, but not “colouur” or “colr”. The ? symbol can also be used to make other qualifiers lazy, meaning that they will match the smallest possible number of characters, instead of the largest (greedy). For example, the regular expression a.?b matches the shortest string that starts with “a” and ends with “b”, such as “ab” or “a-b”, but not “a-b-c”. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of egrep to search for extended regular expressions in text output.
[Regular expression syntax cheat sheet], Topic: Quantifiers.
What is the effect of the egrep command when the -v option is used?
It enables color to highlight matching parts.
It only outputs non-matching lines.
It shows the command's version information.
It changes the output order showing the last matching line first.
The -v option for the egrep command activates the invert matching mode, which means that it only outputs the lines that do not match the given pattern or regular expression. This is useful for filtering out unwanted lines or finding exceptions in a file. For example, the following command will output all the lines in the file my_text that do not contain the word “Linux”:
egrep -v Linux my_text
The -v option can be combined with other options to modify the output format or behavior of the egrep command. For example, the -c option will count the number of non-matching lines instead of printing them, and the -i option will ignore the case of the pattern while matching. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.7: Perform basic file management, Weight: 4, Key Knowledge Areas: Use of egrep to search for extended regular expressions in text output.
[Linux egrep Command with Examples], Topic: Invert Matching with egrep.
Immediately after deleting 3 lines of text in vi and moving the cursor to a different line, which single character command will insert the deleted content below the current line?
i (lowercase)
P (uppercase)
p (lowercase)
U (uppercase)
u (lowercase)
The p command in vi inserts the content of the buffer below the current line. The buffer is where the deleted or yanked text is stored temporarily. The P command inserts the buffer above the current line. The i command enters the insert mode before the cursor position. The U command restores the current line to its original state. The u command undoes the last change made to the file. References:
[LPI Linux Essentials - 1.3 Basic Editing]
[LPI Linux Essentials - 1.4 I/O Redirection]
[LPI Linux Essentials - 1.5 Manage Simple Partitions and Filesystems]