Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux+ Certification Bible.pdf
Скачиваний:
46
Добавлен:
15.03.2015
Размер:
3.78 Mб
Скачать

Chapter 12 Study Guide 405

6.Use the ifconfig command to enable the interface again: ifconfig eth0 up

You should be able to ping the address from another machine again.

Lab 12-2 Configuring Cron to Automate Tasks

The objective for this hands-on lab is to gain experience in using cron to automate tasks. You should be able to use any default Linux installation for this exercise.

1.Logged in as the root user, check your current crontab file: crontab-l

2.Unless you have configured jobs before, it should be empty. Create a simple task that will run each day. Schedule a task for 5 minutes from the current time. So if your time is currently 1:00 p.m., set it to check the local disk space at 1:05 p.m.

crontab -e

Now use vi to enter the cron command:

5 13 * * * df -kl

3.Wait five minutes, and then check your root mail file by using the following command:

mail

You should have an e-mail with the output of the df -kl command.

4.Delete your crontab file so that it is empty again by using the following command:

crontab -r

Check to see that the job was removed by using the following command: crontab -l

Answers to Chapter Questions

Chapter Pre-test

1.Cron is used to schedule recurring jobs. You can set it to run a program or script at any time you choose.

2.A file with a tar.gz extension is a file archive created by tar. Compress this file by using the gzip command.

406 Chapter 12 Study Guide

3.The ifconfig command shows you information about the configuration of your network interfaces, including addresses, and packets transmitted and received.

4.The command to create a file system is mkfs. This command invokes another command specific for that file system, such as mke2fs for Linux file systems.

5.Analyze core dumps to find out why a program crashed. It may give you important information that can help you find what bug is causing the program to fail.

6.A program patch is an update to an application or service that was created to fix an existing bug, or to enhance security or functionality for a program.

7.The at command differs from cron in that it can only be used to schedule a job to run at one time. The cron command allows you to set up a job that will run at recurring times.

8.The fsck utility (File System Check) can scan your disk for errors, and actually fix them as it checks. This is helpful in recovering corrupted file systems that won’t mount or boot.

9.Any system upgrades or patches should be performed in off-hours, so that it won’t affect users currently logged into the system. If the system needs to be rebooted, you won’t have any files still open by users, which may cause them to be corrupted.

10.The fdisk command is used to create partitions on a hard drive.

Assessment Questions

1.D. By invoking the mkfs command, you actually run a program specific to the file system that you are creating, such as mke2fs to format using the Linux ext2 file system. For review, see the “Disk and File System Management” section.

2.B. By analyzing the resulting core file from an application, the administrator may be able to debug the application and find out why the program is crashing. For review, see the “Core Dumps” section.

3.A. The administrator can select the loopback interface to configure by using the ifconfig lo command. The IP address for any loopback interface is 127.0.0.1. For review, see the “Managing Network Interfaces” section.

4.C. The proper format for cron entries is minute/hour/day/month/day of week (0-Sunday, 6-Saturday). For review, see the “System Automation and Scheduling” section.

5.D. To store and compress most file archives, a number of files are stored in a tar archive. To compress that archive, use the gzip command. For review, see the “Installing System Packages and Patches” section.

Chapter 12 Study Guide 407

6.A. The correct command is ifconfig eth0 192.168.1.5 netmask 255.255.255.0. The eth0 option can be any Ethernet interface. The loopback interface must always use 127.0.0.1 for an IP address. For review, see the “Managing Network Interfaces” section.

7.B. Within the fdisk utility, the “p” command will print the partition table. This command does not “print” to a printer; the command displays the partition table on the terminal screen. For review, see the “Disk and File System Management” section.

8.D. The GNU debugger is the most popular tool for analyzing core dump files. You can use it to walk step-by-step through a program to identify bugs. For review, see the “Core Dumps” section.

9.A. The cron command allows you to create recurring tasks. The at command only allows you to execute a scheduled task at one particular time. For review, see the “System Automation and Scheduling” section.

10.C. The rpm -U command will update a currently existing package to the new version. If the program doesn’t exist, rpm will install the package. For review, see the “Installing System Packages and Patches” section.

11.B. To enable an interface, use the ifconfig eth0 up command. If you need to disable the interface, use ifconfig eth0 down. For review, see the “Managing Network Interfaces” section.

12.A. The proper command is tar -zxvf filename. You can also complete the operation by using two separate commands, tar to extract the archive and gunzip to decompress the file. For review, see the “Installing System Packages and Patches” section.

13.C. The core file will tell you what exactly caused the program to crash. In this case, the program crashed because of a segmentation fault in memory. For review, see the “Core Dumps” section.

14.A. The first ATA/IDE hard drive is hda, so the correct command is fdisk /dev/hda. For review, see the “Disk and File System Management” section.

15.B. If you have no intention of keeping these files for debugging purposes, they should be deleted because they are wasting valuable disk space, and may cause your system to run out of space. For review, see the “Core Dumps” section.

16.D. Programs and applications should be kept up-to-date with the latest releases because the newest version will always have the latest security updates, bug fixes, and additional functionality. For review, see the “Installing System Packages and Patches” section.

17.A. The Linux swap file is used for virtual memory to store additional information that can’t fit into current memory. This swap file allows information to be cached on disk, and can be retrieved very quickly. Heavy use of the swap file indicates a low memory condition. For review, see the “Disk and File System Management” section.

408 Chapter 12 Study Guide

18.C. A kernel panic indicates that a kernel process has crashed. This is a very serious error that causes the entire Linux system to crash. These core dumps should be analyzed carefully to find the root cause of the problem. For review, see the “Core Dumps” section.

19.A. The second ethernet interface is called eth1, so the proper command is ifconfig eth1 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.254. For review, see the “Managing Network Interfaces” section.

20.B. Because you are only running this job once at the specified time, you only need to use the at command. The cron command is more useful for setting up recurring jobs. The correct syntax is at 23:59. For review, see the “System Automation and Scheduling” section.

Scenarios

1.Because this must be a recurring task, the at command won’t be an efficient method for performing the task in this situation. It is much easier to set up cron to run a script that will check the disk space daily at 1:00 p.m. The output will be e-mailed to the root account. You can compare the results from day to day to analyze disk space usage.

Your cron file should look similar to the following:

* 13 * * * df -kl

2.The crash of the Web server should create a core dump file in the Web server home directory. The administrator can save that file, and either debug it himself using the GNU debugger tool (gdb), or pass it along to the programmer who created the Perl code so that they can debug the program and remove the bugs that are causing the Web server to crash.

Process

C H A P T E R

13

Management

EXAM OBJECTIVES

5.6 Differentiate core services from non-critical services (e.g., ps, PID, PPID, init, timer)

5.7 Identify, execute and kill processes (ps, kill, killall)

5.8 Monitor system log files regularly for errors, logins, and unusual activity

5.9 Document work performed on a system

410 Part V Maintaining the Linux System

CHAPTER PRE-TEST

1.What command is used to identify processes?

2.Which log file contains a list of user logins and logouts?

3.Why is maintenance documentation important?

4.What command is used to terminate a process?

5.What is the difference between a core process and a non-critical process?

6.What is the purpose of the init process?

7.What is a PID?

8.What command is used to send a running process into the background?

9.Which log contains system errors?

10.What command can be used to see real-time information on running processes and the resources that they are using?

Answers to these questions can be found at the end of the chapter.

Соседние файлы в предмете Операционные системы