P. 1
Linux Certification Bible

Linux Certification Bible

4.0

|Views: 2.327|Likes:
Publicado porMarcelo

More info:

Published by: Marcelo on Dec 18, 2008
Direitos Autorais:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

01/17/2013

pdf

text

original

Slackware’s package management system utilizes .tgz files as its package format.
Although the type of file is very similar to a standard tar.gz file, and can be
unzipped and untarred as usual, the resulting package is only intended for installa-
tion on a Slackware system.

You can install Slackware packages by using a menu-driven tool called pkgtool.
From the command line, you can use different utilities, depending on what you want
to do with the package. For example, to install a package, use the following
command:

installpkg packagename.tgz

The installpkgutility comes with an excellent installation option, which shows
you what happens if you install a particular package. The “warn” option allows you
to test a package before installing on a production system. To test install the pack-
age, use the following command:

installpkg -warn packagename.tgz

To remove a package from a system, use the removepkgcommand:

removepkg packagename

184881-6 ch12.F 11/12/01 8:31 AM Page 398

399

Chapter 12 ✦Linux Disk and System Management

Summary

This chapter details many different system administration tasks. Disk and file
system management, scheduling tasks, networking, analyzing core dumps, and
installing new packages and patches are all routine tasks of the Linux system
administrator. For the exam, keep the following points in mind:

✦Disk and File Management

•fdisk: Formats disk partitions

•mkfs: Creates a file system on a partition

•fsck: File system check for fixing disk errors

✦Job Scheduling

•at: Can only schedule a task for one time

•cron: Can schedule recurring tasks

✦Core Dumps

•core: Typical name of the core file

•gdb: GNU debugger tool for debugging core files

✦Networking

•ifconfig -a: Used to show information on all network interfaces

•ifconfig eth0: Configures the first ethernet interface

•ifconfig lo: Configures the loopback interface

✦Package Upgrades and Patches

•rpm -U: Upgrades an RPM package

•rpm -i: Installs an RPM package

•tar -xvf: Extracts a tar archive, tar file has .tar extension

•tar -zxvf: Extracts and decompresses a tar archive compress with gzip

•gunzip: Unzips a compressed file with extension .gz

•gzip: Compresses a file

•configure, make, make installto compile and install source code

binaries

•Upgrade after work hours to avoid affecting users

184881-6 ch12.F 11/12/01 8:31 AM Page 399

STUDY GUIDE

The Study Guide section provides you with the opportunity to test your knowledge
about the Linux+ exam objectives that are covered in this chapter. The Assessment
Questions provide practice for the real exam, and the Scenarios provide practice
with real situations. If you get any questions wrong, use the answers to determine
the part of the chapter that you should review before continuing.

Assessment Questions

1.What command do you use to format a partition with a file system?

A.fdisk

B.fsmake

C.format

D.mkfs

2.On a Linux Web server, the Apache http server keeps crashing unexpectedly.
What can the Linux administrator check to stop the crashes?

A.process kill log

B.core file

C./var/log/dmesg

D.root cron file

3.An administrator wants to create the local loopback network interface on her
Linux system. Which command will correctly perform the task?

A.ifconfig lo

B.ifconfig -loopback

C.ifconfig -a

D.ifconfig 255.255.255.255

4.Which of the following croncommands will create a cronjob that will run
at5:00 a.m. every Sunday?

A.* 5 * * S /etc/cron.weekly

B./etc/cron.sunday

C.* 5 * * 0 /etc/cron.weekly

D.5 0 * * S /etc/cron.weekly

400Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 400

401

5.What kind of file is stored with an extension of tar.gz?

A.Backup files

B.Temporary files

C.A special compression executable

D.A file that has been tar and gzipped

6.What command should be used to set a network interface to the IP address,
192.168.1.5, with a subnet mask of 255.255.255.0?

A.ifconfig eth0 192.168.1.5 netmask 255.255.255.0

B.ifconfig lo 192.168.1.5 netmask 255.255.255.0

C.ifconfig eth1 192.168.1.5 broadcast 255.255.255.0

D.ifconfig -a 192.168.1.5 255.255.255.0

7.Which option in fdiskwill display the partition table?

A.s (show partition table)

B.p (print partition table)

C.fdisk partition

D.t (tables)

8.What command can you use to view and debug an application’s core file?

A.cron

B.debug

C.vi

D.gdb

9.To create a recurring scheduled task, which Linux scheduling tool should
youuse to perform the task?

A.cron

B.at

C.timer

D.gdb

10.To upgrade an RPM package, which is the proper command to use?

A.rpm -upgrade

B.rpm -i

C.rpm -U

D.rpm -upg

401

Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 401

11.What command can you use to enable an ethernet network interface that
hasalready been configured?

A.ifconfig eth0 on

B.ifconfig eth0 up

C.ifconfig eth0 down

D.ifconfig eth0 start

12.What is the proper command to open and decompress a file with a tar.gz
extension?

A.tar -zxvf filename

B.gzip -txvf filename

C.uncompress filename

D.gunzip -txvf filename

13.A core dump file contains this message, “Program terminated with signal 11,
segmentation fault.” What does this message indicate?

A.The program is a kernel system process

B.Signal 11 means the program is still running, but had an error

C.The program halted because of a memory segment fault

D.Nothing, this is informational only

14.What command runs fdisk on the first ATA/IDE hard drive?

A.fdisk /dev/hda

B.fdisk /dev/sda1

C.fdisk hda1

D.fdisk /dev/hda2

15.An application is creating several, very large core dump files. What should the
administrator do if he has no intention of debugging these files?

A.Copy them to gdb

B.Delete the core files

C.Move them to the root partition

D.Change the name of the file, so that new core files can be created

402Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 402

403

16.What is the best reason to upgrade a package or application on your Linux

system?

A.Updated security

B.Less program bugs

C.More program functionality

D.All of the above

17.When checking the partition information on your hard drive with fdisk, you
notice that one of the partitions is formatted as “Linux Swap,” and is approxi-
mately 128MB in size. What is the purpose of this partition?

A.Special disk area for the Linux Swap file

B.Overflow area in case the main partition runs out of space

C.Virtual memory that is not used

D.Holds temp files and deleted items

18.What sort of kernel error can cause a Linux system to crash and write a
memory core dump?

A.Cron daemon error

B.Corrupt swap file

C.Kernel panic

D.Web server error

19.An administrator needs to create a second network interface with an IP
address of 192.168.1.10, a subnet mask of 255.255.255.0, and a broadcast
address of 192.168.1.254. What command will accomplish this task?

A.ifconfig eth1 192.168.1.10 netmask 255.255.255.0 broadcast
192.168.1.254

B.ifconfig lo 192.168.1.10

C.ipconfig eth0 192.168.1.10 netmask 255.255.255.0 bc=254

D.ifconfig eth0 192.168.1.10 netmask 255.0.0.0 broadcast
192.168.1.254

20.What command should you use to set up a job to run at 11:59 p.m. today?

A.cron 59 11 * * *

B.at 23:59

C.cron 11:59pm

D.at 11:59am

403

Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 403

Scenarios

1.Management has instructed you to set up a schedule to perform automatic
checks of disk space at least once a day. The company has had problems with
running out of disk space on a routine basis, and they want to proactively
monitor the situation to ensure that it won’t happen again. How can you
accomplish this task?

2.A company’s Web server was recently upgraded with new Perl scripting code.
Since the upgrade, the server crashes at least twice a day. What can the Linux
administrator do to find and solve the problem?

Lab Exercises

Lab 12-1Configuring Network Interfaces

The objective for this hands-on lab is to gain experience in setting up network inter-
faces by using the ifconfigcommand. This example assumes that you have one
ethernet interface in the machine, and another machine on the network for testing
purposes. You should be able to use any default Linux installation for this exercise.

1.See what your current interface configuration looks like by using ifconfig.

ifconfig -a

2.In the output, there should be at least one ethernet interface, eth0, and possi-
bly a loopback interface, lo. If there is no loopback interface, create it by using
the following command:

ifconfig lo 127.0.0.1

Check to see if the loopback interface has been created by using the
ifconfig -acommand.

3.Now, set or change the IP address of the ethernet interface. The address is
192.168.1.1, and the subnet mask is 255.255.255.0.

ifconfig eth0 192.168.1.1 netmask 255.255.255.0

Check to see if the change worked by using the ifconfig -acommand.

4.To check that the interface is working, use the pingcommand to test the
address from another machine:

ping 192.168.1.1

5.Use the ifconfigcommand to disable the interface:

ifconfig eth0 down

Try pinging it again from another computer; you should not get a response.

404Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 404

405

6.Use the ifconfigcommand to enable the interface again:

ifconfig eth0 up

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

Lab 12-2Configuring Cron to Automate Tasks

The objective for this hands-on lab is to gain experience in using cronto 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
spaceat 1:05 p.m.

crontab -e

Now use vi to enter the croncommand:

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 -klcommand.

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.Cronis 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
fileby using the gzipcommand.

405

Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 405

3.The ifconfigcommand 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 mke2fsfor 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 atcommand differs from cronin that it can only be used to schedule a
job to run at one time. The croncommand allows you to set up a job that will
run at recurring times.

8.The fsckutility (File System Check) can scan your disk for errors, and actu-
ally 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 fdiskcommand is used to create partitions on a hard drive.

Assessment Questions

1.D. By invoking the mkfscommand, you actually run a program specific to
thefile system that you are creating, such as mke2fs to format using the
Linuxext2 file system. For review, see the “Disk and File System Manage-
ment” 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 crash-
ing. For review, see the “Core Dumps” section.

3.A. The administrator can select the loopback interface to configure by using
the ifconfig locommand. 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 cronentries 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
tararchive. To compress that archive, use the gzipcommand. For review,
see the “Installing System Packages and Patches” section.

406Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 406

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 loop-
back 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 parti-
tion 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 croncommand allows you to create recurring tasks. The atcommand
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 -Ucommand will update a currently existing package to the new
version. If the program doesn’t exist, rpmwill install the package. For review,
see the “Installing System Packages and Patches” section.

11.B. To enable an interface, use the ifconfig eth0 upcommand. 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, tarto extract the archive and
gunzipto 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 informa-
tion 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.

407

Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 407

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 atcommand. The croncommand 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 atcommand won’t be an efficient
method for performing the task in this situation. It is much easier to set up
cronto run a script that will check the disk space daily at 1:00 p.m. The out-
put will be e-mailed to the root account. You can compare the results from
dayto day to analyze disk space usage.

Your cronfile 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 him-
self 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.

408Chapter 12 ✦Study Guide

184881-6 ch12.F 11/12/01 8:31 AM Page 408

Process
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

13

13

CHAPTER

✦ ✦ ✦ ✦

194881-6 ch13.F 11/12/01 8:31 AM Page 409

410Part 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 initprocess?

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.✦

194881-6 ch13.F 11/12/01 8:31 AM Page 410

411

Chapter 13 ✦Process Management

Linux is a multi-user, multi-tasking operating system. Every time you run a pro-
gram under Linux, you begin what is known as a process. A process is another
name for a program that is run by a particular user. Depending on the processing
and memory resources on your particular machine, a large number of processes
can run simultaneously. Linux administrators must know what processes are run-
ning on their systems, and to what extent the processes are affecting system perfor-
mance. This chapter deals with the subject of how to view, manage, stop, and start
these processes.

The Linux administrator must also maintain system logs. The logs can provide
excellent troubleshooting information by reporting system errors, user logins, and
any unusual behavior that may affect the system. This chapter shows you where to
find the different types of logs and how to interpret their data. Finally, this chapter
also discusses the importance of documenting and maintaining the information on
your Linux system and its performance.

You're Reading a Free Preview

Descarregar
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->