Answers to the “Do I Know This Already?” Quizzes and Review Questions - CompTIA Linux+ / LPIC-1 Cert Guide (Exams LX0-103 & LX0-104/101-400 & 102-400) (2016)

CompTIA Linux+ / LPIC-1 Cert Guide (Exams LX0-103 & LX0-104/101-400 & 102-400) (2016)

Appendix A. Answers to the “Do I Know This Already?” Quizzes and Review Questions

Chapter 1

“Do I Know This Already?” Quiz

1. D. A is incorrect because IO ports are used to transfer data between the CPU and devices. B is incorrect because DMA allows a device to access memory directly. C is incorrect because IRQs are used by a device to ask for the CPU’s attention. D is correct because TCP/IP ports are used to talk to other hosts, not peripherals.

2. B. A is not correct because lspci gives an overview of just the PCI hardware. B is correct because lsdev aggregates many different files under /proc to give you a description of all your hardware. C is not correct because lsusb enumerates the USB bus and nothing else. D is not correct because sysinfo is not a valid command.

3. A. A is correct because sda3 includes both the device and an offset indicating the partition. B is not correct because a flash drive would not have a number. C is not correct because the filesystem goes on the partition. D is not correct because the disk does not have a number in it.

4. D. A is not correct because the PV is the disk itself. B is not correct because the VG pools all the PVs but still does not allocate disks to be used. C is not correct because PEs are just a unit of allocation. D is correct because the LV is comprised of multiple PEs allocated from the VG.

5. A. A is correct because /sbin holds binaries necessary to manage the system and boot it. B is not correct because /home is often placed on a separate partition to make it easier to share. C is not correct because /usr can be separated to keep system binaries separate, or to make it easier to grow. D is not correct because /tmp is often put on its own partition so that it can have different mount options, or to prevent temporary files from filling the root partition.

6. D. A is not correct because the BIOS is used to load the first stage of the boot manager. B is not correct because /boot contains the kernel and later stages. C is not correct because the partition table is just a table pointing at the locations of the various partitions. D is correct because the MBR is the first place the BIOS looks for a bootable block.

7. B. A is not correct because menu.lst is for the Legacy GRUB. B is correct because the new name of the file is grub.cfg. C is not correct because grub.conf is also for the old version of GRUB. D is not correct because that name is not used by any version of GRUB.

Review Questions

1. B. B is correct because direct memory access lets the peripheral talk directly to memory. A is incorrect because an interrupt request is a signal from the peripheral to the CPU that it needs attention. C is incorrect because the Transmission Control Protocol is a network concern. D is incorrect because it is not a hardware matter.

2. D. D is correct because lsdev shows information about system resources including devices, IO ports, and DMA channels.

3. C. C is correct because the IRQ is a signal to the processor. A is incorrect because IO ports are used by the CPU to talk to the device. B is not correct because pushing to memory does not involve the CPU. D is incorrect because devices don’t execute code out of main memory.

4. B. B is correct because /proc exposes files containing information about the system. A is incorrect because /dev contains device files used to talk to devices. C and D are incorrect because they are file storage locations.

5. D. D is correct because the udev subsystem monitors for device changes and makes the appropriate changes in /dev. A is incorrect because systemd is used for managing processes, though udevd can be a component of systemd. B is incorrect because init is used for managing processes. C is incorrect because procfs is used for exposing system information to the user.

6. B. B is correct because a hotplug device can be inserted or removed at any time. A is incorrect because the device still needs a driver. C is incorrect because the device can be removed without a reboot. D is incorrect because there are more hotplug devices than just hard drives.

7. C. C is correct because the memory of the system is not persistent. All the others are persistent block devices.

8. D. D is correct because /dev/sda2 refers to the second partition on the first hard drive. A is incorrect because sda would be the name of the hard drive. B is incorrect because sda refers to a physical disk, not a logical volume. C is not correct because network adapters are named differently.

9. B. B is correct because a partition contains a filesystem. A is incorrect because you need to partition a hard drive before applying a filesystem. C and D are incorrect because the PV is added to a volume group and then sliced up into logical volumes that contain filesystems.

10. A. A is correct because the file would be stored under /usr but not /usr/local.

11. B. B is correct because integration is not a core consideration—integrity is, however. The others are primary considerations when laying out hard drive partitions.

12. D. D is correct because the hard drives are added as PVs. A is incorrect because the LV is the target of a filesystem and is mounted. B is incorrect because the volume groups are a collection of physical volumes. C is incorrect because the PVs are carved up into PEs.

13. A. True. Hot resizing is possible because the makeup of the disk is all logical under LVM.

14. A. A is correct because the kernel’s virtual memory allows a memory page to be swapped to disk and swapped back later when it’s needed. B is incorrect because the memory was promised earlier and can’t be discarded. C is incorrect because the VM subsystem doesn’t compress memory. D is incorrect because if swap exists, it can be used to make the system appear as if it has more memory than it actually does.

15. C. C is correct because the MBR is the first block on the disk where the first stage of the bootloader and the partition tables are located. A and B are incorrect because GRUB is a bootloader that uses the MBR. D is incorrect because the index is a component of the filesystem and is not stored on the MBR.

16. D. D is correct because grub.cfg is the new name of the configuration file. A and B are incorrect because they are the name of the configuration for GRUB Legacy. C is incorrect because that file is not used.

Chapter 2

“Do I Know This Already?” Quiz

1. The correct answer is 2. Entering the character 2 at the boot prompt causes the majority of distributions to then subsequently enter Runlevel 2. The same would be true for the various other configured numerals and their corresponding runlevels.

2. B. In a GRUB configuration file, the disks are referred to by (hd#,#). The first disk is referred to by (hd0) and the fifth partition, the first logical, is referred to by (hd0,4) as GRUB starts counting from 0.

3. C. e is the command used by GRUB at the boot menu to edit the parameters for the entry you want to change.

4. B. The dmesg command is designed to show to standard output the kernel ring messages generated by the Linux Kernel.

5. B, C. If you do a ls –l on the shutdown, halt, poweroff, and init commands, you see that halt and poweroff are symlinks that point to the /sbin/reboot command, while shutdown is its own command and not a symlink. The “init 6” command string will simply cause the system to reboot, but it is NOT a symlink to the reboot command.

6. C, E. journald is one of the daemons that is a part of the systemd suite, and systemctl is a configuration utility that is also part of the systemd suite. The others are incorrect.

7. D. Killing more than one process by name is done via the killall command. halt is a command used to bring the system to a halted state, pskill doesn’t exist, kill just kills a single instance of foobar, likely the first one found in the process table, and pstree shows the treelike hierarchy of processes and alone does not kill a process.

Review Questions

1. A, D, E. Answers A, D, and E are correct because the numeral 1 puts the system into runlevel 1, a troubleshooting mode. The characters “s” and “S” also are used to put the system into a troubleshooting mode where few modules are loaded and mostly you are presented with a shell prompt. The other answers are incorrect because they don’t match the criteria or are nonexistent.

2. A, D. Answers A and D are correct because these are valid locations for the boot loader code to reside. The other answers are incorrect because they don’t match the criteria or are nonexistent.

3. B. Answer B is correct because group tags are used by systemd to refer to and allow the loading and removal of groups of processes. The other answers are incorrect because they don’t match the criteria or are nonexistent.

4. B. Answer B is correct because the –k option to shutdown is for simulating a system shutdown event, as well as sending a message to the attached users. The other answers are incorrect because –h halts the system, -r reboots the system, and –c cancels a shutdown that has already been issued, if there is sufficient time.

5. A, D, E. Answers A, D, and E are correct because they are all valid variations of the SIGHUP signal and will “hang up” or restart the service, rereading the configuration file. The other answers are incorrect because they don’t match the criteria and will either politely kill the service (9) or abruptly kill the service (15).

6. B, D, E. Answers B, D, and E are correct because they are all three capable of showing just the system’s boot messages from the last boot. The other answers are incorrect because they don’t match the criteria or are nonexistent.

Chapter 3

“Do I Know This Already?” Quiz

1. B. B is correct because the .so moniker indicates a shared library (or literally “shared object”). A is not correct because a static library would be bundled with the binary. C and D are not correct because the file is more likely to be a shared library.

2. A. A is correct because the name of the linker is ld.so, sometimes also called ld-linux.so. The configuration file is in /etc/ld.so.conf. The other answers either get the name wrong or the configuration file locations wrong.

3. C. C is correct because the dpkg tool is used to install local Debian packages. A and B are not correct because yum and rpm are for RPM-based systems. D is not correct because apt-get is for retrieving packages from remote repositories.

4. D. A is not correct because the --info option is used to examine a local Debian package. B is not correct because apt-cache is used to update the cache of remote packages. C is not correct because rpm is a tool for RPM-based systems. D is correct because the --list option searches the list of locally installed packages.

5. D. D is correct because the apt-get update command is used to update the list of remote repositories and their contents. A is not correct because dpkg does not deal with repositories. B and C are not correct because apt-cache is only used for searching the cache.

6. B. B is correct because the option tells dpkg to install dependency errors. A is incorrect because the default is to stop processing when a dependency error has been found. C is not correct because that overrides an error indicating a package is conflicting, rather than missing a dependency. D is incorrect because that overrides packages that need to be reinstalled.

7. D. D is correct because the architecture, such as x86_64, is not part of the package name. The long name contains the name of the package, version, and the distribution version. For example, kernel-3.17.7-300.fc21 is a long name.

8. A. A is correct because the -K option checks signatures. B is not correct because the query option (-k) does not accept a -k parameter. C is not correct because there is no --check-sig option to rpm. D is not correct because there is no rpm-sig command.

9. C. C is correct because the query (-q) checks the installed RPMs. A and B are not correct because there is no -V option to rpm query. D is not correct because the -p makes the operation work on a local file, not the rpm database.

Review Questions

1. B. B is correct because the combination of the -qp and --changelog options shows the changelog or revision history for a package that’s on disk. Answer A is incorrect because there is no such thing as a --revision option for the rpm command. Answer C is incorrect because there isn’t a -p option to query the package on disk, nor does -qc show the required information. Answer D is incorrect because the -qlp option shows the files in the package, not the revision history, and there isn’t a --showrev option to the rpm command.

2. B. B is correct because that is the name of the cache file generated by ldconfig.

3. C. C is correct because the ldd program, when used with a program name as the argument, shows the necessary libraries for the program’s functionality. Answer A is incorrect because ldconfig is used to rebuild links to library files, not ldd. Answer B is incorrect because creating a link to a library file is done by the ldconfig or ln command, not ldd. Answer D is incorrect because the ldd command does not read a program’s library capabilities; instead it reads its dependencies.

4. D. D is correct because the dynamic linker will use the LD_LIBRARY_PATH environment variable to load extra libraries if the variable is present. None of the other options refers to a variable that’s in use.

5. A, B, D. Answers A, B, and D are correct because they cannot be performed in any way except singly at any given time because the database is locked or because normal users cannot perform the action. Answer C is incorrect because multiple verification commands can be performed simultaneously because the operation is a read, not a read-write.

6. D. D is correct because the command is the only one that removes all instances of the package woohoo with a single command. Answer A is incorrect because asterisks do not invoke multiple removals and can be used only in installation situations for multiple packages on disk. Answer B is incorrect because the -ea option does not allow for multiple removals and works only in queries. Answer C is incorrect because there is no --remove option for the rpm command.

7. A. A is correct because the Freshen command only upgrades packages and won’t install new packages. B is incorrect because the upgrade command installs new packages. C is incorrect because that queries a package file and does not install it. D is incorrect because the Freshencommand does not use the -p option.

8. B. B is correct because the query and requires options together produce a list of what the package needs. A is incorrect because that queries the basic information about the package. C is incorrect because the --whatrequires option gives a list of which packages depend on the given package or capability, not the other way around. D is incorrect because it gives a list of all installed packages.

9. D. D is correct because the dpkg --list command lists installed packages. A is incorrect because that command searches remote repositories for the packages. B is incorrect because apt-get does not search local packages. C is not correct because the --info command reads a local package and gives information about it.

10. A. A is correct because the install command both installs and upgrades packages. B is incorrect because update resynchronizes the remote package list. C is incorrect because the upgrade command upgrades all packages on the system. D is incorrect because there is no --upgradeoption to dpkg, and that command only operates on local files.

Chapter 4

“Do I Know This Already?” Quiz

1. B. The bash shell takes the words/commands we type into it and interprets those to make the system take certain actions. The other phrases are not indicative of what is happening in the Bash shell.

2. D. None of the files listed are “executed” during the user’s login. They are instead “sourced,” which loads their settings and variables into the current version of the shell. The files are relatively meaningless to the question, as it is the method of executing versus sourcing that is being tested.

3. C. C is the correct answer because it properly uses the ~ character, which represents the path of the currently logged-in user, followed by the /test and /.h directories. The others are incorrect syntax or distractors.

4. B. B is correct because when you place double pipe characters between two commands, the shell monitors the exit status for the first command, and if it exits with an error, only then is the second command executed. Double asterisks (a) means any character or none followed by any character or none, the double ampersands (c) means to execute the subsequent command if the first is successful and the not equal (!=) means that the two items on either side of it are not equal to each other.

5. A. Typing the env command is the simplest and most complete way to see all variables in your current environment.

6. C, E. When setting options, you use the set –o option command; when unsetting the option, you either use unset option or set +o option.

Review Questions

1. D. Answer D is correct because the C shell is the only one listed that doesn’t offer inline command line editing.

2. E. Answer E is correct because none of the others correctly completes the statement. Sourcing is where instead of instantiating a new lower-level shell, the commands and variables in the script are loaded into the current shell’s environment.

3. C. Answer C is correct because you are using Tab completion to complete the missing characters of the command. The rest are simple characters that do their appropriate actions, but not the one asked for.

4. B. Answer B is correct because echoing $? displays the exit code for the previously executed program.

5. A, C, D. Answers A, C, and D are correct because they are the recognized ways to be transported back to your home directory.

6. B. Answer B is correct because the history command when piped through the tail command shows only the last 10 lines of your command history.

Chapter 5

“Do I Know This Already?” Quiz

1. D. D is correct because the /var directory is reserved for data that changes. A is not correct because /usr is for sharable, read-only, data. B is not correct because /proc exposes kernel variables and status through the procfs pseudofilesystem. C is not correct because /root is for the root user’s home directory.

2. B. B is correct because the path given first descends one directory to /usr, then moves into bin. A is incorrect because the shell would have to descend two levels, not one. C is incorrect because /usr/local/bin is a subdirectory of the current working directory. D is incorrect because the command is valid.

3. D. D is correct because items in /sbin are needed to boot the system, and therefore must be on the root partition. All the remaining options can be on their own filesystem because they are not essential to booting.

4. A. A is correct because the file command uses several heuristics to find out what a file is. B is not correct because that executes the file, which may not work in the case of text or data files and could be dangerous if you don’t know what it does. C is incorrect because displaying the contents of the file on your screen does not work for binary files and is cumbersome for large text files. D is not correct because which looks for the file in your search path.You happen across a file in a directory called foo. What is a good way to find out what the file is or does?

5. D. D is correct because the touch command updates dates on files. A is not correct because tar is for archiving files. B is not correct because file is for determining what a file is. C is not correct because that queries and sets the system date.

6. C. C is correct because the -p option is needed to create the nested structure; otherwise, you get an error because the parent directories don’t exist. A is not correct because it takes far more typing than doing it with the correct option. B is incorrect because the command will not create the parent directories. D is not correct because md is not a Unix command for making directories.

7. D. D is correct because which looks at your shell aliases and search path to find which command will be run when you type a particular command. A is not correct because whereis returns multiple matches and doesn’t tell you which of multiple options will be run. B is not correct because it finds anything with doit in the name. C is not correct because find searches for any file and the command is not a correct use of find.

8. A. A is correct because that searches your entire filesystem for a file named backup.tar.gz. B is not correct because the find command needs a search predicate such as -name. C is not correct because locate does not include anything from the current day—the database must be updated on a nightly basis. D is not correct because whereis does not search the filesystem extensively.

9. C. C is correct because it creates a bzip2 compressed archive in the correct location, using files from /home/fred. A is not correct because tar does not accept a list of files as input, and with the -f parameter, it expects a filename. B is not correct because tar does not write to standard out if a filename is present, and the /home/fred passed will be interpreted as the output filename, not the files to archive. D is not correct because the command is run out of Fred’s home directory and will result in all the files being part of the root when extracted. This is less optimal than the previous option.

10. C. C is correct because the -t option lists what’s in the archive, and passing a filename only returns matches. A is not correct because the -c option creates an archive. B is not correct because -r adds to an archive. D is not correct because extraction is done with -x.

11. A. A is correct because bzip2 provides the best compression of them all. gzip generally beats compress, and cpio doesn’t offer compression.

Review Questions

1. A, D. Answers A and D are correct because the FHS states that the /root and /home partitions are optional. Answers B and C are incorrect because the FHS doesn’t list them as optional for the root filesystem.

2. B. Answer B is correct because the FHS states that sharable programs should be in /usr/local/appname. Answer A is incorrect because the /usr/local/bin directory is for single binaries and is often just a link to some application in /usr/local/appname/bin. Answer C is incorrect because the /usr/share directory contains files for multiple architectures and the question does not state that multiple architectures are involved. Answer D is incorrect because the /opt directory is for locally installed programs only and is not to be shared out for multiple system usage.

3. A, B, C, D, E. All of these answers are correct. A filename can contain virtually any character, though in the case of spaces, ampersands, and backslashes, care must be taken to escape the character lest it be interpreted as a command to the shell.

4. C. Answer C is correct because the use of a ~ character in front of a string parses the /etc/passwd file for a username of that string. So in this case /home/tarfoo. Answer A is incorrect because functions begin with a left parentheses mark and contain commands. Answer B is incorrect because, for that string to denote a directory named tarfoo in your home directory, it would need to be ~/tarfoo. Answer D is incorrect because the /data directory is not mentioned in the command, nor is it implied by the ~ character.

5. D. Answer D is correct because the series of .. and forward slashes that precede the /home12/user3 string correctly navigate to that directory. Answer A is incorrect because the path is not absolute; it’s relative and would work only from the root of the system. Answer B is incorrect because the ~/user3 string denotes a subdirectory of the current user’s home directory named user3 and would have to be changed to ~user3 to work. Answer C is incorrect because the string does not go back to the root of the system; it only goes back up to the /home1 directory.

6. B. Answer B is correct because, to copy the contents of a directory, the source must end with a /*; otherwise, the directory itself is copied as a subdirectory of the target. Answer A is incorrect because there isn’t a --contents option to the cp command. Answer C is incorrect because thexcopy command is offered only on DOS and Windows machines. Answer D is incorrect because the source directory doesn’t include a /* suffix and therefore copies the source into the target as a subdirectory.

7. C. Answer C is correct because this command moves the contents from the source to the target and is the shortest command. Answer A is incorrect because this command doesn’t work for copying the contents—*.* is incorrect syntax for the command. Answer B is incorrect because the same condition exists—the string *.* doesn’t match all files or directories. Answer D is incorrect because it moves the /ccc directory to be a subdirectory of the /bbb subdirectory.

8. D. Answer D is correct because the -p option allows mkdir and rmdir to create and remove parent directories. Answers A, B, and C are incorrect: These options are not available to the mkdir and rmdir commands.

9. A. A is correct because it uses the correct combination of starting directory (/home) search predicates (modify time is greater than 7 days, name is core) and action (execute the rm -f command on the name of the file). B is not correct because the starting directory is the current user’s home directory. C is not correct because the mtime search predicate is -7, indicating “less than 7 days old”. D is not correct because there is no -older search predicate.

10. A. A is correct because the link points to the inode of the file, and that wouldn’t work if the file were on a filesystem. D is correct because this is a limitation imposed in Linux to avoid cycles in the directory structure that would break the tree model. The rest of the options are incorrect because the name and type of the file do not matter for the hard link.

11. C. C is correct because the tar command uses the create option with bzip2 compression, and the correct ordering of output filename and files to archive. A is incorrect because it uses gzip compression, which creates larger archives than does bzip2. B is incorrect because it uses a cpiostyle of archiving—tar does not accept the list of files over stdin. D is incorrect because it uses the extract option instead of the create option.

Chapter 6

“Do I Know This Already?” Quiz

1. B. The file descriptors are 0 = stdin, 1 = stdout, 2 = stderr, and 3 is not an existing file descriptor.

2. C. The output of the find command is sent to the file command, which sends its output to be redirected into a file named “sort” in the current directory.

3. C. The characters chosen are based on the exit code for the first command. Only the double ||’s will cause the second command to run based on the failure of the first command.

4. C. Answer C is correct, as the tee command allows you to simultaneously log a stream of output to a file and send the identical stream on to be further processed. The other commands do not accomplish the described task.

5. B. The tabs in files combined with the length of the data in each column often display oddly when the file is output to the console. The proper command to temporarily remove tabs and replace them with the appropriate number of spaces is the expand command. The other commands are either not correct or don’t exist.

6. E. All the answers are functional commands, but most are simple editors or—in edlin’s case a DOS command—and don’t work on Linux. The tr command could possibly be used to replace the words specified, but it would take a great deal of work to use it, as tr replaces single characters with other characters. Only the sed command is designed to easily replace whole words as words.

7. A. The grep command is well known for being able to show the exact opposite of the current output by the use of the –v option. All the other commands are functional commands, but either don’t have that option or the option is not for reversing output.

Review Questions

1. A, E. Answers A and E are correct because you can use the specific stdout and stderr number descriptors to redirect output or you can use the 2>&1 option to send the stderr to wherever stdout is directed.

2. B. Answer B is correct because double redirect symbols catenate the output of the command into the described file properly. The > redirect overwrites the file each time, and the other operators are either input redirects or invalid.

3. C. Answer C is correct, as the tee command allows you to simultaneously log a stream of output to a file and send the identical stream on to be further processed. The other commands do not accomplish the described task.

4. A. The –n option performs a nonmachine or human-friendly sort, effectively padding any numbers such as 1 with a leading 0. If the numbers go to multiple positions, such as 1 to 100, then additional leading 0s are added so that all the numbers are sorted in the human-friendly format. These 0s are not input into the file nor displayed, just used in the sort of the file’s data.

5. C. Answer C is correct because it is the only answer whose command shows a count of lines, words, and characters for a given file.

Chapter 7

“Do I Know This Already?” Quiz

1. C, D. C and D both have the capability of listing out the running processes on a system in a hierarchical or treelike format. A is a nonsense command to distract you, B, lsproc shows you a listing of the /proc directory, while E, gvfs-tree is for listing files in a directory structure.

2. B. The keystrokes Ctrl-z send a SIGTSTP or 20 signal to the process, pausing or freezing its execution. The logical next step is to use the bg command and put that process back to executing in the background. The other Ctrl-? combinations all send signals, but don’t perform the function specified.

3. D. The fg command acts on the last used or last suspended, notated by the + sign after the [2]. The other jobs must be interacted with by their job #.

4. B, D. Answers B and D are correct.The r keystroke within top allows you to enter a numeric value that changes the priority of the specified process, and the renice command alters the priority of a running process, which the unruly process is, which leaves out the nice command, used for starting processes at an altered priority. The other answers have invalid options.

5. A, C. The nohup command and the screen command both allow you to execute something and log out. They both essentially detach the process from the controlling terminal and set it free. The other commands don’t do what is being asked.

Review Questions

1. E. Answer E is correct because top is the only command listed that does what is being asked about.

2. C. Answer C is correct because the original signal must have been 15, and the signal guaranteed to terminate the process is the 9 signal.

3. A. The pkill command allows you to specify a concise set of requirements for killing a process or set of processes. The pgrep command can be used to find those processes, but pkill is used to kill them.

4. False. The jobs command can run and work properly inside any bash shell instance.

5. B. Answer B is correct because it’s the only possible answer that causes the screen command to show you a listing of the available sessions. All the others are variations on the Ctrl-a theme, but either are false or don’t work as described.

Chapter 8

“Do I Know This Already?” Quiz

1. C. A is incorrect because you edit the text at the end of the line with A. B is incorrect because that would be I as opposed to i. C is correct because the i command begins editing at the current place. D is incorrect because the ~ command inverts the case of the character.

2. A. A is correct because k and j represent up and down motions. B is incorrect because the keys are inverted from their described functions. C is incorrect because Ctrl+d and Ctrl+u move down and up in terms of half pages, not lines like the arrows. D is incorrect because h moves to the left and j moves down.

3. D. A and B are incorrect because the i and I commands insert on the current line. Similarly, the A command appends on the current line, so C is incorrect. D is correct: The O command opens a new line before the current cursor position.

4. A. A is correct because the D command deletes and it is applied to the end of the line with the $. B is incorrect because a single D by itself deletes from the character position to the end of the line, but the second D deletes more characters. YP is incorrect because it duplicates the current line (Yank, Put). D is incorrect because cW changes the current word.

5. D. A is incorrect because the capital A appends the yanked text into the named buffer rather than replacing it. B and C are incorrect because they do the same operation 10 times on the same buffer rather than bringing 10 lines into the buffer. D is correct because it first indicates the operation is on a named buffer and then yanks 10 lines.

6. B. A is incorrect because the / searches forward, not backward. B is correct because the command searches backward, anchors the search with the ^, and also escapes the splat operator correctly. C is incorrect because it searches forward and doesn’t anchor the search to the beginning of the line. D is incorrect because the search isn’t anchored nor is the * escaped.

7. A. A is correct because a set command ending in a question mark queries the setting. The remaining answers are incorrect because the command queries and doesn’t set.

8. C. A and b are incorrect because the j command joins lines rather than moving the cursor. C is correct because you are running the join command 10 times. D is incorrect because that would involve the Ctrl+F command.

9. D. A is incorrect because rsplit is not a vim command. B is incorrect because you can do this within vim. C is incorrect because :split opens a window above, not to the right. Only D, the :vsplit, works here.

Review Questions

1. C. Answer C is correct because vim is in nearly every distribution of Linux that exists. Answer A is incorrect because, even though emacs is very well known, it’s considered an add-on to Linux. Answer B is incorrect because joe is a specialized editor and not normally included in a distribution by default. Answer D is incorrect because nano is used only for document-style text editing and is not the default editor.

2. A, C, E. Answers A, C, and E are correct because they save and exit a given file in vi. Answer B is incorrect because it forces a nonsaving exit to a modified buffer or file. Answer D is incorrect because only a shifted pair of z characters saves and exits a file properly.

3. B. Answer B is correct because it takes the cursor to the end of the file. Answer A is incorrect because Ctrl+PgDn does nothing in vi. Answer C is incorrect because it moves to the end of the current line. Answer D is incorrect because it does nothing in vi.

4. A. A is correct because the + command line option passes a command that vim will run; in this case it sets the number mode to on. B and C are not correct because there are no long options to set the line numbers. D is incorrect because –o is used to open split windows.

5. D. Answer D is correct because the J key denotes the down arrow and the L character denotes the right arrow. Answers A, B, and C are incorrect because they don’t use the correct keystrokes.

6. B. Answer B is correct because it enters LastLine mode and reloads the file, discarding changes. A is not correct because that exits the file with no changes. C is not correct because that only goes back one level in the undo history. D is not correct because you need to enter LastLine mode and e! is not a valid command within Command mode.

7. C. Answer C is correct because it searches for and highlights the string string1 properly. Answer A is incorrect because it has added quotation marks around the search string. Answer B is incorrect because it’s missing the necessary plus symbol. Answer D is incorrect because there is no --find option for vi.

8. D. Answer D is correct because it starts a subshell and displays the normal files in the current directory. Answer A is incorrect because it exits the file and ignores the ls command. Answer B is incorrect because it attempts to edit all the files returned by the ls command and errors out. Answer C is incorrect because it just starts displaying the text on the screen in vi.

9. B. Answer B is correct because vim looks for user-specific configuration files in a file called .vimrc, located within the user’s home directory. Answer A is not correct because the file in /etc applies to all users, and they may not appreciate your customizations. Answer C is incorrect because the file named is a fake. Answer D is incorrect because no such file as /etc/editorrc exists.

10. A. Answer A is correct because it specifies that the whole document will be searched (%s), that snark will be replaced by FARKLE (/snark/FARKLE/), and that all matches are to be considered (g). B is not correct because it is missing the g. C and D are incorrect because they are missing the % and g, and so only operate on the first match in the current line. Additionally, D has the search and replace clauses swapped.

Chapter 9

“Do I Know This Already?” Quiz

1. B, D. B is correct because gdisk is a command line utility that works on GUID partition tables. D is correct because parted works on all kinds of partition tables. A is not correct because fdisk only works on MBR tables. C is incorrect because it does not exist.

2. D. D is correct because code 83 is for Linux partitions—a filesystem will be directly placed on this partition. A is not correct because LVM is type 8e. B is not correct because swap is type 82. C is not correct because RAID is fd.

3. B. B is correct because GPTs allow up to 128 partitions. A is not correct because MBRs allow 4 primary partitions. C and D are not correct because they are not partition tables.

4. A. A is correct because the name is stored in the directory entry, not the inode. All the remaining options are attributes of the inode.

5. D. D is correct because the ratio is otherwise known as the bytes per inode ratio; therefore, one inode will be created for every 4096 bytes of disk space.

6. A. A is correct because fsck is the filesystem checker, and it will clean the dirty filesystem. B is not correct because df is used to determine how much free space each filesystem has. C is not correct because du calculates disk usage of a set of files or directories. D is not correct because that creates a filesystem.

7. B. B is correct because du shows the disk usage for a particular directory. A is not correct because repquota shows quota usage across all files on the partition and the command requires you give it a partition or –a for all partitions. C is not correct because df operates on filesystems not directories. D is not correct because the find command shows you individual files.

8. D. D is correct because the hard limit is the absolute maximum disk space that can be used. A is not correct because repquota is a command to display the quota information. B is not correct because the soft limit can be exceeded. C is not correct because the grace period is the length of time that a soft limit can be exceeded.

Review Questions

1. D. Answer D is correct because the fourth column is the options column and the user option is the proper one to use. Answers A and B include valid options but are in the wrong column. Answer C is the wrong option in the right column.

2. A. Answer A is correct because the filesystem should be unmounted if possible, mounted read-only if not. Answer B is incorrect because mounting it read-write would cause errors in the fsck process. Answer C is incorrect because there isn’t a noauto mode, although there is a noautooption. Answer D is incorrect because the user being set to something in options doesn’t affect the fsck process.

3. B, C. Answers B and C are correct because the highest traffic partitions in the choices are /home (users data) and /var (log files, print spools, Web, and FTP). Answer A is incorrect because on a user file server /tmp isn’t as heavily used as it would be on a developer station. Answer D is incorrect because anything at all could be in a directory tree named /data, whereas the /home directory tree is almost certainly user data.

4. C. Answer C is correct because the maximum mount count option can be set with the tune2fs command. Answer A is incorrect because the debugfs command manipulates the filesystem inodes and contents but not the needed parameter. Answer B is incorrect because the dumpe2fscommand shows only parameters for the filesystem. Answer D is incorrect because the setfs command doesn’t exist.

5. B. Answer B is correct because the df command shows the disk statistics for mounted filesystems. Answer A is incorrect because dir is only an alias for the ls command. Answer C is incorrect because the du command can show the space used by files but not disk statistics like df can. Answer D is incorrect because the ls command can show file sizes but not disk statistics.

6. C. Answer C is correct because the filename is not stored with the inode or in the data location for the file; it occurs only in the directory file that contains the filename entry. Answer A is incorrect because the link count affects only hard links and is shown by the stat command. Answer B is incorrect because link permissions affect only a symbolic link, and the symbolic link permissions are kept in the link’s inode. Answer D is incorrect because the ownership information is kept in the inode for the file.

7. D. Answer D is correct because the tune2fs -c 0 command changes a filesystem’s maximum mount count to not have it checked automatically. Answer A is incorrect because the fsck command can’t change the maximum mount count. Answer B is incorrect because the mkfs.* tools are for creating filesystems, and even though they can set the maximum mount count at filesystem creation, using these tools on existing filesystems would destroy the filesystem. Answer C is incorrect because, although hdparm is good for changing parameters, the tune2fs command is the best choice for this task.

8. A. Answer A is correct because the ext3 filesystem type does not require any reformatting to upgrade an ext2 filesystem. Answers B, C, and D are incorrect because they require backing up the filesystem data, formatting with the new advanced filesystem, and restoring the data.

9. C. Answer C is correct because the df command has an option to query the number and percentage of inodes used and free for all mounted filesystems. Answer A is incorrect because the ls -li command shows only groups of file object inode information, not totals. Answer B is incorrect because the du -sh command doesn’t show inode percentages, just object sizes and size totals. Answer D is incorrect because find -inum searches for a specific inode but does not show totals or percentages.

10. D. Answer D is correct because quotas are configurable only on a per-file-system basis. In this case, one or both must be off the root (/) filesystem to have a different quota assigned. Answer A is incorrect because the ext3 filesystem and others support user quotas. Answer B is incorrect because the sparse_super option is used only for creating fewer superblock backups for a filesystem. Answer C is incorrect because these are directories, not filesystems, and the usrquota option is entered in the /etc/fstab entry for a filesystem, not a directory tree.

11. A, C. A is correct because the files existing prior to the quotas being implemented would not retroactively delete any files. C is correct because quotaon is the trigger to start enforcing quotas. B is not correct because without the filesystem options, the quota system would not be tracking usage. D is not correct because the grace period applies to the soft limit, not the hard quota.

Chapter 10

“Do I Know This Already?” Quiz

1. D. A is not correct as the chmod command changes permission on an existing object. Answer B is not correct as the chgrp command changes group ownership of an existing object. Answer C is not correct as the chown command changes user and/or group ownership of an existing object.

2. A. A is correct because the user fred is the owner of the file and the owner’s permissions are rwx, which stands for read, write, and execute.

3. C. C is correct because the letter “a” in a+x stands for “all,” the “+” character adds the permission, and the “x” stands for the execute permission.

4. B. B is correct because the chmod command is used to set permissions. The letter “o” in o+t stands for “others,” which is where the sticky bit permission is applied in the permission set. The “+” character adds the permission, and the “t” stands for the sticky bit permission.

5. A. A is correct because the –perm option is used to search for files by permission.

6. B, C. The chown command can change both user owner and group owner. The user owner is listed first, followed by a “:” character and then the group owner.

7. D. A user can change the group ownership of a file owned by that user to any group the user is a member of.

Review Questions

1. D. Answer A is incorrect because this is the access provided by the read permission. Answers B and C are incorrect because these are the access provided by the write permission.

2. B. The user fred is the owner of the file, so only the owner permission set (rw-) applies. The “r” stands for read and the “w” stands for write.

3. C. Answer C is correct because it sets all the permissions equal to 644. The other answers only change some permissions, so it is possible that the execute permission could be still set for user owner, group owner, or others, and the write permissions could still be set for group owner and others.

4. A, D. Answers A and D are correct. The SUID permission can be set symbolically by using u+s or numerically by using 4XXX (with XXX being regular permissions). Answers B and C set the SGID permission, not the SUID permission.

5. B, C. Answers B and C are correct. The umask 077 command “masks out” all permissions for group and others. The maximum permissions of directories is normally rwxrwxrwx, so the resulting new permissions would be rwx------. The maximum permissions of directories is normally rw-rw-rw-, so the resulting new permissions would be rw-------.

Chapter 11

“Do I Know This Already?” Quiz

1. B, C. B is correct because it assigns the value using the equals sign and also marks it for export. C is also correct for the same reason except that it’s not exported. A is not correct because set is used for shell options. D is not correct because it is missing an equals sign.

2. B. B is correct because it executes the script in the current shell rather than opening a new shell. AGE was not exported; therefore it doesn’t exist in the subshell. A is not correct because the capitalization is consistent between the script and the environment variable. C is not correct because the permissions of the script don’t have a bearing on the environment. D is not correct because set is used for shell options.

3. A. A is correct because the ~/.bashrc file is sourced in non-login sessions and indirectly from login sessions. The other scripts are only called in login sessions.

4. A, C. A is correct because both aliases and functions can perform larger commands with a shorter command. C is correct because only a function can span multiple lines. B is not correct because only a function can accept parameters. D is not correct because functions can be used without being exported.

5. B. B is correct because the date command looks for the TZ environment variable. A is not correct because that would change the time zone for the entire system. C is not correct because LC_TIME is used for formatting and expects the name of a locale rather than a time zone. D is not correct because date doesn’t have a timezone long option.

6. D. D is correct because it uses iconv to go from UTF-16 to ASCII. A is not correct because it’s possible to convert a file to plain ASCII. B is not correct because the locale setting won’t change how the file is displayed on the screen. C is not correct because it doesn’t have options to automatically convert UTF-16.

Review Questions

1. C. Answer C is correct because bash is the default Linux shell. Answer A is incorrect because there isn’t a vsh command. Answer B is incorrect because ksh is the default. Answer D is incorrect because sh is the Bourne shell, ostensibly the first, but not the default.

2. B. Answer B is correct because it’s sourced from the user’s ~/.bash_profile file. Answer A is incorrect because it’s the system’s profile file. Answer C is incorrect because it’s the system’s bash configuration file and is sourced from the ~/.bashrc file if needed. Answer D is incorrect because it’s the last file that gets run as the user exits the system. Answer E is incorrect because it’s the configuration file for the vi editor.

3. B. Answer B is correct because running export VARNAME makes that variable available for all subshells. Answer A is incorrect because it is used to set bash shell options, not to export variables. Answer C is incorrect because it is the bash shell executable. Answer D is incorrect because the source command is used to reexecute configuration scripts, not export variables.

4. B, D. Answers B and D are correct because commands not in the path can be specified either via the full path or by prefixing them with ./. Answer A is incorrect because it attempts to execute a file in the /home directory named .tarfoo. Answer C is incorrect because that string would attempt to execute the home directory for the user tarfoo.

5. B. Answer B is correct because the noclobber option allows the user to only append to files, not overwrite their contents. Answer A is incorrect because it doesn’t exist as an option in bash. Answer C is incorrect because the hashall option builds a table of recently used commands. Answer D is incorrect because the monitor option has to do with job control and notification of process statuses.

6. C. C is correct because it sets a shell alias to replace ls with ls -a. A and B are not correct because the LS_OPTS environment variable is not checked by the ls command. D is not correct because it omits the ls and would replace the ls command with -a.

7. B. B is correct because the /etc/localtime file should either be a copy of, or point to, the time zone file under /usr/share/zoneinfo. A is not correct because changing the TZ environment variable won’t make everything on your system change over. C is not correct because the time zone file is specific to Debian and contains the name of the time zone itself. D is not correct because /etc/profile is a shell script that is executed.

8. A. A is correct because /etc/profile is sourced on login by all bash shells. B is not correct because you would have to put that in each user’s .bashrc. C is not correct because /etc/path is not sourced on login. D is not correct because /usr/local/bin may be in everyone’s PATH already but will not execute files on login.

9. D. D is correct because LC_ALL takes priority over the other variables. A is not correct because the LANG variable has the lowest priority. B is not correct because LC_TIME is overridden by LC_ALL. C is not correct because LC_MESSAGES is not used for date formatting.

Chapter 12

“Do I Know This Already?” Quiz

1. C. C is correct because comments start with the hash symbol. The other answers are incorrect.

2. A, B. A is correct because the shebang line indicates how the script is to be run; in this case it is with /usr/bin/perl. B is correct because the script needs to be executable. C is not correct because that would let the script run as root, and that is unnecessary here. D is not correct because the shebang line needs a fully qualified path to the interpreter. E is not correct because the script being in /usr/bin won’t let you run the script with ./ because that means the current directory and the script still need the executable bit and the shebang line.

3. C. C is correct because the script will source /etc/zoid if it has the executable bit set. A is incorrect because elif is a shell built-in. B is incorrect because only one of the two files can be executed because the second is in an “else if” block. D is incorrect because the priority is the opposite.

4. D. D is correct because a result code ($?) of a nonzero number indicates an error condition. A is not correct because $? would have been 0. B is not correct because there’s no way to tell what was passed in the environment from the output. C is not correct because timing information was not included.

5. A. A is correct because the $1, $2, and so forth variables contain the arguments passed to the script. B is not correct because that is usually stored in $SHELL. C is not correct because the name of the script is in $0. D is not correct because the PID of the script is in $$.

6. B. B is correct because the shell expects an esac to close out the case and will get to the end of file and throw an error if it’s missing. A is not correct because you won’t get an error if you don’t match any conditions. C is not correct because the test style doesn’t matter to a case statement. D is not correct because you will get a message indicating the shell was expecting an integer.

7. D. D is correct because it correctly uses a file glob in the for clause and moves the file to the same name plus a .bak. A is not correct because the mv command won’t expand the names as expected and returns an error. B and C aren’t correct because the ls will be treated as a string, not a command substitution. Additionally, C refers to the variable by name and not value ($i).

Review Questions

1. A, C. Answers A, and C are correct because the features mentioned as being in the script are all related to the bash shell. Either you use answer C to specifically set it or you allow the default of bash to be used by not specifying a shell. Answer B is incorrect because the syntax is incorrect for the string and the csh shell won’t do what the question requires. Answer D is incorrect because the line is incorrect and means nothing in a shell script.

2. C. C is correct because it properly substitutes the command for the arguments to the kill command. A is not correct because double quoting the command won’t make it execute. B is similar to A but with an intermediate variable; therefore, it won’t work. D is not correct because the$(()) is for arithmetic evaluation, not command substitution.

3. A. A is correct because it uses the $(()) syntax to evaluate an arithmetic expression. B is not correct because it will try to run the numbers as a command, which doesn’t exist. C is not correct because it will try to run the numbers as a command and capture the output, which is no more helpful than B. D is not correct because eval is for running programs. There is an older style of arithmetic evaluation that uses expr, however.

4. B. B is correct because it checks the value of $?, which stores the exit code of the last program ran, for the value of 1 or greater, which means an error. A is incorrect because it checks for the existence of the program that was just run. C is not correct because it checks for success of the last program. D is not correct because the until command loops while the condition is false.

5. C. C is correct because the -x and -f mean “is executable” and “exists,” respectively, and the -a requires both with a logical AND. A is incorrect because there is no option to look inside a file. B is not correct for the same reasons. D is not correct because the -x means that the file is executable; that it exists is not sufficient. Also the -a means an AND clause.

6. D. D is correct because the script is performing a string equality check on the output of the hostname command against the string bob. A is not correct because an integer comparison is done with -eq. B is not correct because the equality operator means the result is of the check for equality, not the command substitution. C is not correct because the equals sign separates the hostname from the string, so nothing is passed to the hostname command.

7. C. C is correct because the collection is known and a for loop can easily iterate over every process. A is not correct because seq is for counting. B is not correct because the size of the collection is known and using a while loop would be more confusing. C is not correct because untilloops until a condition is true.

8. D. D is correct because it uses the -eq integer equality operator to compare 3 to $#, which holds the number of arguments. A is not correct because it checks for three or more through the greater than or equal to operator. B is not correct because ARGV does not contain the number of arguments. C is not correct because $? holds the exit code of the last program to run.

9. B. B is correct because it uses the exit keyword with a value of 1, which indicates an error. A is not correct because die comes from Perl. C is not correct because raise is not used in bash. D is not correct because it will exit with a code of 0, which indicates successful completion.

10. C. C is correct because after the shift, $1 becomes “b” and $0 contains the name of the script. A is not correct because $0 is the name of the program and the arguments are counted starting at $1. B is not correct because the $0 is not shifted. D is not correct because the “b” will have been shifted to the first argument position.

Chapter 13

“Do I Know This Already?” Quiz

1. B. B is correct because variable elements are a property of schemaless databases, not relational databases. A is incorrect because a table is a series of columns corresponding to data elements, with each record forming its own row. C is incorrect because SQL is the typical language used to query a relational database. D is not correct because each row has a primary key that identifies it.

2. D. D is correct because indexes provide fast lookups to large sections of data. A is not correct because a binary object is some data, such as a picture, that is not text in nature. B is not correct because client-server is a method used to communicate with a database but does not contribute to looking up data quickly. C is not correct because embedding a database reduces the footprint of the application but does not contribute to speed the same way an index would.

3. A. A is correct because table names are case sensitive; that is, table is different from Table. B is not correct because SQL keywords can be written in any case. C is not correct because AND and OR are also SQL keywords and are therefore case insensitive. D is not correct because the server name is not part of SQL.

4. C. C is correct because it has the proper ordering of clauses: SELECT, FROM, and WHERE. It also uses the correct case for the table. A is not correct because the table name is capitalized in the answer, but the table given in the question is all lowercase. B is not correct because it is missing the FROM clause and does not end with a semicolon. D is not correct because the FROM and WHERE clauses are reversed.

5. D. D is correct because it takes all the cars and left joins the owners. A is not correct because it returns all the owners even if they don’t have cars, not the other way around. B is not correct because that is doing an inner join, showing only cars that have an owner. C is not correct because it is also doing an inner join.

6. C. C is correct because the subselect includes a single column of models, and the query uses the IN clause. A is not correct because it does not use a subselect; it uses a join. B is not correct because the subselect includes all the columns and cannot be executed by the database. D is not correct because the WHERE clause is outside the subselect; cars does not have a recall_date.

7. A. A is correct because it uses a single sort with two columns, where office location is before last name. B is not correct because grouping by office location will return one row per office. C is not correct because the sort columns are reversed. D is not correct because of similar reasons to B.

8. B. B is correct because it uses the UPDATE command and contains the required elements—a table name and instructions for the SET clause. A is not correct because the problem requires data be updated, not inserted. C is not correct because the word that follows the UPDATE keyword should be a table name. D is not correct because the column to be updated needs to be specified with the SET keyword.

Review Questions

1. C. C is correct because relational databases store entities in tables, which are comprised of rows and columns. A is not correct because flat files have no structure. B is not correct because key-value databases have a key and a value rather than a table. D is not correct because schemaless databases store documents and don’t have a set of formal rows and columns.

2. A. A is correct because the semicolon is the statement delimiter. New lines, blank or not, are ignored. Periods are not special in SQL.

3. D. D is correct because it selects people who have between 5 and 20 years of service, inclusive. A is not correct because the conditionals miss people who have been working for 5 or 20 years. B is not correct because the syntax of the BETWEEN keyword requires an AND, not a comma. C is incorrect because the ranges are inclusive, and this includes people with 21 years experience.

4. B. B is correct because it performs an inner join so that the managers without employees are excluded. A is not correct because that returns a cross join with all managers and employee combinations. C is not correct because a left join includes managers without employees. D is not correct because the join syntax is invalid.

5. A, C. A is correct because the left join of products onto sales ensures all products will be included. C is correct because the join matches the product name to the product_name column in sales. B is not correct because the sales need to match up to the product. D is not correct because there is no aggregate clause like SUM or a GROUP BY clause.

6. D. D is correct because it aliases the table name in the FROM clause and then uses the alias throughout the query. A is not correct because the table is not aliased in the FROM clause. B is not correct because the table is not aliased at all, but the WHERE clause includes a use of the alias. C is not correct because the second condition doesn’t use the alias.

7. A. A is correct because a NULL is a placeholder for a missing value. NULL is not comparable to anything; therefore, it is not zero, a blank string, or able to match anything.

8. C. C is correct because it uses the GROUP BY keyword to group on description and sums the salary. A is not correct because columns are rolled up so SELECT * is meaningless. B is not correct because the query is missing a GROUP BY clause. D is not correct because the query needs to group by description, not salary.

9. D. D is correct because the statement is a valid INSERT with two data items. A is not correct because each row is enclosed in parentheses. B is not correct because the statement only specifies two columns and that is allowed as long as there are no constraints on missing data. C is not correct because you can insert multiple rows at a time by separating each row with a comma.

10. B. B is correct because it uses an UPDATE with an appropriate WHERE clause, remembering that you can’t directly compare NULL and need to use IS NULL. A is not correct because it tries to compare directly to NULL. C is not correct because there is no WHERE clause, so everyone will be set to 20 years. D is not correct because the format is not correct: The UPDATE specifies the table name and the SET specifies the column.

Chapter 14

“Do I Know This Already?” Quiz

1. C. The display manager is there to ensure that the user is presented with the opportunity to securely log in and access the system. Even when not logged in there may be the option to shut down the system and other tasks. The other choices are incorrect as they do not perform the function of a display manager.

2. D. Desktop suites almost all contain a set of additional programs such as an office suite, file manager, and settings or configuration manager. The other answers are components of an X Window System, or part of the desktop suite itself.

3. B. This is the correct location of the file; the others are just good distractors.

4. C. The Files section is the appropriate section of the Xorg file for the location of system fonts. The other sections do not deal with fonts, they deal with loadable Modules, the Screen dimensions or in the case of Fonts, they are distractors.

5. D. The Xorg system includes by default the Xorg Display Manager or xdm. The gdm is associated with the GNOME Desktop, the kdm is associated with the KDE Desktop and lightdm is the display manager that is default in Ubuntu distributions.

6. A. When going from the GUI to a text-based virtual terminal, you must use the Ctrl key in front of the standard Alt+F3. You don’t need to use Ctrl when switching back from the text-based terminal to the GUI. The other keystrokes are not able to move you from a GUI to the virtual terminals/tty sessions. They will do whatever they have been mapped to do inside the GUI, but unless Ctrl and Alt plus a Fkey are pressed, you will stay inside the GUI environment.

7. B. Toggle Keys is capable of being configured to emit a sound when a key such as the Ctrl key is pressed. Slow Keys governs the duration of a key’s press before the system accepts it, Repeat Keys governs how many times a key will be repeated with a single press and Bounce Keys governs how the system will ignore several quick or repeated presses on a key.

8. D. The xhost command makes it possible for users and systems to access your system. The other answers are either unrelated configuration parameters or distractors.

Review Questions

1. C. The other sections do not exist in the /etc/X11/xorg.conf file.

2. B. Answer B is correct because this entry enables the xfs X font server if it has been installed. Answer A is incorrect because the FontPath entry doesn’t allow an executable as an argument. Answer C is incorrect because there isn’t a FontServer entry in the Xorg file. Answer D is incorrect because there isn’t an FSERVER variable that affects the font server selection.

3. A, B. Answers A and B are correct because both cause programs to execute remotely but allow them to display locally. The difference is that -Y is permissive and -X uses the inherent X11 Security extension to apply security measures or restrictions to the connection. Answer C is incorrect, it has to do with rekeying the connection and Answer D is incorrect as it is for disabling pseudo-tty connections.

4. C. Answer C is correct because the window manager is capable of providing scrollbars, widgets, and so on for the X environment. Answer A is incorrect because a desktop typically has the mentioned features but is better known for providing an integrated environmental look and feel along with an Office suite and other utilities. Answer B is incorrect because the X server just manages the display and paints the output on the screen. Answer D is incorrect because an X client depends on the window manager to provide the mentioned options.

5. The correct answer is xhost.

6. C. The other directories do not exist on a typical Linux distribution.

7. B. The others are not valid software programs.

8. C. Answer C is correct because Mouse Keys allow you to use your keyboard keys to move your mouse cursor. Answer A is incorrect because Toggle Keys make a sound when a modifier key is pressed. Answer B is incorrect because there is no such feature called Keyboard Keys. Answer D is incorrect because Slow Keys require a user to hold down a key for a brief period before it is displayed.

9. C. The correct answer is High Contrast.

10. C. None of the others exist as valid Linux programs.

Chapter 15

“Do I Know This Already?” Quiz

1. A. The UID for the root user account is 0. The other UIDs are non-root.

2. C. Answer C is correct because the nobody account is typically the UID 99. This account exists to allow a user to be assigned to services that need to run as a user but should not be logged in to. The rest of the UIDs are not associated with the nobody account.

3. D. Answer D is correct because the last field of the entry is the member list. The group is named tim, and you can assume that there is a user named tim who has the group assigned as his primary group in the /etc/passwd file. The usernames in the last field are always secondary users of the group; therefore, they do not have that group name in their primary group field in the /etc/passwd. Answer B is the contents of the password field and Answer C is the GID of the group.

4. D. Answer D is correct. The –m option makes the home directory, so Answer A is incorrect. Answer B is incorrect because the –d option specifies the home directory. The –k option specifies the skel directory, so Answer C is incorrect.

5. B. Answer A is incorrect because the -e option specifies the home directory. Answer C is incorrect because -c is the option for the Comment field, and Answer D is incorrect because -b is the option for the base-dir or default base directory.

6. D. The chage command changes password aging policies for a user, so Answer A is incorrect. The ulimit command doesn’t modify group ownership, so Answer B is incorrect. The groupmod command does change group information but not group membership, so Answer C is incorrect.

7. A. Answers B and C are not valid options. Answer D forces the removal of the account.

8. D. Answer A is the file where passwords used to be stored on older Linux systems. Answers B and C are not valid files.

9. A, B, C. Answers A, B, and C are correct. Answer D is not a valid command.

Review Questions

1. The correct answer is 6. There are no alternative answers.

2. A. Answer A is correct because this output indicates that the user’s account associated with UID 1002 was deleted. Answer B is incorrect because all files must be owned by an account. Answer C is incorrect because the /etc/passwd file being corrupted would not cause this output. Answer D is incorrect because the user’s group has nothing to do with the output, other than showing what the group owner is currently.

3. The correct answer is 511. There are no alternative answers.

4. The correct answer is /etc/skel. There are no alternative answers.

5. D. Answer D is correct because using the chage username command interactively asks and sets the /etc/shadow options. Answer A is incorrect because the passwd command doesn’t interactively change the options in the /etc/shadow file. Answer B is incorrect because there is no such thing as a chpass command. Answer C is incorrect because the vipw command is used to alter the /etc/passwd file.

6. The correct answer is newgrp. There are no alternative answers.

7. The correct answer is 644. There are no alternative answers.

8. C. Answer C is correct because the ulimit command shows account limitations. Answer A is incorrect because the umask command shows the altered permissions for created objects. Answer B is incorrect because dmesg is for system initialization log file viewing. Answer D is incorrect because there isn’t a perms command.

Chapter 16

“Do I Know This Already?” Quiz

1. B. B is correct because the column order is minute, hour, day of month. A is not correct because that transposes the first two columns. C is not correct because that is reading the day column as an hour. D is not correct because that is reading the day column as minutes.

2. A. A is correct because */2 in the hours column means “every 2 hours” and 1 in the fifth column means “Monday.” B is not correct because half hour would be */30 in the first column and the day of the month is the third column. C and D are not correct for the same reasons.

3. C. C is correct because with no cron.deny file, cron.allow dictates who can run crontab. A is not correct because sudo access is not needed to edit a user’s own crontab. B is not correct because full usernames go in that file. D is not correct because, while crontab eventually will need to have root access, it does not give this error.

4. C, D. C is correct because cron specifies jobs down to the minute and anacron down to the day. D is correct because cron doesn’t guarantee jobs will be run. If the system is off at the appointed time, the job will be missed. A is not correct because both systems run periodic jobs. B is not correct because anacron does not know about users and relies on a single configuration file.

5. C. C is correct because the anacrontab file has four columns: The period in days, the delay in minutes, the job identifier, and the command. A is not correct because there is no need to specify a username, as everything runs as root. B is not correct because there are only two numbers at the beginning. D is not correct because there is no user in the file.

6. B. B is correct because at is for one-off jobs. A is not correct because that is anacron’s limitation. C is not correct because at jobs are not periodic. D is not correct because that is the function of batch.

Review Questions

1. D. D is correct because it uses the 1-23 range of hours and skips 2 every time. A is not correct because a skip of 120 over the span of 60 minutes doesn’t work. B is not correct because the minutes column is being used and that is an invalid use of the skip counter. C is not correct because that will execute on even hours instead of odd hours.

2. C. Answer C is correct because the atrun command can be used to set the load average that batch uses as its threshold. Answer A is incorrect because there is no such command as batchavg. Answer B is incorrect because there is no such command as atconfig. Answer D is incorrect because the crontab command has no such capability.

3. A. A is correct because it is likely the search path is not expansive enough. B is not correct because the shell is already using bash. C is not correct because that just sends out emails of the error, which you already know. D is not correct because that environment variable does not exist.

4. A. A is correct because the user crontabs are stored in /var/spool/cron. The rest of the options are incorrect.

5. B. B is correct because the cron.allow file takes priority over cron.deny. A is not correct because the allow file takes priority. C is only correct if the files are empty or nonexistent. D is incorrect because allow takes priority over deny.

6. True. A is correct because anacron ensures daily jobs are executed even if the computer was off when the job was supposed to run.

7. A. A is correct because anacron holds the timestamp of the last run of that job in a file bearing the name of the job identifier. B is not correct because jobs are sorted by the period and delay. C is not correct because identifying the process in the process list is not the primary purpose of the identifier. It may show up briefly, but this is not the goal. D is not correct because everything in anacron runs as root.

8. D. D is correct because /etc/cron.d contains system crontabs in the extended format that includes a user name. A is not correct because /etc/crontab is a file, not a directory. B is not correct because it contains standard crontabs. C is not correct because it does not contain crontabs at all. Instead, /etc/cron.daily contains scripts that are run daily through anacron.

9. C. C is correct because at -l (also known as atq) lists the jobs and atrm (also known as at -d) deletes jobs by their id. A is not correct because -q is not a valid flag to at. B is not correct because that would delete every scheduled job, not just yours. D is not correct because at -r is not valid.

10. A. A is correct because the batch command is used to run jobs when the system load average gets below a certain threshold. B is not correct because at is used to schedule jobs for a certain time. C and D are not correct because they are used to schedule regularly occurring jobs for a particular time.

Chapter 17

“Do I Know This Already?” Quiz

1. A. A is correct because the printer itself has been stopped, and cupsenable fixes that. B is not correct because lpq shows the status of the printer and does not change it. C is not correct because cupsaccept enables the queue, not the printer, and in this case the queue is accepting jobs. D is not correct for the same reasons as C, with the addition that the name of the printer is passed directly without any options.

2. C. C is correct because the lp command’s -d option selects the destination printer, and the command expects a filename to print. A is not correct because lpr expects the printer to be selected with -P. B is not correct because lp selects the printer with -d, not -P. D is not correct because it will print to the default printer, if it exists, which is not necessarily Main given the information in the question.

3. B. B is correct because that is the location of the CUPS configuration files. Other answers are incorrect.

4. C. C is correct because the MTA’s job is to transfer mail from one computer to the next, on its way for delivery. A is not correct because the MUA is the piece that the user uses to send and receive email. B is not correct because the Mail Relay Agent is not a typical component of email delivery. D is not correct because the MDA is responsible for the final delivery of email from the final MTA to the user’s mailbox.

5. D. D is correct because the newaliases command must be run after editing the alias file. A is not correct because that will not rebuild the aliases.db file to make your changes take effect. B is not correct because the aliases file still overrides the presence of a local user. C is not correct because a .forward file doesn’t override an alias.

6. A. A is correct because Exchange is a commercial product made for Microsoft servers. B, C, and D are all open source MTAs that run on Linux.

Review Questions

1. C. C is correct because the IPP protocol listens on TCP port 631. A is not correct because that URL points to a local web server. B is not correct because that URL points to a local web server running in secure mode. D is not correct because that points to a non-web port (lightweight directory access protocol).

2. C. C is correct because the stopped state is reserved for the case when CUPS stops a queue because there is some kind of error. A is not correct because the idle state means that the printer is online and waiting for work. B is not correct because processing means that CUPS is currently sending something to the printer. D is not correct because paused means that the administrator has disabled the printer.

3. lpstat -d

4. A. A is correct because the lprm command deletes a job from the printer named by the -P option. Without a job ID it deletes the first job. B is not correct because it deletes job number 1, but the job has an ID of 3. C is not correct because there is no such option to lpq, which is used for querying the printer queue. D is not correct because the job will still be there if the printer is turned off.

5. D. D is correct because the cupsreject command rejects all jobs to the given queue immediately. A is not correct because there is no such option to lpstat, and the command itself is read-only. B is not correct because the cupsreject command expects the name of the queue with no parameters. C is not correct because that actually deletes the queue.

6. B, D. B and D are correct because both Qmail and Postfix are implemented as a series of separate components so that a problem with one doesn’t compromise functionality of others. Both A and C refer to monoliths that have a single daemon doing all the work.

7. /etc/aliases

8. D. D is correct because the newaliases command updates the /etc/aliases.db file with the contents of /etc/aliases. A is not correct because that displays the contents of the mail queue. B is not a command. C is a command used to update Postfix databases but is incomplete.

9. B. B is correct because the user’s .forward file tells the mail delivery agent to forward mail to another account instead of delivering locally. A is not correct because that is used to send an email through sendmail. C is not correct because /etc/aliases is not accessible to users, nor does that line specify a source address, which is required. D is not correct because the name of the file should be ~/.forward.

Chapter 18

“Do I Know This Already?” Quiz

1. C. C is correct because the Linux kernel maintains the system clock. A is not correct because the RTC on the motherboard is the source of the hardware clock. B is not correct because the NTP system keeps the clock up to date but is not the source. D is not correct because the GPS clocks are used to calibrate stratum 1 servers.

2. A. A is correct because the format string given separates all elements by spaces and specifies year, numeric month, day of month, hour in 24-hour time, and minute. The others are incorrect.

3. B. B is correct because the -w option writes the current system clock to the hardware clock. A is not correct because that is the default mode of the hwclock command. C is not correct because that is done with the -s option. D is not correct because that is done with the -u option.

4. A, D. The rule matches anything of notice priority or more important unless it is mail. A is correct because warning is more important than notice. D is correct because err (error) is more important than notice. B is not correct because info is less important than notice and is excluded here. C is not correct because the mail facility was excluded.

5. A. A is correct because the logger command takes a message on the command line and sends it to syslog. B is not correct because there is no log command for syslog. C is not correct because there is no syslog command to log messages. D is not correct because syslogd doesn’t take information from stdin, nor does it log messages to itself from the command line.

6. C. C is correct because the -f flag puts journalctl in follow mode. A is not correct because the files under /var/log/journal are in binary format and can’t be read by tail. B is not correct because the output of journalctl stops when the end of the file is reached. D is not correct because there is no --continuous option.

7. C, D. C is correct because the copytruncate option rotates a log file by copying it and truncating the original. This allows you to rotate a log file without touching the process that owns it. D is correct because restarting the daemon gets it to reopen the log files with the nontimestamped names. A is not correct because the log rotation can be handled with one of the options in answers C or D. B is not correct because if logrotate were not running, the log file would not have been renamed.

8. B. B is correct because anacron runs the logrotate program, which performs log rotation. A is not correct because the log rotation program is not a daemon. C is not correct because the kernel does not deal with log rotation. D is not correct because even though the program can be run manually, it only provides benefit if run regularly from cron.

Review Questions

1. A, B. A is correct because the hardware clock is the real-time clock on the computer’s motherboard. B is correct because the system clock is the clock maintained inside the Linux kernel. C is not correct because the NTP is not a clock but a protocol designed to keep a clock updated with the correct time. D is not a clock, as cron reads the system clock to figure out when to trigger a job.

2. D. D is correct because it uses the correct format—the year comes last, and the items before it are month, day, hour, and minute. A is not correct because the year is in the wrong spot, as is the case with B. C is not correct because the format is incorrect, but it also uses the + option, which means to print the date in the given format.

3. B, C. B and C are correct because they are the long and short ways of writing the system clock to the hardware clock. A is not correct because that saves the hardware clock into the system clock. D is not correct because that reads the hardware clock, not writes it.

4. D. D is correct because the ntpq command is used to query the ntp daemon and find out the status of peers. A is not correct because there is no --debug flag. B is not correct because the date command tells you about the system clock and not ntpd. C is not correct because there is no ntptool command.

5. D. D is correct because pool.ntp.org is the name of the public NTP pool. All the remaining options are incorrect.

6. /var/log/journal

7. A. A is correct because syslog-ng, along with rsyslog, are alternative syslog implementations. B and C are not the names of any project. D is not correct because journald is not a syslog implementation; it is a complete replacement for system logging.

8. B, D. B and D are correct because the severities, in order of least to most severe, are debug, info, notice, warning, err, crit, alert, emerg. The remaining two come before notice.

9. A. A is correct because it captures everything at debug level and greater, which includes info, and removes mail with the mail.none keyword. B is not correct because that would capture anything at alert and higher and all mail messages. C is not correct because it captures everything at notice level and greater, which doesn’t include info. D is not correct because the -mail is not a valid configuration.

10. D. D is correct because a stratum 2 server gets its time from a stratum 1 server, which must have a reference clock. A is not correct because the stratum of your server is defined by who it gets its time from, not the other way around. B is not correct because the stratum doesn’t dictate how the time is calculated locally. C is not correct because the clock skew doesn’t define the stratum.

Chapter 19

“Do I Know This Already?” Quiz

1. B. The first and second octet of the address are the network part of an address with Class B or 16-bit network mask. The other answers are either not a Class B network or are the wrong range.

2. D. The 255.0.0.0 subnet mask is identical to the notation /8 or 8-bit subnet mask. The other answers are incorrect because they don’t match properly.

3. D. The subnet mask is a /24, indicating that the last octet is a network, the first address or 0 is the network itself, and the last address 255 is the broadcast address. The other answers are incorrect or don’t match properly.

4. A. The TCP protocol is capable of making network communications much more reliable than its lesser-capable fellow protocol UDP. TCP can detect lost packets, reorder them if delivered out of order, and perform other functions that make network communications more reliable. Answer B is incorrect because UDP is much less reliable and is used for more broadcast-oriented or less-critical network communications. Answer C is incorrect because the IGMP protocol is an add-on to the TCP layer but does not transport actual data, and Answer D is incorrect because the ICMP protocol is typically used to transmit necessary diagnostic information between hosts.

5. A, D. The ifconfig command is a historical method of viewing your IP address information, whereas the ip command is a newer and more commonly supported version that introduces some new and useful functions. Answer B is incorrect because the route command is used to view and change the routing table. Answer C is incorrect because the ifup command is used to bring an interface “up” or make it active.

6. B. The route command is used to display and manage the default gateway. The other commands are typically used for manipulating or showing the IP address information.

7. D. The order of the query is files first, which means the /etc/hosts file will be consulted. The rest of the servers in the answers would be queried only if a name resolution is not achieved from the local files.

8. A, B, C. Answers A, B, and C are correct, as they are all client tools that request an IP address from the DHCP server. Answer D is the DHCP server daemon and not a client utility or command.

9. C. The dig command is used to gather or query information from the DNS server you are using it upon. The other answers are not related to DNS entries.

Review Questions

1. B. Answer B is correct because the network is a Class C; therefore, the network mask of /28 causes the LSB to be 16, and networks are incremented by 16, making the 192.168.33.35 address’s network address 192.168.33.3 2. Answer A is incorrect because that is the first valid network but not the one your IP resides on. Answer C is incorrect because 192.168.33.0 is the default network if you were using a /24 network mask. Answer D is incorrect because it’s two networks past the one your IP is on.

2. The correct answer is route. An alternative is netstat -r.

3. C. Answer C is correct because, with the number of networks needed, a 240 subnet mask is needed and allows for at least 10 hosts per network. Answer A is incorrect because a 192 subnet mask allows for only 4 possible networks. Answer B is incorrect because a 224 subnet mask allows for only 8 possible networks, but with the loss of the first and last subnets, a 224 subnet mask really means that 6 networks are usable. Answer D is incorrect because a 248 subnet mask allows for enough networks (32) but not enough hosts per network.

4. The correct answer is traceroute. There are no correct alternative answers.

5. The correct answer is route add default gw 192.168.33.1. There are no correct alternative answers.

6. B, D. Answers B and D are correct because they both can be used to show MX records or the names of the mail servers. Answers A and C are incorrect because these commands don’t exist.

7. The correct answer is /etc/nsswitch.conf. There are no correct alternative answers.

8. A, C, D. Answers A, C, and D are correct because they all are valid resolution methods on the hosts: line in the /etc/nsswitch.conf file. Answer B is incorrect because there is no method named ylwpage.

9. The correct answer is tcpdump. There are no correct alternative answers.

Chapter 20

“Do I Know This Already?” Quiz

1. D. The /etc/sudoers file is the configuration file for the sudo command. The others are incorrect or don’t exist.

2. A, D. The -l and just the - symbol both cause the su command to execute the login as a login shell, reading and sourcing all the appropriate configuration files, just as if the user had logged in to the console of the system as that user. Answer B is incorrect in that it will run a specific shell that you have to specify. Answer C is incorrect because double dashes is not a part of the options that the su command supports. Answer E is incorrect because there is no –k option to the su command.

3. A, B. The inetd and xinetd super servers are start on demand server environments, they receive a request from a client on a configured port and protocol and start an instance of that service to answer the request. The other answers are simply distractors and don’t exist.

4. C, D. The /etc/hosts.allow and /etc/host.deny files are used by the librwrap and TCP wrappers to protect services. There are no such files as Answer A or Answer B.

5. D. You can use the find command with the -perm option to find SUID files on the system. Answer A is incorrect as there is no search command installed by default on a Linux system. Answer B is incorrect in that locate simply locates files via a database search. Answer C is incorrect because it cannot easily display all SUID files on your system.

6. B. The gpg --gen-key command and option generate the private and public keys on the system. The other answers are incorrect because they are partially-formed answers based on the correct answer.

7. A, D. The /etc/ssh/ssh_known_hosts file is the system location for the SSH public host keys, and the ~/.ssh/known_hosts file is the user-specific location for the SSH public host keys. The other answers are existing files on the system, but they don’t contain the list of keys being asked for.

8. B, C. The chage and usermod commands both allow for the changing of the user’s password aging information. Answer A is incorrect because the fuser command shows the PID’s of processes a user owns, Answer D is incorrect because ulimit has to do with limiting the user’s environment and Answer E is incorrect because it shows the files being used by processes on a given filesystem.

Review Questions

1. A. Answer A is correct because when a user connects to a host for the first time via SSH, the RSA host key is copied to that user’s local .ssh/known_hosts file. Answer B is incorrect because the known_hosts file exists only in user configurations. Answer C is incorrect because the authorized_keys file on host2 has nothing to do with this connection. Answer D is incorrect because authorized_keys files are used only in user configurations.

2. The correct answer is /etc/hosts.deny. There are no alternative correct answers.

3. A, B, D. Answers A, B, and D are correct because they all copy the file properly from host1 to host3. Answer C is incorrect because the addition of the :~ to the end of the host3 target causes an error trying to write a file to a directory that can’t be resolved.

4. The correct answer is gpg --list-keys. There are no alternative correct answers.

5. B. Answer B is correct because the +7000 means to look for any combination of special bits that are set when using the -perm option for find. Answer A is incorrect because it finds only files that have all the special bits set. Answer C is incorrect because it finds only files that have the permissions ---s------. Answer D is incorrect because the locate command doesn’t have a --permissions option.

6. C. Answer C is correct because ssh-agent wraps around the current shell and provides requested credentials, enabling you to not enter a password for a connection. Answer A is incorrect because it is used to load the user’s key into the ssh-agent, but it doesn’t run otherwise. Answer B is incorrect because it’s used to generate the user’s private and public keys but isn’t otherwise used. Answer D is incorrect because the .ssh/authorized_keys file is not a program or utility.

7. The correct answer is ssh-keygen -b 1024 -t rsa. There are no alternative correct answers.