cis52-Chap15
Download
Report
Transcript cis52-Chap15
Chapter 15
System
Administration
© 2000-2002 John Urrutia. All rights reserved.
1
Chapter 15
(Topics)
Background
The System Administrator & SuperUser
Types of Files
Description of System Operations
Important Files & Directories
© 2000-2002 John Urrutia. All rights reserved.
2
Chapter 15
(Topics)
System Administration
Day-to-day
Periodic
Preventing & Fixing Problems
Useful Utilities
Getting Help
© 2000-2002 John Urrutia. All rights reserved.
3
Background
Because 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
© 2000-2002 John Urrutia. All rights reserved.
4
The System Administrator
Responsible for:
The care and feeding of Linux.
Addition, Deletion and updates to all
system resources.
Disaster Recovery.
Users
© 2000-2002 John Urrutia. All rights reserved.
5
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.
© 2000-2002 John Urrutia. All rights reserved.
6
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
© 2000-2002 John Urrutia. All rights reserved.
7
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.
© 2000-2002 John Urrutia. All rights reserved.
8
Types of Files
Ordinary files contain all types of user
data
text, programs, scripts, etc.
Directory files contain information about
all files (as outlined on next slide)
Special files primarily for devices,
named pipes, and sockets
© 2000-2002 John Urrutia. All rights reserved.
9
Types of Files
Directory files contain information about all
files
Type, 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.
© 2000-2002 John Urrutia. All rights reserved.
10
Types of Files
Special files
By convention are stored in /dev directory and
represent devices.
Each device file is identified in the directory by a
type indicator:
b – block
c – character
d – directory
l – link
p – named pipe
s – socket
© 2000-2002 John Urrutia. All rights reserved.
11
Types of Files
Special files
By convention are stored in /dev directory
and represent devices.
fifo special files (aka Named Pipes)
first in first out
Allows any two processes to exchange info
and are treated just like files.
sockets – basis of networking facility
© 2000-2002 John Urrutia. All rights reserved.
12
Types of Files
Character and Block Special files
block and character devices fall into
categories identified by a device number
Major device number – Identify the category
of hardware represented by the device
Minor device number – Identify a specific
device of that category
Created by mknod
© 2000-2002 John Urrutia. All rights reserved.
13
Types of Files
Character 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 time
By the “line”
© 2000-2002 John Urrutia. All rights reserved.
14
System Operation
Description of operation
Booting the system
System operating modes
Logging In, Running and Logging Out
Bringing the system down
© 2000-2002 John Urrutia. All rights reserved.
15
System Operation
Booting the system
Process of initializing the hardware,
loading the operating system and allowing
users access in normal operation mode.
Power-up
Hardware self-checks
BIOS execution
Boot loader (lilo – linux loader)
© 2000-2002 John Urrutia. All rights reserved.
16
System Operation
Boot 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.
© 2000-2002 John Urrutia. All rights reserved.
17
System Operation
Boot loader (Continued)
Six phases to nirvana
Loading and initialize the kernel
Device detection and configuration
Creation of spontaneous system processes
Operator intervention (Manual Boot Only)
Execution of system startup scripts
Multi-user operations
© 2000-2002 John Urrutia. All rights reserved.
18
System Operation
System 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
© 2000-2002 John Urrutia. All rights reserved.
19
System Operation
Single 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
© 2000-2002 John Urrutia. All rights reserved.
20
System Operation
Multi User operations
Logging In
init 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
© 2000-2002 John Urrutia. All rights reserved.
21
System Operation
Multi User operations
Running
Enter command or exit / logout
Logging Out
Kills your login shell process
init receives the signal and cleans-up
© 2000-2002 John Urrutia. All rights reserved.
22
System Operation
Bringing 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 shutdown
Warns users before shutdown
© 2000-2002 John Urrutia. All rights reserved.
23
System Operation
Normal 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
© 2000-2002 John Urrutia. All rights reserved.
24
System Operation
Abnormal 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
© 2000-2002 John Urrutia. All rights reserved.
25
System Operation
System re-start after a crash
fsck utiltity checks and repairs the following
errors:
Inodes, blocks, and sizes
Directory structure
Directory connectivity
Reference counts
Note: filesystems must not be mounted
or mounted as readonly
If file integrity is okay – normal startup will
follow
© 2000-2002 John Urrutia. All rights reserved.
26
System Operation
If errors are detected and fixed
Notify file users to beware of missing or
inaccurate data.
Restore files from backups
© 2000-2002 John Urrutia. All rights reserved.
27
Important Files & Directories
/dev/null – the bit bucket
/var – frequently changed system files
System logs
/var/spool/cron – controls what interval
jobs are executed.
© 2000-2002 John Urrutia. All rights reserved.
28
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 devices
Controlled by mount and umount utility
© 2000-2002 John Urrutia. All rights reserved.
29
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)
© 2000-2002 John Urrutia. All rights reserved.
30
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 script
First script your shell runs after login
© 2000-2002 John Urrutia. All rights reserved.
31
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 changed
max: – max. # of day before password must change
warn: – days to warn of password expiration
inactive: – set acct. inactive after password expires
expire: – days since 1/1/70 when acct will expire
flag: – reserved for future use
© 2000-2002 John Urrutia. All rights reserved.
32
Important Files & Directories
Don’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
© 2000-2002 John Urrutia. All rights reserved.
33
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
© 2000-2002 John Urrutia. All rights reserved.
34
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
0
0
defaults
© 2000-2002 John Urrutia. All rights reserved.
35
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
© 2000-2002 John Urrutia. All rights reserved.
36
System Administration (Day to Day)
Backing Up Files – why bother
System malfunctions User indiscriminate deletions –
What to consider
How much work are you willing to lose?
How often are you willing to back-up files?
Time, storage media
Partial vs full backups
© 2000-2002 John Urrutia. All rights reserved.
37
System Administration (Day to Day)
What to use for backups
Type
Speed
Capacity
Cost
Slow
High
Low
CD-ROM,RW
Medium
Medium
Medium
Hard Drives
Fast
Medium
High
Removable
Medium
Low
Low
Tape
© 2000-2002 John Urrutia. All rights reserved.
38
System Administration (Day to Day)
Programs to use for backups
tar – 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
© 2000-2002 John Urrutia. All rights reserved.
39
System Administration (Day to Day)
tar – tape archive utility
Create an archive file
Add to an archive file
List archive file
Retrieve from archive file
tar option [modifiers] [file-list]
--create
--append
--list
--
--extract
--get
--update
© 2000-2002 John Urrutia. All rights reserved.
40
System Administration (Day to Day)
tar option [modifiers] [file-list]
--absolute-paths
--exclude filename
--file filename
--verbose
© 2000-2002 John Urrutia. All rights reserved.
41
System Administration (Day to Day)
crontab – Creates a list of scheduled tasks
The 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
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.
© 2000-2002 John Urrutia. All rights reserved.
42
System Administration
Periodic
Installing LINUX
Floppy
CD-ROM
Rescue Disks
© 2000-2002 John Urrutia. All rights reserved.
43
System Administration
Re-building the kernel
make config
make dep; make clean
make zlilo
© 2000-2002 John Urrutia. All rights reserved.
44
Preventing & Fixing Problems
When a User Cannot Log In
useradd
userdel
Usermod
Suspect files
/etc/passwd
.profile – .login – .bashrc
/etc/inittab
© 2000-2002 John Urrutia. All rights reserved.
45
Preventing & Fixing Problems
System logs
/var/log
Track various events in system
© 2000-2002 John Urrutia. All rights reserved.
46
Useful Utilities
Simple commands
du – disk usage
df – display filesystems
chsh – change your shell
mount – attaches a device to the system
Relies on the etc/fstab file for information
about the device to mount
© 2000-2002 John Urrutia. All rights reserved.
47
Useful Utilities
mount –t msdos /dev/fd0 /mnt
Mounts the floppy drive as a MSDOS
device with its root at the /mnt directory
© 2000-2002 John Urrutia. All rights reserved.
48
Getting Help
man pages
Info pages
© 2000-2002 John Urrutia. All rights reserved.
49