Pré-visualização | Página 14 de 25
are references to files on Linux filesystems; they’re meaningful only after the BIOS has found a boot loader and run it and lots of other boot processes have occurred. 2. C. You can type a stanza name (such as linux, although this can vary) and a runlevel num- ber (such as 1) at a LILO boot: prompt to boot into the specified runlevel; runlevel 1 is single-user mode. Option A won’t do the trick unless you’ve got a stanza called s and your system is configured to boot into single-user mode by default. Option B is similar. Option C is a command you can type once Linux has booted to reboot the computer, but it won’t work as described at a LILO boot: prompt. 3. D. The kernel ring buffer, which can be viewed by typing dmesg (piping this through less is a good supplement), contains messages from the kernel, including those from hardware drivers. These messages may provide a clue about why the disk didn’t appear. The /var/ log/diskerror file is fictitious, as is /mnt/disks. The /etc/inittab file doesn’t directly control disk access and so is unlikely to provide useful information. 4. B. Ordinarily, Linux runs init as the first program; init then runs, via various scripts, other programs. The dmesg program is a user diagnostic and information tool used to access the kernel ring buffer; it’s not part of the startup process. The startup program is fictitious. The rc program is a script that init calls, typically indirectly, during the startup sequence, but it’s not the first program the kernel runs. 5. D. Option D is the correct LILO configuration file. Option A is a fictitious file; it doesn’t exist. Although LILO’s boot loader code may be written to the MBR, as implied by option B, this isn’t the location of the LILO configuration file. Option C is reminiscent of the loca- tion of the GRUB configuration file; it’s not the location of the LILO configuration file. 6. A. The image keyword identifies a kernel file in the LILO configuration file, and an equal sign (=) separates this keyword from the filename. Option B lacks this equal sign, and options C and D use the kernel keyword instead of image. (GRUB uses kernel, but slightly differently from the way LILO uses image.) 7. D. You use grub-install to install the GRUB boot loader code into an MBR or boot sec- tor. When using grub-install, you specify the boot sector on the command line. The MBR is the first sector on a hard drive, so you give it the Linux device identifier for the entire hard disk, /dev/hda. Option A specifies using the grub utility, which is an interactive tool, and the device identifier shown in option A is a GRUB-style identifier for what would probably be the /dev/hda3 partition in Linux. Option B is almost correct but installs GRUB to the /dev/hda1 partition’s boot sector rather than the hard disk’s MBR. Option C is the com- mand to install LILO to the MBR rather than to install GRUB. 262 Chapter 5 N Booting Linux and Editing Files 8. B. The root keyword in a GRUB configuration file tells GRUB where to look for files, including its own configuration files, kernel files, and so on. Because GRUB numbers start- ing from 0, (hd1,5) refers to the sixth partition on the second disk. Option A is incorrect because you pass the Linux root partition to the kernel on the kernel line. Options A and C both misinterpret the GRUB numbering scheme. The GRUB installation location is speci- fied on the grub-install command line, and /dev/hd1,5 isn’t a standard Linux device file. 9. B. The initdefault action specifies the default runlevel. 10. A, B, D. Runlevel 0 is the reserved runlevel for halting the system. Runlevel 1 is reserved for single-user mode. Runlevel 6 is reserved for rebooting. Runlevel 5 is a regular, user- configurable runlevel. (Many systems use it for a regular boot with a GUI login prompt.) 11. B, C. The first number in the runlevel output is the previous runlevel (the letter N is used to indicate that the system hasn’t changed runlevels since booting). The second number is the current runlevel. 12. A. The -c option to shutdown cancels a previously scheduled shutdown. Options B and C describe the effects of the -r and -h options to shutdown, respectively. No shutdown option asks for confirmation before taking action, although you can delay a shutdown by specify- ing a shutdown time in the future. 13. D. There is no standard takedown command in Linux. The reboot command is equiva- lent to shutdown -r, halt is equivalent to shutdown -H, and poweroff is equivalent to shutdown -P. 14. B. The telinit command is used to change runlevels; when it’s passed the 1 parameter, telinit changes to runlevel 1, which is single-user mode. The runlevel command displays the current runlevel but doesn’t change runlevels. Although telinit can be used to shut down or reboot the computer, the shutdown command can’t be used to change runlevels except to runlevel 0 or 6. There is no standard single-user command. 15. D. Runlevel 4 isn’t standardized, and most distributions don’t use it for anything specific (although in practice it will do something if you enter it). You can safely redefine runlevel 4 to achieve specific goals. Option A describes runlevel 6. Option B describes runlevel 3 on Red Hat and related distributions. Option C describes runlevel 5 on Red Hat and related distributions. 16. A. In Vi, dd is the command-mode command that deletes lines. Preceding this command by a number deletes that number of lines. Although yy works similarly, it copies (yanks) text rather than deleting it. Option C works in many more modern text editors, but not in Vi. Option D works in Emacs and similar text editors, but not in Vi. 17. D. The :q! Vi command does as option D states. Option A is simply incorrect. Option B would be correct if this command were typed while in Vi’s insert mode, but the question specifies that command mode is in use. To achieve option C, the command would be :wq, not :q!. Answers to Review Questions 263 18. B. Vi is included on Linux emergency disks, embedded systems, and other systems where space is at a premium because its executable is tiny. Emacs is, in contrast, a behemoth. Con- trary to option A, Vi isn’t an X-based program (although X-based Vi variants are available); Emacs can be used in text mode or with X. Vi’s modes, referred to in option C, have nothing to do with non-English language support. Option D is backward; it’s Emacs that includes a Web browser, e-mail client, and other add-ons. 19. A, B, C. Typing R in command mode enters insert mode with the system configured to over- write existing text. Typing i or a enters insert mode with the system configured to insert text. (The i and a commands differ in how they place the cursor; a advances one space.) Typing : in command mode enters ex mode (you typically type the ex-mode command on the same command line immediately after the colon). 20. B. The Esc key exits Vi’s insert mode. Typing a tilde (~) inserts that character into the file. The Ctrl+X, Ctrl+C key combination exits from Emacs, but it’s not a defined Vi key sequence. The F10 key also isn’t defined in Vi. 320 Chapter 6 N Configuring the X Window System, Localization, and Printing Review Questions 1. When you configure an X server, you need to make changes to configuration files and then start or restart the X server. Which of the following can help streamline this process? A. Shut down X by switching to a runlevel in which X doesn’t run automatically, and then reconfigure it and use startx to test X startup. B. Shut down X by booting into single-user mode, and then reconfigure X and use telinit to start X running again. C. Reconfigure X, and then unplug the computer to avoid the lengthy shutdown process before restarting the system and X along with it. D. Use the startx utility to check the X configuration file for errors before restarting the X server.