Title: DT2283 Computer Systems Architecture and Administration
1DT228-3Computer SystemsArchitecture and
Administration
- Mark Deegan
- Mark.Deegan_at_comp.dit.ie
- Room K115a
2Aims of the CSAA Course
- To introduce the student to the general
principles of computer systems administration.
(S1) - To equip the student with sufficient
understanding of the architecture of computer
systems to allow them to support systems
administration activities. (S1)
3Aims of the CSAA Course
- To provide a greater depth of knowledge of
systems design and administration tasks. (S2) - To give hands on experience of applying systems
administration techniques. (S2)
4Learning Outcomes
- On completion of the course the student will
- Have a broad understanding of Systems
Architecture and Administration - Be capable of analysing the architecture of a
computer system and of understanding the effects
of different architectural features on system
administration. - Be able to perform basic system administration
tasks. - Appreciate the protocols and policies of system
administration
5Examination
- Semester 1
- Written Examination 70
- Continuous Assessment(3 Assignments) 30
- Semester 2
- Written Examination 70
- Continuous Assessment(3 Assignments) 30
6Reading List
- Essential Reading
- Running Linux
- Matt WELSH
- OReilly UK
- Background Reading
- Linux System Administration A Users Guide
- Marcel GAGNE
- Addison Wesley
- Linux System Administration Guide
- WIRZENIUS and OJA
7Reading List
- Computer Organisation and Architecture
- William STALLINGS
- Prentice Hall
- Upgrading and Repairing PCs
- Scott MEULLER
- QUE
- Hardware Bible
- Winn L ROCHE
- QUE
8CSAA Semester 1 Overview
9CSAA Semester 1 Overview
- Essential Tasks of the System Administrator
- Booting and Shutting Down
- Controlling Processes
- File Systems
- UNIX User Management
- Windows User Management
10CSAA Semester 1 Overview
- Logon Procedures
- Log Files
- Printing
- Network Configuration
- Performance Analysis
- UNIX Windows Co Operation
11CSAA Semester 2 Overview
12CSAA Semester 2 Overview
- Disk Management
- Backups
- Drivers and the Kernel
- Performance Analysis
- Planning and Configuring Network Services
13CSAA Semester 1 Details
14Essential Tasks of the System Administrator
- Adding Removing Users
- Adding and Removing Hardware
- Performing Backups
- Installing New Software
- Monitoring the System
- Managing System Resources
- CPU, memory, disk I/O, disk space
- Troubleshooting
15 Essential Tasks of the System Administrator
- Maintaining local documentation
- Security
- Contingency Planning
- Disaster Recovery
- Helping Users
16Booting Shutting Down
- Bootstrapping
- Automatic Manual Booting
- Steps in the Boot Process
- Kernel Initialisation
- Hardware Configuration
- System Processes
- Scripts
- Startup Scripts
17 Booting Shutting Down
- Rebooting Shutting Down
- Turning Off the Power
18Controlling Processes
- Components of a Process
- PID Process ID Number
- PPID Parent PID
- UID User ID
- EUID Effective User ID
- GID Group ID
- EGID Effective Group ID
- Niceness
- Control Terminal
19 Controlling Processes
- The Lifecycle of a Process
- Sending Signals to Processes
- Process States
- Nice and Renice
- Process Priority
- ps
- Monitoring processes
- top
- Runaway Processes
20The File System
- Pathnames
- Mounting and Unmounting File Systems
- The Organisation of the File Tree
- File Types
- Regular Files
- Directory Files
- Character and Block Special Files
21The File System
- UNIX Domain Sockets
- Named Pipes
- Symbolic Links
- File Attributes
- The setuid and setgid bits
- The Sticky bit
- Permission bits
22The File System
- Viewing File Attributes
- Free BSD Bonus Flags
- Chmod Change Mode
- Chown Change Ownership
- Chgrp Change Group
- Umask Default Permissions
- Default Permissions
23UNIX User Management
- The /etc/passwd file
- Login name
- Encrypted password
- UID Number
- Default GID Number
- GECOS Field
- Home Directory
- Login Shell
24UNIX User Management
- Setting an Initial Password
- Creating users home directory
- Copying in the default startup files
- Setting the users mail home
- Editing the /etc/group file
- Setting Disk Quotas
- Verifying the New Login
25UNIX User Management
- Removing Users
- Disabling Logins
- Vendor Supplied Account Management Utilities
26Windows User Management
- LDAP Protocol
- Microsoft Active Directory
- Novell Active Directory
- Open LDAP
- User Account Creation
- User Management Tools
- Domain Structures
27Logon Procedures
- UNIX Logon Procedures
- Character Mode
- Graphical More
- Dtlogin on Solaris and other UNIX variants
- Windows Logon Procedures
- Windows Telnet Services
- Windows Terminal Services
28Log Files
- Logging Policies
- Disposal of Log Files
- Rotating Log Files
- Archiving Log Files
- Finding Log Files
- Condensing Log Files to Useful Information
29Printing
- Types of Printers
- Serial Parallel Printers
- Network Printers
- Configuring the Printing Environment
- Controlling Spooling
- Controlling a Printer
- Adding a Printer
- Debugging Printer Problems
30Network Configuration
- Configuring clients on an IP Network
- Static IP
- DHCP
- Bootp
- DNC Client configuration
31Performance Analysis
- Optimising Performance
- Factors influencing performance
- System Performance Checkup
- Analysing CPU Performance
- How UNIX Manages Memory
- Analysing Memory Usage
- Analysing Disk I/O
- Procinfo
32Performance Analysis
- Displaying Red Hat Performance Data
- Print random Free bsd statistics
33Cooperating with Windows
- File and Print Sharing
- The Netwok File System
- CIFS The Common Internet File System
- Samba CIFS For UNIX
- Installing and Configuring SAMBA
- Debugging Samba
- Secure Terminal Emulation with SSH
- XWindows Emulators
34Cooperating with Windows
- PC Mail Clients
- PC Backups
- Dual Booting
- Running Windows Applications under UNIX
- PC Hardware Tips
35CSAA Semester 2 Details
36Drivers and the Kernel
- Kernel Types
- Configuring a Kernel
- Build the Kernel
- Install the New Kernel
- Test The New Kernel
- Document the New Kernel
- Configuration File
37Drivers and the Kernel
- Adding Device Drivers
- Device Numbers
- Device Files
- Naming Conventions for Devices
- Loadable KernelModules
38Adding a Disk
- Disk Interfaces
- SCSI
- IDE
- SATA
- USB
- Disk Geometry
39Adding a Disk
- Disk Installation Procedure
- Connecting the Disk
- Creating Device Entries
- Mounting a file system
- Formatting the disk
- Labelling and partitioning the disk
- Establishing logical volumes
40Adding a Disk
- Software RAID
- Hardware RAIS
- Network Area Storage (NAS)
- Storage Area Networks (SANs)
41Backups
- Labelling Tapes
- Selecting a backup Interval
- Comparison of file systems
- Making file systems smaller than the backup
device - Protection of Backups
- Checking Backup Tapes
- Developing a tape life cycle
42Backups
- Designing data for backups
- Backup devices and media
- Setting up an incremental Backup Regime
- Dumping file systems
- Restoring individual files
- Restoring entire file systems
- Dumping and restoring for upgrades
- Commercial backup suites
- ArcServe, Veritas
43Planning and Configuring Network Services
- Firewall
- SSHD
- BIND
- NIS
- DHCP
- OpenLDAP
- SaMBa
44Lecture 1UNIX User Management
- Essentials tasks of the System Administrator
- Adding/Removing Users
- UNIX Traditionally, user account details are
stored in the /etc/passwd file (/etc/group,
/etc/shadow) - This file has the format
- usernamepassworduidgidcommenthome dirshell
- one way to get a list of usernames on a system
- cut d -f1 /etc/passwd
- Do not edit this file directly, use
- useradd / userdel / groupadd / groupdel commands
45useradd (linux)
- Create a new user or update default new user
information - useradd -c comment -d home_dir
- -e expire_date -f
inactive_time - -g initial_group -G
group,... - -m -k skeleton_dir -M -n
-o -p passwd -r - -s shell -u uid login
- useradd -D -g default_group -b default_home
- -e default_expire_date -f
default_inactive - -s default_shell
- The D option causes system defaults specified in
/etc/login.defs to be used for this account
creation
46userdel
- Delete a user account and related files
- userdel -r login
- The userdel command modifies the system
account files, deleting all entries that refer to
login. The named user must exist. The options
which apply to the userdel command are - -r Files in the users home directory will
be removed along with the home directory itself
and the users mail spool. Files located
in other file systems will have to be searched
for and deleted manually.
47groupadd (linux)
- Create a new group
- groupadd -g gid -o -r -f group
- Creates a new group account using the values
specified on the command line and the default
values from the system. - The new group will be entered into the system
files as needed. - Options
- -g gid The numerical value of the groups ID.
This value must be unique, unless the -o option
is used. The value must be non-negative. The
default is to use the smallest ID value greater
than 500 and greater than every other group.
Values between 0 and 499 are typically reserved
for system accounts.
48groupadd (linux)
- -r instructs groupadd to add a system
account. The first available gid lower than 499
will be automatically selected unless the -g
option is also given on the command line. - -f the force flag. This will cause groupadd
to exit with an error when the group about to
be added already exists on the system. If that is
the case, the group wont be altered (or
added again). - Also modifies the way -g option works. When you
request a gid that it is not unique and you dont
specify the o option too, the group creation
will fall back to the standard behavior (adding a
group as if neither -g or o options were
specified).
49groupdel (linux)
- Delete a group
- groupdel group
- The groupdel command modifies the system
account files, deleting all entries that refer to
group. The named group must exist. - You must manually check all filesystems to insure
that no files remain with the named group as the
file group ID.
50groupdel (linux)
- Delete a group
- groupdel group
- The groupdel command modifies the system
account files, deleting all entries that refer to
group. The named group must exist. - You must manually check all filesystems to insure
that no files remain with the named group as the
file group ID.
51Managing Users
- Whether in the UNIX or Windows (or other)
environment, it is best practice to manage users,
where possible, on a per-group basis - Wherever possible, settings and configurations
should be managed on a per-group basis - For this reason, the management of group settings
is as important in any multi-user environment as
is the management of individual settings
52Managing Groups
- One approach to the management of groups is a
hierarchical approach, whereby the user community
is divided into a number of groups based on roles
within the organisation - In this way, an individual may belong to several
groups, each of which may have a different
combination of security settings etc. - If we can be assured users have only setting
which are assigned on a per-group basis, it
becomes easier for us to ensure that all users
with similar or identical roles are subject to
the same rules
53Lecture 2Windows User Management
- Brief History of Windows Server Platforms
- Server Message Block (SMB) Protocol
- Windows net commands
54Managing Users and Groups in the Windows
Environment
- Since the arrival of Microsoft/IBMs Lan Server
application in the late 1980s, Microsoft have
provided a network server platform based on the
SMB (Server Message Block) protocol - The management tools and the features of these
server platforms have changed somewhat over the
years, but remain broadly the same
55History
- Lan Manager
- Windows for WorkGroups
- Windows NT
- Windows Server 2000
- Windows Server 2003
56Similarities between SMB based platforms
- Due to the similarities which exist between the
various SMB based platforms, some knowledge of
how to manage an SMB platform will serve will in
many situations - One of the most powerful SMB commands is the net
command discussed later
57Net command
- In the Microsoft Windows environment, the net
command accepts a wide range of sub commands to
achieve many varied tasks
58Net sub-commands
- accounts, computer config, continue, file, group,
help, helpmsg, localgroup, name, pause, print,
send, session, share, start, statistics, stop,
time, use, user, view - Many of these, in turn, have further sub commands
59Net accounts
- Updates the user accounts database and modifies
password and logon requirements for all accounts.
The Net Logon service must be running on the
computer for which you want to change account
parameters. - net accounts /forcelogoffminutes no
/minpwlenlength /maxpwagedays unlimited
/minpwagedays /uniquepwnumber /domain - net accounts /sync /domain
60Net computer
- Adds or deletes computers from a domain database.
This command is available only on computers
running Windows 2000 Server. - net computer \\computername /add /del
61Net config
- Displays the configurable services that are
running, or displays and changes settings for a
service. - net config service options
62Net group
- Adds, displays, or modifies global groups on
Windows 2000 Server domains. This command is
available for use only on Windows 2000 Server
Domain Controllers. - net group groupname /comment"text" /domain
- net group groupname /add /comment"text"
/delete /domain - net group groupname username ... /add
/delete /domain
63Net localgroup
- Adds, displays, or modifies local groups.
- net localgroup groupname /comment"text"
/domain - net localgroup groupname /add /comment"text"
/delete /domain - net localgroup groupname name ... /add
/delete /domain
64Net name
- Adds or deletes a messaging name (sometimes
called an alias), or displays the list of names
the computer will accept messages for. The
Messenger service must be running to use net
name. - net name name /add /delete
65Net send
- Sends messages to other users, computers, or
messaging names on the network. The Messenger
service must be running to receive messages. - net send name /domainname /users
message
66Net session
- Lists or disconnects the sessions between a local
computer and the clients connected to it. - net session \\computername /delete
67Net share
- Creates, deletes, or displays shared resources.
- net share sharename
- net share sharenamedrivepath /usersnumber
/unlimited /remark"text" - net share sharename /usersnumber unlimited
/remark"text" - net share sharename drivepath /delete
68Net start
- Starts a service, or displays a list of started
services. Service names of two or more words,
such as Net Logon or Computer Browser, must be
enclosed in quotation marks ("). - net start service
69Net statistics
- Displays the statistics log for the local
Workstation or Server service, or the running
services for which statistics are available. - net statistics workstation server
70Net stop
- Stops a Windows 2000 network service.
- net stop service
71Net time
- Synchronizes the computer's clock with that of
another computer or domain. Used without the /set
option, displays the time for another computer or
domain. - net time \\computername /domaindomainname
/rtsdomaindomainname /set - net time \\computername /querysntp
/setsntpntp server list
72Net use
- Connects a computer to or disconnects a computer
from a shared resource, or displays information
about computer connections. The command also
controls persistent net connections. - net use devicename \\computername\sharename
\volume password /userdomainname\use
rname /delete /persistentyes no - net use devicename /homepassword
/deleteyes no - net use /persistentyes no
73Net user
- Net user
- Adds or modifies user accounts or displays user
account information. - net user username password options
/domain - net user username password /add options
/domain - net user username /delete /domain
74Net view
- Displays a list of domains, a list of computers,
or the resources being shared by the specified
computer. - net view \\computername /domaindomainname
- net view /networknw \\computername
75Lecture 3Backup Restore
- Backup
- Restore
- tar, cpio, dd, dump/ufsdump
- Backup types
- Backup Plan
- Backup Scheduling
76Backups
- The correct management of backup policy is
possibly the most important role of a systems
administrator - It serves to provide
- Archives of data and state, roll-back, comparison
- Disaster recovery plan
- System replication mechanism
- Software deployment mechanism
77Backup Restore
- Traditionally backup is to tape devices for
reasons of capacity and reliability - Backup may be to any other device depending on
factors such as - Capacity
- Speed
- Reliability
- Facility
- Cost
- Cost
78tar
- Oldest UNIX backup method, runs on all UNIX
variants - Supports appending of files to the end of the
tape - Very slow, not really suitable for full system
backups
79tar
- User and group IDs are retained upon restore
- cd /export/home/michael
- tar cvf /dev/rmt/0m .
- tar xvf /dev/rmt/0m .
80cpio
- Much faster than tar
- Good for replicating directory trees
- Supports incremental backup
- find . cpio o F archive
- cpio i F archive
81dd
- Bit-for-bit copy
- Does not copy files and ownerships, just copies
bits - Cannot select files and directories from a dd
tape - Used for creating mirror images of disks at a low
level
82dump / ufsdump
- Used for creating full or incremental backups
- Can specify levels for dumping which specify the
type of incremental backup - Level 0 full backup
- Level 1 all files changed since last level 0
dump - Level 2 all files changed since last level 1
dump - Etc.
83Backup Types
- Full
- Backup everything on the system
- Incremental
- Backup only those files that have changed since
the last full backup - Differential
- Backup only those files that have changed since
the last backup
84Grand Father - Father - Son Backup Scheme
- Perform an initial Full System Backup
- Perform daily backups, Monday, Tuesday,
Wednesday, Thursdayreuse these tapes each week - Perform weekly backups Friday1, Friday2,
Friday3reuse these tapes each month - Perform monthly backups Month1, Month2 etc.
85Grand Father - Father - Son Backup Scheme
- Files can be restored to within 1 day, for files
archived within the last week - Files can be restored to within 1 week for files
archived within last month - Files can be restored to within 1 month for files
archived within last year
86Scheduling Backups
- Cron is the UNIX scheduling daemon
- The windows environment includes the Scheduler
service which can be accessed using the At command
87Cron (unix)
- Depending on the system configuration, users may
schedule tasks to occur at specific times on a
UNIX system - The cron service searches the /var/spool/cron
directory for cron files - Cron files are named after usernames in
/etc/passwd - Files specify the time and the command to perform
88Cron (unix)
- The cron service wakes up every minute and
examines all the cron files - Within each file it examines each line to
ascertain if a command needs to be executed - When the command is executed, any output is
mailed to the user who owns the file or the
username (if any) specified in the command
89Cron (unix)
- Format of the crontab files
- minute (0-59)
- hour (0-23)
- monthday (1-31)
- month (1-12)
- weekday (0, Sunday 6, Saturday)
- username
- Command
90Cron (unix)
- Example
- ls l /etc gt /home/mdeegan/etclist.txt
- 0 2 6 full-backup
- 15 12 1-5 incremental-backup
- 0 3 0 find / -name core atime 7 gt /corelist
- 0,20,40 0,6 w gtgt /home/mdeegan/wholog
- 0,10,20,30,40,50 1-5 w gtgt
/home/mdeegan/wholog
91Cron (unix)
- edited with crontab e
- displayed with crontab l
- deleted with crontab -r
92At (unix)
- Used for single command execution at 900pm
atgt find / -name core exec rm \
93At (windows)
- at \\computername time /interactive
/everydate,... /nextdate,... command - at 1527 wholog.bat
- at 1700 /nextF collectCSAA.bat
- at 0300 /everyM,T,W,Th incBackup.bat
- at 0300 /everyF fullBackup.bat
94Lecture 4Booting Linux
- Booting Linux
- LILO
- lilo.conf
- Loadlin.exe
- System Startup Shutdown
95Booting LINUX
- Booting Linux requires that you install a program
to load the kernel into memory on your computer - Depending on your hardware, you may use one of
several programs to do this - LILO(intel), MILO(alpha), SILO(sparc)
96Lilo
- You can use lilo to start Linux
- From the Master Boot Record (MBR) of your hard
drive - From the superblock of your linux root partition
on a hard drive - From a floppy disk
97Drive Naming in Linux
- In Linux, as in other UNIX systems your hard
drives are represented by files in the /dev
directory - If you have more than one IDE drive, the first is
referred to as /dev/hda, the second as /dev/hdb
etc. - If you use SCSI drives, they will be named
/dev/sda /dev/sdb etc.
98Partition Naming in Linux
- Partitions within drives are referred to as the
hard drive name plus a partition number /dev/hda1
etc. or /dev/sda1 etc. for SCSI drives
99Lilo.conf
- The operation of lilo is configured using the
/etc/lilo.conf file - Before configuring LILO you must know what
partitions have what operating system on them - For example If you have a dual-boot installation
with 2 operating systems installed, /dev/hda1
might be your Linux partition and /dev/hda2 might
be your Windows 2000 partition
100Lilo.conf
- You should know where you want to install LILO
- In most cases, you will want to put LILO on the
MBR (Master Boot Record)
101Lilo.conf
- In certain cases, you cannot install LILO on the
MBR, you must install it in the Superblock of the
root partition for your Linux installation - LILO is normally installed after you have
partitioned your hard drives and after you have
installed either Linux or other operating systems
102Editing Lilo.conf
- Editing lilo.conf is easy, but dangerous if you
dont know what youre doing - Always make a backup of lilo.conf (preferably to
a bootable Linux floppy) before making any changes
103Editing Lilo.conf
- You may want to edit lilo.conf for a number of
reasons - You are testing a new kernel and you want to be
able to boot the same Linux partition with more
than one kernel - You want to add password protection to a
partition - You have a hardware setup that requires you to
specify special options such as booting a remote
file system - Your kernel is called something other than
/vmlinuz or is is a non-standard place such as
/etc or /home
104Sample lilo.conf
- Start LILO global section
- BOOT /dev/hda
- Prompt
- Vga normal
- Ramdisk 0
- End LILO global section
- image /vmlinuz
- root /dev/hda3
- label linux
- read-only
- other /dev/hda1
- label windows2000
- table /dev/hda
105Lilo.conf parameters
- There are over 20 parameters that can be used in
the lilo.conf file. Some of these are - bootltboot_devicegt
- installltboot_sectorgt
- messageltmessage_filegt
- verboseltlevelgt
- backupltbackup_filegt
- prompt
- timeoutltsecsgt
- passwordltpasswordgt
106/sbin/lilo
- After making any changes to lilo.conf you need to
run /sbin/lilo - This should also be run after installing a new
kernel
107Lilo boot prompt options
- The following options can be passed to LILO at
the boot prompt to enable special features of
your system or to pass options to the Linux
kernel - Normally, at the lilo prompt you will just type
linux or dos - Some other options that can be used are
- Rescue
- Single
- rootltdevicegt
- vgaltmodegt (can use the ask option)
108Loadlin.exe
- Instead of using LILO, you can start Linux from
DOS using loadlin.exe - This is included on the installation CD-Rom in
the Dosutils directory - Loadlin.exe uses the DOS MBR to boot Linux
- Copy loadlin.exe to a DOS partition
- Put a copy of the Linux kernel in the DOS
partition - At the dos prompt type
- loadlin c\vmlinuz root/dev/hda1 rw
109Diskless Linux workstation
- You may also choose to boot your PC as a diskless
Linux workstation, provided the correct network
infrastructure is in place
110Lecture 5Linux StartUp and ShutDown
- Linux startup Shutdown
- The Boot Process
- The Initialisation Process
- Startup Scripts
- Run Levels
- Init, Shutdown, Halt, Reboot
111The Boot Process
- Intel based PCs start by executing code contained
in BIOS chips - This code instructs the system to look for the
first sector of the first cylinder of the boot
drive and to try to load and execute code found
there - It is possible to set (in BIOS) the order in
which the drives are searched (CD, Floppy, IDE1,
IDE2 etc.)
112The Boot Process
- This is also the case in many (but not all) other
versions of hardware and of UNIX - Linux shares many traits with System V and with
BSD based UNIX variants - Linux is closer to System V than to BSD in
relation to the booting process - Linux uses the init command and a directory
structure based on run-levels to start running
the system and loading processes
113The Initialisation Process
- System States (or run levels) on early UNIX
systems grew out of a need to separate how the
system ran depending on the maintenance being
performed - Usually, this meant that to add new hardware (or
software) a system reboot was necessary - Today, with hot swappable devices, it is not
strictly necessary to reboot systems in order to
install new hardware or software
114The initialisation Process
- The /etc/inittab file contains settings for the
init process and also defines the run levels for
a Linux system
115/etc/inittab run levels
- Default runlevel. The runlevels used by RHS
are - 0 - halt (Do NOT set initdefault to this)
- 1 - Single user mode
- 2 - Multiuser, without NFS (The same as 3, if
you do not have networking) - 3 - Full multiuser mode
- 4 - unused
- 5 - X11
- 6 - reboot (Do NOT set initdefault to this)
116/etc/inittab file (1/5)
-
- inittab This file describes how the INIT
process should set up - the system in a certain
run-level. -
- Author Miquel van Smoorenburg,
ltmiquels_at_drinkel.nl.mugnet.orggt - Modified for RHS Linux by Marc
Ewing and Donnie Barnes
117/etc/inittab file (2/5)
- Default runlevel. The runlevels used by RHS
are - 0 - halt (Do NOT set initdefault to this)
- 1 - Single user mode
- 2 - Multiuser, without NFS (The same as 3, if
you do not have networking) - 3 - Full multiuser mode
- 4 - unused
- 5 - X11
- 6 - reboot (Do NOT set initdefault to this)
118/etc/inittab file (3/5)
- id3initdefault
- System initialization.
- sisysinit/etc/rc.d/rc.sysinit
- l00wait/etc/rc.d/rc 0
- l11wait/etc/rc.d/rc 1
- l22wait/etc/rc.d/rc 2
- l33wait/etc/rc.d/rc 3
- l44wait/etc/rc.d/rc 4
- l55wait/etc/rc.d/rc 5
- l66wait/etc/rc.d/rc 6
119/etc/inittab file (4/5)
- Trap CTRL-ALT-DELETE
- cactrlaltdel/sbin/shutdown -t3 -r now
- When our UPS tells us power has failed, assume
we have a few minutes - of power left. Schedule a shutdown for 2
minutes from now. - This does, of course, assume you have powerd
installed and your - UPS connected and working correctly.
- pfpowerfail/sbin/shutdown -f -h 2 "Power
Failure System Shutting Down" - If power was restored before the shutdown
kicked in, cancel it. - pr12345powerokwait/sbin/shutdown -c "Power
Restored Shutdown Cancelled"
120/etc/inittab file (5/5)
- Run gettys in standard runlevels
- 12345respawn/sbin/mingetty tty1
- 22345respawn/sbin/mingetty tty2
- 32345respawn/sbin/mingetty tty3
- 42345respawn/sbin/mingetty tty4
- 52345respawn/sbin/mingetty tty5
- 62345respawn/sbin/mingetty tty6
- Run xdm in runlevel 5
- x5respawn/etc/X11/prefdm -nodaemon
121init process
- init is sometimes referred to as the father of
all processes - init is responsible for creating processes from a
script stored in /etc/inittab - Linux init command is compatible with the System
V init command - init starts as the last step of the kernel
booting - init is the first command that initialises and
configures the system for use
122init process
- Init works by parsing the /etc/inittab file and
by running scripts in the /etc/rc.d directories
depending on the required run level - Each individual script is designed to start or
stop and individual service such as networking,
mail, news, web, nfs, dhcp etc.
123/etc/rc.d directory
- The /etc/rc.d directory contains the following
files - rc, rc.local, rc.sysinit
- And the following directories
- init.d
- rc0.d
- rc1.d
- rc2.d
- rc3.d
- rc4.d
- rc5.d
- rc6.d
124Startup Scripts
- One of the most important scripts in /etc/inttab
is rc.sysinit - When init parses the inittab file, rc.sysinit is
the first script found and executed
125rc.sysinit script
- Sets some initial PATH variables
- Configures Networking
- Sets up Swapping for Virtual Memory
- Sets the system hostname
- Checks root file systems for possible repairs
- Checks root filesystem quotas
- Turns on user and group quotas for root file
system
126rc.sysinit script
- Remounts the root filesystem read/write
- Clears the mounted filesystems table /etc/mtab
- Enters the root filesystem into mtab
- Readies the system for loading modules
- Finds module dependencies
- Checks filesystems for possible repairs
- Mounts all other file systems
127rc.sysinit script
- Cleans out /etc/mtab /etc/fastboot /etc/nologin
etc. - Deletes UUCP lock files
- Deletes stale subsystem files
- Deletes stale pid files
- Sets the system clock
- Turns on swapping
- Initialises the serial ports
- Loads Modules
128rc.local script
- After the rc.sysinit script is run, init runs the
rc.local script to carry out any site-specific
operations that may be required upon system
startup - rc.local may examine the local system and create
a message for the login prompt based on the
hardware and software versions found - If it does, it will put such details in the file
/etc/issue which may be displayed on login
129Run Level 0
- /etc/rc.d/rc0.d
- Starts the shutdown sequence
- Kills All Processes
- Turns off Virtual Memory File Swapping
- Unmounts swap and mounted file systems
130Run Level 1
- /etc/rc,d/rc1.d
- Single user mode, or administrative state
- Used by sys admins while performing software
maintenance - Nobody else can log in
- Networking is turned off, but file systems are
mounted
131Run Level 2
- /etc/rc.d/rc2.d
- Multiuser state
- Networking is enabled, NFS is disabled
132Run Level 3
- /etc/rc.d/rc3.d
- Usually the default run level specified as the
first line in the /etc/inittab file - Remote file sharing is enabled along with all
other desired services
133Run Level 4
- /etc/rc4.d
- Usually empty, not used
- If you want to define your own run level, this
can be used to set up the appropriate links
134Run Level 5
- /etc/rc.d/rc5.d
- Similar to the default run level, but with the
named (internet DNS server) - Usually the default run level for X11
135Run Level 6
- /etc/rc5.d
- Reboot run level
- Contains links similar to level 0, but logic in
the halt script in init.d determines whether the
system is being shut down or rebooted
136Run Levels
- Each run-level is defined by the services
(daemons) that are normally running in that level - The services to stop and start for each run level
are defined in the rcX.d directories mentioned
above - These directories contain symbolic links to
master scripts contained in the /etc/rc.d/init.d
directory
137Run Levels
- The symbolic links contained in the rcX.d
directories must be named so as to start with
capital K or capital S - For example rc3.d contains the following
symbolic links - K05saslauthd K87portmap S10network S25netfs
S80sendmail S95anacron - Any other files or symbolic links contained in
the rcX.d directories will be ignored by the rc
script
138Run Levels
- In addition to the inclusion of K or S at the
start of the symbolic links, the file names also
carry a number between 00 and 99 - The combination of K or S followed by a number
means that when the files are listed
alphabetically, they appear in a particular order - This order determines the order in which the
scripts are run by the rc script
139Run Levels
- When a symbolic link beginning with K is
encuntered, rc runs that script with the stop
parameter - When a symbolic link beginning with S is
encountered, rc runs that script with the start
parameter
140/etc/rc/d/init.d directory
- This directory contains the master copies of all
the scripts that may contain symbolic links in
the rcX.d directories
141Adding Services to Run Levels
- If we want a service to start in a given run
level we must - Create or copy the start/stop/status script to
the /etc/rc.d/init.d directory - Create a symbolic link in the required run level
directory to start the script in the appropriate
sequence - ln -s /etc/rc.d/init.d/isdn /etc/rc.d/rc3.d/S20is
dn
142Init
143Shutdown
- shutdown -krhfnc -t secs time warning
message - -k Dont really shut down, just warn
- -r reboot after shutdown
- -h halt after shutdown
- -f do a fast reboot
- -n do not go through init but go down real
fast - -c cancel a running shutdown
- -t ltsecgt delay between warning and kill signal
- Shutdown t60 r now
144Halt
- Notifies the kernel of a shutdown or reboot
145Reboot
146Lecture 6CSAA Lab 5
- 1 Directory Creation
- All work done as part of this lab should be
stored in the following directory - Windows U\MD-CSAA\LAB05
- or
- UNIX ltyour home directorygt/MD-CSAA/LAB05
147Lab
- 2 Background
- This lab is intended to reinforce lectures on the
topic of Linux system start-up. - The lab helps to develop an understanding of the
workings of the rc start-up script on a Linux (or
other UNIX) system
148Lab
- 3 Existing Files Directories
- On the Aisling server the directory
/home/deegan-DT228-3/rc.d contains files and
directories similar to those found in the
/etc/rc.d directory - init.d contains master copies of the scripts to
be used as part of this lab
149Lab
- The rc script  functions in a similar manner to
the Linux rc script with the following exception - Instead of the /etc/rc.d/rcltrun-levelgt.d
directory it checks your own lab directory
/home/student/DT228-3/ltyougt/MD-CSAA/LAB05/rc.d/rclt
run-levelgt.d
150Lab
- 4 Directories to Create
- In the LAB05 directory, you must create the rc.d
directory - In rc.d you must create run level directories,
rc1.d, rc2.d and rc3.d - In the rc3.d directory you must create symbolic
links to effect the execution of the master
scripts in the order specified in the rc3.d
directory at /etc/rc.d/rc3.d - To do this you must create correctly named
symbolic links to the master files contained in
/home/deegan-DT228-3/rc.d /init.d
151Lab
- 5 Test
- You may test your work by running the rc script
with the parameter indicating the required run
level, for example - /home/deegan-DT228-3/rc.d/rc 3
152Lab
- 6 Completion Criteria
- When you have created the required symbolic links
in the correct directories - When you have successfully tested these links
using the rc script - You have successfully completed this lab
153Lecture 7Performance Analysis
- Performance Analysis
- vmstat
154Performance Analysis
- Performance analysis involves identifying various
system bottlenecks - This incolves a number of steps
- We must ask a number of questions
- Is there a performance Problem?
- Is the problem CPU or I/O related?
155CPU Related?
- What is the current load on the CPU?
- What is the average load on the CPU?
156I/O Related?
- Is it normal disk I/O?
- Would more/faster disks help?
- Is it paging I/O?
- Would more physical memory help?
157Related to a Particular User or Program?
- Identify the user / program
- Identify what they are doing to cause the problem
- Revise their operating procedures
- Consider removing them from the system
158Determining CPU Usage
- Determining the CPU usage is the first thing we
should do - There are a number of tools to do this
- vmstat gives several pieces of useful information
including CPU usage - vmstat interval count
- Interval is the number of seconds between reports
and count is the number of reports to generate
159vmstat 2 10
- mdeegan_at_aisling mdeegan vmstat 2 10
- procs memory swap
io system cpu - r b w swpd free buff cache si so
bi bo in cs us sy id - 1 0 0 5484 27240 136584 198840 0 1
5 8 8 8 4 7 4 - 0 0 0 5484 27240 136584 198840 0 0
0 96 155 100 0 0 100 - 0 0 0 5484 27232 136584 198844 0 0
0 0 159 112 2 0 98 - 0 0 0 5484 27216 136584 198844 0 0
0 0 130 51 0 2 98 - 0 0 0 5484 27216 136588 198848 0 0
0 86 157 63 0 0 100 - 0 0 0 5484 27216 136588 198848 0 0
0 0 139 46 0 0 100 - 0 0 0 5484 27224 136588 198836 0 0
0 30 153 47 0 0 100 - 0 0 0 5484 27712 136588 198824 0 0
0 8 166 107 1 0 99 - 0 0 0 5484 26876 136588 198828 0 0
0 0 139 92 6 2 91 - 0 0 0 5484 26876 136592 198824 0 0
0 144 137 69 0 0 100
160vmstat
- The first line gives the average values since the
system was booted and should be ignored - To determine the CPU usage, we are interested in
the last three columns, us, sy, id
161Analysing vmstat output(Process States)
- There are three states in which a process may be
at any point in time - Runtime, uninterrupted sleep, swapped out
- Process Statistics
- r Number of processes waiting for runtime
- b Number of processes in uninterrupted sleep
- w Number of processes swapped out, but otherwise
able to run
162Analysing vmstat output(Process States)
- The number of processes waiting for runtime is a
good indicator of system health - The more processes waiting, the slower will be
the system
163Analysing vmstat output (Memory)
- Memory Statistics
- swapd Amount of virtual memory used (KB)
- free Amount of idle memory (KB)
- buff Ammount of memory used in buffers
- cacheamount of memory left in cache
164Analysing vmstat output (Swap)
- Swap Statistics
- si Amount of memory swapped in from disk (KB/s)
- so Amount of memory swapped out to disk (KB/s)
- Swap statistics are arguably the most important
statistic to monitor, and of these, the so field - This field indicates the pages that have been
swapped out, even if done before vmstat was
started
165Analysing vmstat output (I/O)
- I/O Statistics
- bi Blocks received from a block device
(blocks/sec) - bo Blocks sent to a block device (blocks/sec)
- If there are a large number of block transfers,
the problem with your system may lie here - A single reading, however is not indicative of
the system as a whole, simply a snapshot - All Linux blocks are 1KB except for CDRom blocks
(2KB)
166Analysing vmstat output (System)
- System Statistics
- in The number of interrupts per second,
including the system clock - cs The number of context switches per second
167Analysing vmstat output (I/O)
- I/O Statistics
- bi Blocks received from a block device
(blocks/sec) - bo Blocks sent to a block device (blocks/sec)
- cs The number of context switches per second
- If there are a large number of block transfers,
the problem with your system may lie here - A single reading, however is not indicative of
the system as a whole, simply a snapshot
168Analysing vmstat output (CPU)
- CPU Statistics
- us Percentage of CPU cycles spent on performing
user tasks - sy Percentage of CPU cycles spend on system
tasks. These include writing I/O, performing
general O/S functions etc. - id Percentage of CPU cycles not used (idle)
169Analysing vmstat output (CPU)
- Just because CPU time is high or idle time is low
does not indicate a system problem - It may simply indicate that a number of batch
jobs are scheduled to run at the same time and
might benefit from being rearranged - In order to establish if there is a genuine
problem it is necessary to monitor the system
over an extended period - If average CPU remain high, there is a problem
170Lecture 8Performance Analysis
171top
- top is another tool for identifying problems with
a LINUX system - Displays the top CPU processes
- Displays a listing of the most CPU intensive
tasks on the system - Can provide an interactive interface for
manipulating the processes - Default is to update every 5 seconds
172top
- top operates by examining files in the /proc
pseudo file system - This pseudo file system is used as an interface
to kernel data structures - man proc
173top
- mdeegan_at_aisling mdeegan top
- 171441 up 47 days, 227, 8 users, load
average 0.06, 0.03, 0.07 - 61 processes 59 sleeping, 2 running, 0 zombie, 0
stopped - CPU states 0.0 user 0.2 system 0.0 nice
0.0 iowait 99.8 idle - Mem 513316k av, 200052k used, 313264k free,
0k shrd, 44976k buff - 57692k actv, 11208k in_d,
1024k in_c - Swap 1052248k av, 9096k used, 1043152k free
34656k cached - PID USER PRI NI SIZE RSS SHARE STAT CPU
MEM TIME CPU COMMAND - 1 root 15 0 108 76 56 S 0.0
0.0 015 0 init - 2 root 15 0 0 0 0 SW 0.0
0.0 000 0 keventd - 3 root 15 0 0 0 0 SW 0.0
0.0 001 0 kapmd - 4 root 34 19 0 0 0 SWN 0.0
0.0 000 0 ksoftirqd_CPU0 - 9 root 15 0 0 0 0 SW 0.0
0.0 000 0 bdflush - 226 root 15 0 0 0 0 SW 0.0
0.0 000 0 kjournald - 586 root 15 0 200 160 116 S 0.0
0.0 008 0 syslogd - 590 root 15 0 180 168 120 S 0.0
0.0 003 0 klogd - 666 root 15 0 480 348 232 S 0.0
0.0 109 0 sshd - 719 root 15 0 52 4 0 S 0.0
0.0 000 0 gpm
174Analysing top output
- Up The time the system has been up and the three
load averages - Average number of processes ready to run in the
last 1,5 and 15 minutes - Same as the output of uptime
- Processes The total number of processes running
at the time of the last update - Broken down into running, sleeping, stopped and
zombied
175Analysing top output
- CPU States The percentage of CPU time in user
mode, system mode, niced tasks (negative nice
tasks) and idle - Time spent in niced tasks will also be counted
system and user time, so the total will be more
than 100 - Mem Statistics on memory usage, including total
available memory, free memory, used memory,
shared memory, memory used for buffers
176Analysing top output
- Swap Statistics on swap space including total
swap space and used swap space - This and the Mem section together are the same as
the output of free - PID The process ID of each task
- USER The username pf the tasks owner
- PRI The priority of the task
- NI The nice value of the task. Negative values
are lower priority
177Analysing top output
- SIZE The size of the tasks code plus data stack
space, in kilobytes - RSS The total amount of physical memory used by
the task in kilobytes - SHARE The amount of shared memory used by the
task - STATE The state of the task, S sleeping, D
uninterrupted sleep, R running, Z zombies, T
stopped or traced
178Analysing top output
- CPU The tasks share of the CPU since the last
screen update as a a percentage of total CPU time - MEM The tasks percentage of physical memory
- Time Total CPU time used by process since it
started - COMMAND The tasks command name
179Using top to control processes
- In addition to command-line options for
controlling the appearance of top (not covered
here) there are a number of commands that can be
issued to top while running - Space immediately updates the display
- L Erases and redraws the screen
- k kill a process You will be prompted for the
pid and a signal to send to the process (normally
15)
180Using top to control processes
- i ignore zombie processes
- n change the number of processes to view
- r renice a process
- P sort tasks by CPU usage
- M sort tasks by Memory usage
181Renice
- The renice command is used to alter the priority
of running processes - The default nice value is 0
- The range in Linux is -20 to 20
- The lower the value the faster the process runs
- Can examine the nice value of a process using ps
l
182Renice
- The owner of and root can change the nice value
of aprocess using renice - Changes apply to all child processes
- renice priority -p pid ... -g pgrp ...
-u user ... - mdeegan_at_aisling mdeegan ps -l
- F S UID PID PPID C PRI NI ADDR SZ WCHAN
TTY TIME CMD - 0 S 1634 24496 24495 0 75 0 - 1091 wait4
pts/1 000000 bash - 0 R 1634 26361 24496 0 75 0 - 778 -
pts/1 000000 ps - mdeegan_at_aisling mdeegan renice 5 24496
- 24496 old priority 0, new priority 5
- mdeegan_at_aisling mdeegan ps -l
- F S UID PID PPID C PRI NI ADDR SZ WCHAN
TTY TIME CMD - 0 S 1634 24496 24495 0 80 5 - 1091 wait4
pts/1 000000 bash - 0 R 1634 26363 24496 0 80 5 - 777 -
pts/1 000000 ps
183Renice
- Once a nice value has been increased, only the
root user can reduce it again, not even to the
default value - mdeegan_at_aisling mdeegan renice 19 24496
- 24496 old priority 5, new priority 19
- mdeegan_at_aisling mdeegan ps -l
- F S UID PID PPID C PRI NI ADDR SZ WCHAN
TTY TIME CMD - 0 S 1634 24496 24495 0 94 19 - 1091 wait4
pts/1 000000 bash - 0 R 1634 26390 24496 0 94 19 - 778 -
pts/1 000000 ps - mdeegan_at_aisling mdeegan renice 1 24496
- renice 24496 setpriority Permission denied
184Lecture 9File Systems
- Guest Lecture by Emmet Caulfield
- File Systems
185Lecture 10RPM Package Management
- Guest Lecture by Emmet Caulfield
- Package Management
186Lecture 11UML On McCool
- User Mode Linux (UML) On McCool
187User Mode Linux (UML)
- User-Mode Linux is a safe, secure way of running
Linux versions and Linux processes. - Run buggy software, experiment with new Linux
kernels or distributions, and poke around in the
internals of Linux, all without risking your main
Linux setup. - http//user-mode-linux.sourceforge.net/
188User Mode Linux (UML)
- UML is a useful teaching tool, especially in
courses where students need a dedicated machine
in order to get the most out of it - UML is being used to teach OS development,
network administration, and more general system
administration. - These are all cases where having a virtual
machine to practice on is far more convenient for
everyone than using physical boxes. - http//user-mode-linux.sourceforge.net/
189UML at the School of Computing
- At present (01/12/2004) The School of Computing
provides one system specificall for hosting UML
sessions - McCool.student.comp.dit.ie
190McCool
- For ease and speed of initial set up the
/etc/passwd and /etc/group files were copied from
aisling.student.comp.dit.ie - Home directories for students were also copied
from aisling - The net effect is that the initial passwords and
initial directory contents of student accounts on
McCool were the identical