hp education services hp education services 1 hp world/interex 2002 linux system maintenance...

27
1 hp education services education.hp.com hp education services education.hp.com HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734) 805-2172 [email protected] George Vish II (404) 648-6403 [email protected]

Upload: sheila-henry

Post on 18-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

© 2002 Hewlett-Packard Company U2794S A.00 3 The Software Package Concept Steps for loading software: Manually load and relocate files and directories. Extract file structure from an archive. Relocate and configure files by hand. Run any provided scripts or utilities. Configure start-up scripts. OR Use a package manager to install the software.

TRANSCRIPT

Page 1: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

1

hp education serviceseducation.hp.com

hp education serviceseducation.hp.com

HP World/Interex 2002

Linux SystemMaintenance Basics

Chris Cooper(734) 805-2172

[email protected] Vish II

(404) [email protected]

Page 2: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

2

hp education serviceseducation.hp.com

hp education serviceseducation.hp.com

Software Package

ManagementRPM and DPKG

Version A.00U2794S Module 12 Slides

Page 3: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

3 © 2002 Hewlett-Packard Company

U2794S A.00

The Software Package Concept

Steps for loading software: • Manually load and relocate files and directories.• Extract file structure from an archive.• Relocate and configure files by hand.• Run any provided scripts or utilities.• Configure start-up scripts. OR• Use a package manager to install the software.

Page 4: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

4 © 2002 Hewlett-Packard Company

U2794S A.00

Of Packages and Kings

Package management is a method for storing a set of related files and directories in a single archive file, along with installation scripts. When the “package” is installed, its files will be relocated on the target system, the scripts run. There have been several package managers developed to date:

• RedHat Package Manager• Debian Package Manager• Slackware Package Manager• Stampede Package Manager

Page 5: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

5 © 2002 Hewlett-Packard Company

U2794S A.00

Package Management

The role of the package manager is to provide a consistent means to work

with packaged software. Packages can be created as either a binary or a

source package. The key actions of a package manager are to:• Install• Remove• Upgrade | Freshen• Query | List• Verify• BuildThe above actions must be performed while dealing withpackage-to-package dependencies, hardware, disk space, and

securityrequirements.Once packaged, software can easily be transported and loaded

onto targetsystems.

Page 6: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

6 © 2002 Hewlett-Packard Company

U2794S A.00

Install and Remove• Install — Load a new package: # rpm -i name.version-release.architecture.rpm

name name of software packageversion software version number, such as 2.1.13 or 1.0release package release numberarchitecture defines the hardware platform on which the

bits will function• Upgrade , Update an existing, or install a new package:# rpm -U name.version-release.architecture.rpm

• Freshen , Update an existing package only: # rpm -F name.version-release.architecture.rpm

• Remove , Remove an installed package:# rpm -e name

Page 7: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

7 © 2002 Hewlett-Packard Company

U2794S A.00

Query and Verify

• Query — list the packages currently present on the system: # rpm -qi <package-name>

• Verify — examine the current status of installed packages and compare them to the original installation # rpm -V <package-selection-option>

Page 8: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

8 © 2002 Hewlett-Packard Company

U2794S A.00

Rebuilding a Package

Binary packages can be rebuilt from source packages. The following command builds a new binary package, and stores it in the /usr/src/redhat/RPMS/i386/ directory:

# rpm --rebuild name.version-release.architecture.src.rpm

The following command will compile the code, and install the named package:

# rpm --recompile name.version-release.architecture.src.rpm

Page 9: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

9 © 2002 Hewlett-Packard Company

U2794S A.00

Additional Tools and Utilities

• GnoRPM• AutoROM• Glitter• Apt• Gnome Apt• Kpackage• Alien

Page 10: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

10 © 2002 Hewlett-Packard Company

U2794S A.00

Debian Equivalent Commands

dpkgrpm

The rpm command line # rpm -i name.rpm # rpm -U name.rpm # rpm -e name.rpm # rpm -qi name.rpm # rpm -i name.src.rpm # rpm -bb <spec-file>

The dpkg command line

# dpkg -i name.deb# dpkg -i name.deb# dpkg -r name.deb# dpkg -print-avail name.deb# dpkg-source -x name.dsc# dpkg-deb -b <src dir> \ --build <target dir>

Page 11: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

11

hp education serviceseducation.hp.com

hp education serviceseducation.hp.com

Securing Your Linux

System

Version A.00U2794S Module 19 Slides

Page 12: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

12 © 2002 Hewlett-Packard Company

U2794S A.00

Pluggable Authentication Modules

• PAM is a set of library programs used to authenticate users.• It provides for:

– Authentication, such as asking for a password– Account checking — account is still valid, login time ok ...– Password setting and changing– Session checking when user is authenticated

– Are certain actions allowed for this user?• Functions are implemented using library modules.

– Can be stacked• PAMs are controlled and configured for individual programs

through the /etc/pam.d configuration directory.– Every controlled service is identified by a file. The file name

is the program name.

Page 13: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

13 © 2002 Hewlett-Packard Company

U2794S A.00

PAM Service File

• A PAM service file contains configuration information for a restricted service.

• The file contains three fields.• In some files, you may find a fourth field for optional

arguments. • The fields are:

– Module type – Control flag– Module path– Arguments

Page 14: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

14 © 2002 Hewlett-Packard Company

U2794S A.00

Module Type

• The PAM standard defines four types of modules:

– The auth type is establishes that users are who they claim to be.

– The account type checks to see if a user is allowed to use a service.

– The password type updates authentication tokens. – The session type performs certain actions when the

user logs in or logs out.

Page 15: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

15 © 2002 Hewlett-Packard Company

U2794S A.00

Control Flag

• Requisite: if a service returns a failure, no other modules will be evaluated.

• Required: if a particular module fails, other modules of the same type will still execute.

• Sufficient: if no other module of this type has failed, then the success of the module is sufficient to guarantee that security requirements have been met.

• Optional: PAM ignores the module failure and continues processing the next module in sequence.

Page 16: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

16 © 2002 Hewlett-Packard Company

U2794S A.00

Module Path

• The compiled-in modules are located in the /lib/security directory.

• Modules interface with the file or device that gives the SUCCESS, FAILURE, or ignore to authentication.

• PAM then passes either SUCCESS or FAILURE to the service requesting the information.

• Modules can be stacked, requiring more than one type of authentication, or allowing any of several types.

Page 17: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

17 © 2002 Hewlett-Packard Company

U2794S A.00

Optional Arguments

• Some modules can receive specific options. It is up to the module to parse and interpret the options.

• This field can be used by the module to turn on debugging or to pass any module-specific parameters, such as a timeout value.

• System administrators can use the option field to fine tune the PAM modules.

Page 18: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

18 © 2002 Hewlett-Packard Company

U2794S A.00

Examples

• Example 1: Blocking Anyone to su to rootexcept members of wheel

Add the following two lines to the top of the su file:

auth sufficient /lib/security/pam_wheel.so trust use_uidauth required /lib/security/pam_wheel.so use_uid

• Example 2: Setting Linux System Resource LimitsAdd the following line to the bottom of the login file and

then edit the /etc/security/limits.conf file:

session required /lib/security/pam_limits.so

Page 19: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

19 © 2002 Hewlett-Packard Company

U2794S A.00

TCP Wrappers

Provides protection around TCP/IP service’saccess control logging

xinetd | inetd

IP stack

<- frame ->

direct

tcpwrappers

/etc/hosts.allow

DeniedAllowed

logging

?

Page 20: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

20 © 2002 Hewlett-Packard Company

U2794S A.00

Linux’s ipchains - iptables

IPCHAINS operation:

Input Chain

Routing Decision

Forward Chain

Output Chain

Demasquerade

Accept

Deny/Reject

Deny/Reject

Deny/Reject

Local Process

Using lo interface

Accept/Redirect

Incomingtraffic

Checksum ok ?

Deny

FurtherchecksDeny

Page 21: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

21

hp education serviceseducation.hp.com

hp education serviceseducation.hp.com

Recovering a Non-BootableLinux System

Version A.00U2794S Module 20 Slides

Page 22: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

22 © 2002 Hewlett-Packard Company

U2794S A.00

Normal Boot Process

. . .. . .. . .

sbin bootetc

/hda3

hda2SWAP

hda1 /

vmlinuz

Logical File/Disk Structure after boot

hda1/

vmlinuz

hda3

. . .. . .. . .

sbin bootetc

/

Physical File/Disk Structure

Page 23: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

23 © 2002 Hewlett-Packard Company

U2794S A.00

Kernel Corrupt or Missing

• The kernel is usually named /boot/vmlinuz (compressed).– If the kernel is uncompressed, its name is /boot/vmlinux.

• If the kernel is deleted by accident, boot from the rescue floppy created at installation time.

• After boot, mount /boot to a temporary location.# mount /dev/hda2 /mnt/broken_boot_fs

• Copy the kernel from the rescue floppy to /boot/vmlinuz (or other appropriate kernel name).

• Reboot with the restored kernel.• Configure and recompile a new kernel, if necessary.

Page 24: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

24 © 2002 Hewlett-Packard Company

U2794S A.00

Third-Party Rescue Disks

• The rescue floppy won’t work if important parts of the system (like /etc or /usr) are damaged.

• For more extensive repairs, you need a “tiny Linux distribution” that is customized for this purpose.

• These “repair kits” come with tools like fsck and network support.

• Examples:– MuLinux– Trinux– Tom’s Root Boot

• Some recent distributions provide “rescue disk” capabilities on their installation CD (ie. Red Hat 7.2)

Page 25: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

25 © 2002 Hewlett-Packard Company

U2794S A.00

Back Up Your Data!

• Backups are critical for the operation of your system, because of:– user error, administrative errors, hardware failure, software failure,

destructive break-ins, theft, disaster, and archival needs.• Backup:

– user files, log files, important system directories, your RPM database• Use consistent backup strategy:

– Weekly or monthly full backup– Daily partial backup cycle

• Very common to use tar– Commercial products are available

Page 26: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

26 © 2002 Hewlett-Packard Company

U2794S A.00

Backup Strategies for /boot• Backups are important!

– Use reliable and supported media.– Schedule backups regularly and DO THEM!

• Backing up with tar:

# tar --create --file /dev/st0 /usr/bootor # tar -cf /dev/st0 /usr/boot

# tar -cMf /dev/fd0H1440 /usr/boot(for multiple floppy disk volumes)

# tar --compare --verbose -f /dev/st0 /dev/bootor tar -cvf /dev/st0 /dev/boot

(to compare the backup against the original data)

Page 27: Hp education services   hp education services   1 HP World/Interex 2002 Linux System Maintenance Basics Chris Cooper (734)

27 © 2002 Hewlett-Packard Company

U2794S A.00

Restoring Files with tar• Extract files from a tar backup archive:

# tar --extract --same-permissions --verbose --file /dev/st0or # tar -xpvf /dev/st0

• List files in an archive:

# tar --list --file /dev/st0or # tar -lf /dev/st0

• Extract specific files from an archive:

# tar xpvf /dev/st0 \usr/src/linux-1.2.10-includes/include/linux/hdreg.h \usr/src/linux-1.2.10-includes/include/linux/hdreg.h