+ All Categories
Home > Documents > 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

Date post: 20-Jan-2016
Category:
Upload: bertha-mclaughlin
View: 215 times
Download: 0 times
Share this document with a friend
49
1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration
Transcript
Page 1: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

1© 2000-2002 John Urrutia. All rights reserved.

Chapter 15

System

Administration

Page 2: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

2© 2000-2002 John Urrutia. All rights reserved.

Chapter 15 (Topics)Background

The System Administrator & SuperUser

Types of Files

Description of System Operations

Important Files & Directories

Page 3: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

3© 2000-2002 John Urrutia. All rights reserved.

Chapter 15 (Topics)System Administration

Day-to-day

Periodic

Preventing & Fixing Problems

Useful Utilities

Getting Help

Page 4: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

4© 2000-2002 John Urrutia. All rights reserved.

BackgroundBecause of Linux’s flexibility to operate on

many platforms with a large diversity of hardware this chapter offers an overview of fundamentals that apply to all Linux Systems

We look at some tools used in administration

Kernel construction and re-configuration

Disaster Recovery

Page 5: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

5© 2000-2002 John Urrutia. All rights reserved.

The System Administrator Responsible for:

The care and feeding of Linux.

Addition, Deletion and updates to all system resources.

Disaster Recovery.

Users

Page 6: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

6© 2000-2002 John Urrutia. All rights reserved.

The System Administrator root aka The SuperUser

Has total and complete access to all system functions and data.

SuperUser Login from:system console or any terminal by using

Substitute User (su) command

sudo allows specific command privileges to normal users.

Page 7: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

7© 2000-2002 John Urrutia. All rights reserved.

The System Administrator When you use su to login as root

generally your command line prompt will show a pound sign (#) instead of a dollar sign ($)

To return to a normal user type exit or Ctrl+d

Page 8: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

8© 2000-2002 John Urrutia. All rights reserved.

The System Administrator Most System Administration tools are

located in these directories/sbin

/usr/sbin

When executing these tools specify the absolute pathname! Don’t rely on the $PATH because of security considerations.

Page 9: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

9© 2000-2002 John Urrutia. All rights reserved.

Types of FilesOrdinary files contain all types of user

datatext, programs, scripts, etc.

Directory files contain information about all files (as outlined on next slide)

Special files primarily for devices, named pipes, and sockets

Page 10: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

10© 2000-2002 John Urrutia. All rights reserved.

Types of FilesDirectory files contain information about all

filesType, Permissions, Links, Owner, Group, Size,

Name

Date & Time of: - creation, update, access

Inode: internal number that the file is known as to the system. Owner, size, where located, link count & other attributes.

Page 11: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

11© 2000-2002 John Urrutia. All rights reserved.

Types of FilesSpecial files

By convention are stored in /dev directory and represent devices.

Each device file is identified in the directory by a type indicator:b – blockc – characterd – directory l – linkp – named pipes – socket

Page 12: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

12© 2000-2002 John Urrutia. All rights reserved.

Types of FilesSpecial files

By convention are stored in /dev directory and represent devices.

fifo special files (aka Named Pipes) first in first outAllows any two processes to exchange info

and are treated just like files.

sockets – basis of networking facility

Page 13: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

13© 2000-2002 John Urrutia. All rights reserved.

Types of FilesCharacter and Block Special files

block and character devices fall into categories identified by a device numberMajor device number – Identify the category

of hardware represented by the deviceMinor device number – Identify a specific

device of that category

Created by mknod

Page 14: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

14© 2000-2002 John Urrutia. All rights reserved.

Types of FilesCharacter and Block Special files

The standard block devices on a Linux system are disk drives.

Anything that is not a block device is considered a character device.Printers, terminal, keyboards, modems.Data can be read:

in raw mode one character at a timeBy the “line”

Page 15: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

15© 2000-2002 John Urrutia. All rights reserved.

System OperationDescription of operation

Booting the system

System operating modes

Logging In, Running and Logging Out

Bringing the system down

Page 16: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

16© 2000-2002 John Urrutia. All rights reserved.

System OperationBooting the system

Process of initializing the hardware, loading the operating system and allowing users access in normal operation mode.Power-upHardware self-checksBIOS executionBoot loader (lilo – linux loader)

Page 17: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

17© 2000-2002 John Urrutia. All rights reserved.

System OperationBoot loader

(what St. Nicholas of Myra does)Master Boot Record

First block(s) of data on the hardware specified start-up disk.

lilo is the initial program used to locate, load, and run the operating system kernel.

Page 18: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

18© 2000-2002 John Urrutia. All rights reserved.

System OperationBoot loader (Continued)

Six phases to nirvanaLoading and initialize the kernelDevice detection and configurationCreation of spontaneous system processes

Operator intervention (Manual Boot Only)

Execution of system startup scriptsMulti-user operations

Page 19: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

19© 2000-2002 John Urrutia. All rights reserved.

System OperationSystem operating modes

System Halt – run level 0

Single-User – run level 1 - S

Multi-User – run level 2 - 3

X-windows – run level 5

Reboot – run level 6

Undefined – run level 4, 7 - 9

Page 20: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

20© 2000-2002 John Urrutia. All rights reserved.

System OperationSingle User Mode

This mode is generally used for maintenance or problem solving.

During the boot process this mode is used: To do file system integrity checks.Start the init process and run inittab, rc.M

Page 21: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

21© 2000-2002 John Urrutia. All rights reserved.

System OperationMulti User operations

Logging Ininit spawns mingetty to capture the terminal

login and display the login message, mingetty identifies the terminal type at login and overlays itself with the login process, validates password, initializes your environment

Page 22: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

22© 2000-2002 John Urrutia. All rights reserved.

System OperationMulti User operations

RunningEnter command or exit / logout

Logging OutKills your login shell processinit receives the signal and cleans-up

Page 23: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

23© 2000-2002 John Urrutia. All rights reserved.

System OperationBringing the system down

shutdown brings the system down in an orderly fashion. And it can:Change the mode of system operation.Schedule the time to shutdownWarns users before shutdown

Page 24: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

24© 2000-2002 John Urrutia. All rights reserved.

System OperationNormal shutdown does the following

wall – warns users to logout

/etc/nologin created to prevent new logins

kill – issued for all processes

sync; sync – finish writing buffers

umount -a – dismount all filesystems

telinit -s – set single user mode

Page 25: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

25© 2000-2002 John Urrutia. All rights reserved.

System OperationAbnormal shutdown or crashes

System halts without cleanup

Status of system is unpredictable

May have one or more core dumps

System must be restarted with caution

Page 26: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

26© 2000-2002 John Urrutia. All rights reserved.

System OperationSystem re-start after a crash

fsck utiltity checks and repairs the following errors: Inodes, blocks, and sizesDirectory structureDirectory connectivityReference counts

Note: filesystems must not be mounted or mounted as readonly

If file integrity is okay – normal startup will follow

Page 27: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

27© 2000-2002 John Urrutia. All rights reserved.

System OperationIf errors are detected and fixed

Notify file users to beware of missing or inaccurate data.

Restore files from backups

Page 28: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

28© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/dev/null – the bit bucket

/var – frequently changed system filesSystem logs

/var/spool/cron – controls what interval jobs are executed.

Page 29: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

29© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/etc/group – contains the user groups

allowing members to share data files.newgrp – spawns shell under new group

id – will show uid, current gid and groups

/etc/mtab – list of all mounted devicesControlled by mount and umount utility

Page 30: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

30© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/etc/passwd – identifies system users

login-name: – your login id (ie. jurrutia)

password: – the encrypted password

user id number: – the internal UID

group id number: – the default GID

comment: – whatever you want

directory: – absolute pathname to home

program – default login program to run (bash)

Page 31: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

31© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/etc/passwd – example

root:x:0:0:Root of all:/:/bin/sh

mpress:x:521:0:M Press:/home/mpress:/bin/bash

who:x:1000:1000:Ex who & leave:/usr:/usr/bin/who

/etc/profile – the shell login scriptFirst script your shell runs after login

Page 32: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

32© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/etc/shadow – stores encrypted passwords and

other user info. Only accessible by root. login-name: – your login id (ie. jurrutia)password: – the encrypted password last modified: – modification date (days since 1/1/70)min: – min. # of day before password can be changedmax: – max. # of day before password must changewarn: – days to warn of password expiration inactive: – set acct. inactive after password expiresexpire: – days since 1/1/70 when acct will expire flag: – reserved for future use

Page 33: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

33© 2000-2002 John Urrutia. All rights reserved.

Important Files & DirectoriesDon’t try (modifying) this at home!

/etc/shadow – is modified by:passwd – change password

useradd – add a new user

usermod – change existing user

userdel – delete a user

Page 34: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

34© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/etc/fstab – file system table identifies all

the file systems available to the system. It contains 6 fields (white space delimited):Block device name

Mount point

Filesystem or device type

Mounting option

Filesystem backup (when to run dump utility)

fsck order to check

Page 35: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

35© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories#Device Mountpoint FS Type Options Dump Pass#

LABEL=/ / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

LABEL=/home /home ext3 defaults 1 1

/dev/fd0 /mnt/floppy auto noauto,owner 0 0

none /proc proc defaults 0 0

none /dev/shm tmpfs defaults 0 0

none /dev/pts devpts gid=5,mode=620 0 0

/dev/hda6 swap swap defaults 0 0

/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0

/home/SWAP swap swap defaults 0 0

Page 36: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

36© 2000-2002 John Urrutia. All rights reserved.

Important Files & Directories/vmlinuz – The LINUX system kernel

The z indicates the kernel is in a compressed format. Generally the last character is x .

/sbin/shutdown – Shutdown Program Program to bring the system down

Page 37: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

37© 2000-2002 John Urrutia. All rights reserved.

Backing Up Files – why botherSystem malfunctions -

User indiscriminate deletions –

What to considerHow much work are you willing to lose?

How often are you willing to back-up files?

Time, storage media

Partial vs full backups

System Administration (Day to Day)

Page 38: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

38© 2000-2002 John Urrutia. All rights reserved.

System Administration (Day to Day)

What to use for backups Type Speed Capacity Cost

Tape Slow High Low

CD-ROM,RW Medium Medium Medium

Hard Drives Fast Medium High

Removable Medium Low Low

Page 39: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

39© 2000-2002 John Urrutia. All rights reserved.

Programs to use for backupstar – tape archive utility

cpio – copy in and Out directory trees to archive (antiquated)

afio – Copy and restore directory trees to archival files

taper – A user friendly backup and restore utility

System Administration (Day to Day)

Page 40: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

40© 2000-2002 John Urrutia. All rights reserved.

tar – tape archive utilityCreate an archive file

Add to an archive file

List archive file

Retrieve from archive file

tar option [modifiers] [file-list] --create --append --update

--list --

--extract --get

System Administration (Day to Day)

Page 41: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

41© 2000-2002 John Urrutia. All rights reserved.

tar option [modifiers] [file-list]--absolute-paths

--exclude filename

--file filename

--verbose

System Administration (Day to Day)

Page 42: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

42© 2000-2002 John Urrutia. All rights reserved.

crontab – Creates a list of scheduled tasksThe cron table created contains 6 fields

Minutes 0 thru 59

Hours 0 thru 23

Day of Month 1 thru 31

Month of year 1 thru 12

Day of week 0 thru 6

System Administration (Day to Day)

The values can be combinations of absolutes and ranges. Each field is IFS delimited.

All cron files are stored in the

/var/spool/cron/crontabs

Directory.

Page 43: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

43© 2000-2002 John Urrutia. All rights reserved.

System AdministrationPeriodic

Installing LINUXFloppy

CD-ROM

Rescue Disks

Page 44: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

44© 2000-2002 John Urrutia. All rights reserved.

System AdministrationRe-building the kernel

make config

make dep; make clean

make zlilo

Page 45: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

45© 2000-2002 John Urrutia. All rights reserved.

Preventing & Fixing ProblemsWhen a User Cannot Log In

useradd

userdel

Usermod

Suspect files/etc/passwd

.profile – .login – .bashrc

/etc/inittab

Page 46: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

46© 2000-2002 John Urrutia. All rights reserved.

Preventing & Fixing Problems

System logs/var/log

Track various events in system

Page 47: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

47© 2000-2002 John Urrutia. All rights reserved.

Useful UtilitiesSimple commands

du – disk usage

df – display filesystems

chsh – change your shell

mount – attaches a device to the systemRelies on the etc/fstab file for information

about the device to mount

Page 48: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

48© 2000-2002 John Urrutia. All rights reserved.

Useful Utilitiesmount –t msdos /dev/fd0 /mnt

Mounts the floppy drive as a MSDOS device with its root at the /mnt directory

Page 49: 1 © 2000-2002 John Urrutia. All rights reserved. Chapter 15 System Administration.

49© 2000-2002 John Urrutia. All rights reserved.

Getting Help

man pages

Info pages


Recommended