Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Guide to Linux Installation and Administration, 2e

Chapter 11 Solutions
REVIEW QUESTIONS
1. Name four shell scripts that are included on a standard Linux system, and describe the use of each one.
Examples include all the files in /etc/rc.d/init.d, /etc/rc.d/rc.local, /etc/rc.d/rc.sysinit, xinitrc, bash_profile,
/etc/profile, Xsession, and similar initialization scripts.

2. The first line of a standard shell script must contain:


c. The path and filename of the shell used to execute the script

3. In order to be executed by any user (including root), a shell script must have the _____ file permission set.
a. Execute

4. Which of these statements contains a standard positional variable?


b. gzip $1

5. Which two commands involve a test value of true or false?


a. if and while

6. The test command is equivalent to using square brackets around a test expression, but the test command is less
frequently used.
True

7. Briefly explain why comments are an important part of any shell script.
They tell other system administrators what a shell script is for and how to interact with it; they also remind the
author of these facts later on!

8. Describe the difference in control methods between a for loop and a while loop.
A for loop repeats statements a fixed number of times; a while loop repeats statements until a condition is met, which
is typically not predictable and may last forever.

9. A loop beginning with the command “for i in 2 4 6 8” will be executed how many times?
b. Four

10. Name three non-shell scripting languages. Include a statement on the use, characteristics, or author of each one.
The most popular are listed in Table 11-2; many others are used as well.

11. CGI is popular for which of the following purposes?


b. Interfacing between scripts and Web servers

12. Briefly explain the difference in time specification formats for the at and crontab commands.
at uses keywords like now, hours, minutes, days, tomorrow, today; crontab uses a numeric system based on five fields
representing minutes, hours, day of month, month of year, and day of week.

13. The daemon that manages commands submitted using at and cron are:
c. atd and crond

14. When using the at command interactively to enter commands scheduled for future execution, you indicate that you
have finished entering commands by pressing:
a. Ctrl+D

15. The batch command is used to schedule jobs so that:


c. The system will not be overloaded with scheduled tasks.
16. A simple method for root to schedule recurring system administration tasks is to:
b. Add a script to a directory such as /etc/cron.daily or /etc/cron.weekly.

17. The output of a cron job is normally sent via ______ to the user who submitted the cron job or to the user defined
by the _____ variable within the file containing the cron job.
a. e-mail, MAILTO

18. Name, in order from left to right, the fields of the crontab time specification, giving the range of valid numeric
values for each one.
Minute of the hour: from 0 to 59.
Hour of the day: from 0 to 23.
Day of the month: from 0 to 31
Month of the year : from 0 to 12
Day of the week: from 0 to 7

19. Output from a command executed as part of a cron job cannot be redirected to a file using standard redirection
operators because the environment in which the cron job was created is unlikely to exist when the cron job is
executed.
False

20. The _____ file can include a username in order to deny that user access to the crontab command.
b. /etc/cron.deny

21. Name the two separate commands that can be used instead of at -l and at -d.
atq and atrm

22. Name an advantage of using the make config kernel configuration utility.
You can use input redirection to feed responses to it for faster kernel configuration; this is used only by advanced
users.

23. The make command acts based on

24. The preferred method of installing kernel source code is to include Kernel Development as an option during the
initial installation of Linux.
a. This is true because there are so many dependent packages that it is a lot of work to manually install them all.

25. A newly compiled kernel created using the make bzImage command is initially stored in which directory?
d. /usr/src/linux-2.4/arch/i386/boot

HANDS-ON PROJECTS

Project 11-1
9. Enter ./fileinfo to execute the command without any parameters. What happens? What result is returned by the test in
the second line of the script?
The message appears “You must include a filename on the command line.” The result returned by the test is True,
because the test “is $# less than 1” is true—with no filenames on the command line, the value of $# is 0.

10. What other methods could you use to test for the presence of a command-line parameter? What would happen if you
removed the if/then test but didn’t include any filenames on the command line?
You could use different tests from table 11-1, such as –le. If you removed the if/then test, the for loop would count zero
times and the statement block between do and done would not be executed at all.
11. Enter ./fileinfo /etc/termcap to execute the command with a parameter. What happens? How many times was the for
loop executed?
Once

12. Execute the command with the parameter shown here:


./fileinfo /etc/m*conf
What happens? How could you alter the script to test the validity of each filename that was provided on the command
line before using the wc command? (Hint: Use the -r file test from Table 11-1.)
Enclose everything currently between do and done in the for loop inside another if/then statement that used the test
[ $i –r ];

Project 11-2
8. Press Ctrl+D to finish entering the commands you want to automate. What message do you see? What time is
specified? Is it a relative time or an absolute time based on the time specification that you entered?
You see the <EOT> indication, then an absolute time based on the specification you gave in the at command (15
minutes after that time).

9. Enter the atq command. What information do you see about the job you just entered? What is the job number?
You see a job number, the time it will be executed, and your user name. The exact job number will differ on each
system.

Project 11-3
4. Describe the time specification that you entered in the du_job file.
The command will be executed every day of the year at 2:30 in the morning.

5. What problem could occur with the command entered in the du_job file because you are working as a regular user?
Your regular user cannot access other user’s home directories, so the results in /tmp/output will only include your
own home directory.

15. Enter crontab -r to remove the crontab file for your regular user account. What happens? Why?
You are not allowed to use crontab as this regular user because of the cron.deny entry. This is true even though your
previously-submitted job is still in the system.

CASE PROJECTS
1. One of the cron jobs submitted by a user looks like this:
* * * * 1-5 grep html `ls -r /` > ~/Webpages
Describe what this command does and explain why it is causing problems for every user on the system.
This command searches a listing of all mounted file systems for all filenames containing the string “html” and stores
that list in the Webpages file in the user’s home directory. This is done once per minute, 24 hours per day, Monday
through Friday. The system has slowed to a crawl if indeed it hasn’t crashed.

3. After working out some of the automation issues with the Starwood staff, they ask you about using their digital
video cameras with Linux. The cameras use a video interface called FireWire, or IEEE 1394. The FireWire interface of the
cameras is based on an OHCI-1394 chipset manufactured by NEC. Launch the xconfig kernel configuration utility and find
out whether Linux supports this chipset.
Click on the IEEE-1394 Firewire Support button. Then choose the Help button next to the OHCI-1394 Support line
to see that the Texas Instruments and NEC chipsets are supported.

You might also like