View
215
Download
0
Category
Preview:
Citation preview
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
3© 2000-2002 John Urrutia. All rights reserved.
Chapter 15 (Topics)System Administration
Day-to-day
Periodic
Preventing & Fixing Problems
Useful Utilities
Getting Help
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
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
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.
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
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.
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
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.
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
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
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
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”
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
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)
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.
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
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
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
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
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
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
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
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
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
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
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.
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
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)
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
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
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
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
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
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
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)
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
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)
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)
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)
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.
43© 2000-2002 John Urrutia. All rights reserved.
System AdministrationPeriodic
Installing LINUXFloppy
CD-ROM
Rescue Disks
44© 2000-2002 John Urrutia. All rights reserved.
System AdministrationRe-building the kernel
make config
make dep; make clean
make zlilo
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
46© 2000-2002 John Urrutia. All rights reserved.
Preventing & Fixing Problems
System logs/var/log
Track various events in system
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
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
49© 2000-2002 John Urrutia. All rights reserved.
Getting Help
man pages
Info pages
Recommended