490 likes | 654 Views
Chapter 15. System Administration. Chapter 15 ( Topics ). Background The System Administrator & SuperUser Types of Files Description of System Operations Important Files & Directories. Chapter 15 ( Topics ). System Administration Day-to-day Periodic Preventing & Fixing Problems
E N D
Chapter 15 System Administration
Chapter 15 (Topics) • Background • The System Administrator & SuperUser • Types of Files • Description of System Operations • Important Files & Directories
Chapter 15 (Topics) • System Administration • Day-to-day • Periodic • Preventing & Fixing Problems • Useful Utilities • Getting Help
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
The System Administrator • Responsible for: • The care and feeding of Linux. • Addition, Deletion and updates to all system resources. • Disaster Recovery. • Users
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 • sudoallows specific command privileges to normal users.
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
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.
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
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.
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
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
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
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”
System Operation • Description of operation • Booting the system • System operating modes • Logging In, Running and Logging Out • Bringing the system down
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)
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.
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
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
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
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
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
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
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
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
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
System Operation • If errors are detected and fixed • Notify file users to beware of missing or inaccurate data. • Restore files from backups
Important Files & Directories • /dev/null – the bit bucket • /var – frequently changed system files • System logs • /var/spool/cron – controls what interval jobs are executed.
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
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)
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
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
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
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
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
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
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
System Administration (Day to Day) • What to use for backups
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
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 --update • --list -- • --extract --get
System Administration (Day to Day) • tar option [modifiers] [file-list] • --absolute-paths • --exclude filename • --file filename • --verbose
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 cronfiles are stored in the /var/spool/cron/crontabs Directory.
System Administration • Periodic • Installing LINUX • Floppy • CD-ROM • Rescue Disks
System Administration • Re-building the kernel • make config • make dep; make clean • make zlilo
Preventing & Fixing Problems • When a User Cannot Log In • useradd • userdel • Usermod • Suspect files • /etc/passwd • .profile – .login – .bashrc • /etc/inittab
Preventing & Fixing Problems • System logs • /var/log • Track various events in system
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
Useful Utilities • mount –t msdos /dev/fd0 /mnt • Mounts the floppy drive as a MSDOS device with its root at the /mnt directory
Getting Help • man pages • Info pages