110
UNIX

UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Embed Size (px)

Citation preview

Page 1: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

UNIX

Page 2: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

System Administration Agenda

Day 1: Introduction to UNIX

Day 2: Introduction to Progress

Day 3: Platform Specific - half day

Page 3: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Introduction to UNIX

UNIX storage fundamentals

Working with Files and Directories

Editing and Scripting

Utilities and Maintenance

Page 4: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

UNIX is a Operating Systems (OS) Developed in the late 1960’s by

AT&T BellLabs Since development gone through

many revisions Several flavors available with

advantages and disadvantages

Operating System

Page 5: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Operating System

Infor Supported Versions IBM - AIX RedHat - Linux Hewlett Packard - HP/UX Microsoft - Windows Server

Infor Partner Supported Versions Unixware - SCO

Page 6: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Operating System

Made up of several programs, processes and configuration files

KernelSystem Parameters

Device Files

System Daemons

Processes

Schedulers

Page 7: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Operating System Structure

HARDWARE

KERNEL

SHELL(BOURNE,KORN, C, R)

APPLICATIONS(SX.E/PROGRESS)

Page 8: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

System Hierarchy

UNIX Operating System

Progress Database

SX.e Application

Page 9: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Login

getty = get tty telnetd

/etc/passwd

/etc/profile

/home/username/.profile

Page 10: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Environment Utilities# env List OS environment settingsLANG=en_US

LOGIN=aixuv0

NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat

PATH=./:/usr/bin:/bin:/etc:/usr/vsifax/bin:/usr/vsifax/spool:/etc/default/vsifax

:/home/aixuv0/bin:/rd/data:/usr/facetterm:/usr/bin/custom:/uniplex/UAP/bin:/us

r/bin:/usr/bin/adm:/etc:/usr/sbin:/usr/ucb:/home/tversema/bin:/usr/bin/X11:/sbin

EDITOR=vi

LOGNAME=aixuv0

MAIL=/usr/spool/mail/aixuv0

VFAXDIR=/usr/vsifax/spool

LOCPATH=/usr/lib/nls/loc

USER=aixuv0

AUTHSTATE=compat

SHELL=/usr/bin/ksh

ODMDIR=/etc/objrepos

HOME=/home/aixuv0

TERM=vt220

MAILMSG=[YOU HAVE NEW MAIL]

PWD=/home/aixuv0

Standard input

Page 11: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Environment Utilities# stty -a Lists tty settingsspeed 9600 baud; 0 rows; 0 columns;

eucw 1:1:0:0, scrw 1:1:0:0:

intr = <undef>; quit = ^\; erase = ^?; kill = ^K; eof = ^D; eol = ^@

eol2 = ^@; start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y; reprint = ^R

discard = ^O; werase = ^W; lnext = ^V

-parenb -parodd cs8 -cstopb hupcl cread -clocal -parext

-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc

-ixon -ixany -ixoff imaxbel

isig icanon -xcase echo echoe echok -echonl -noflsh

-tostop echoctl -echoprt echoke -flusho -pending iexten

opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tab3

# stty -a < /dev/tty???

Page 12: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

UNIX Commands

Movement:

pwd Print Working Directory

# pwd /home

Pathing:

cd cd ~

cd .. cd ..//..

Page 13: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

UNIX Commands

Checking File Permissions and Sizes:

ls List Directory -l -i -t -r

# ls.profile myfile junk

# ls -al List Directorydrwxr-xr-x 16 root System 3072 Jul 21 12:29 .

drwxr-xr-x 28 bin bin 15872 Jul 27 11:29 ..

-rw-rw-rw- 1 root System 0 Aug 25 1997 .facetusers

Page 14: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Wild Cards* All matches# ls -al b*

bob

bratt

bradt

? Specific characters must match

# ls -al bra?tbratt

bradt

Page 15: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

/ (root)

root volume group data volume group

usr home var etc rd db bi

bob jean dan passwd trhead.db trhead.bi

bin lib tmp

spool adm tmp src opsys exec tmp

Directory Structure

Page 16: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

/var

/var is a filesystem. A filesystem is an area

that exists on your volume group where you

can store files.

Filesystems

Page 17: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

/var

adm spool tmp news

/var/adm, /var/spool, /var/tmp and/var/news are all directories (or betterknown as sub-directories.

Directories

Page 18: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

/var

tmp bin

cmru.dat login

cmru.dat and login are files which exist in

/var/tmp & /var/bin directories.

Files

Page 19: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Disk Layout

Two ways to setup your disks:

- Full Disk

- Logical Volume Manager - LVM

Page 20: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Full Disk Approach

/rd

/root

/db

/usr /bi

Page 21: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

LVM Approach

Hard Drive Hard Drive

2 GB 2 GB

4 GB

Page 22: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

NxTrend chosen method for datastorage

Logical Volume Manager

Freedom… Ability to cross several physical volumes with a single filesystem.

Flexibility… Add additional physical volumes to the logical volume on the fly.

Page 23: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Terminology

Physical Volume = Hard drive that hasbeen initialized for usein LVM

Volume Groups = A named collection ofphysical volumes.

Logical Volume = Entities upon which afile system resides.

(swap)File system = Formatted area within

logical volume to holddata.

Page 24: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Typical Disk Layout

Disk1 root volume group

(boot disk)

Disk2 Disk3 data volume group

Page 25: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

volume groups

Disk1 Files Systems

root volume group

(boot disk)

logical

volumes

Disk2 Disk3 Files Systems

data volume group

physical volumes

Page 26: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Superblock

Superblock - File system size and identification.

Journaled File System Structure

Page 27: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

SuperblockInodes

Data Block

Superblock

Inodes

Data Blocks

Page 28: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Physical

Volume

Page 29: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

2000 Files

VOLUME GROUPS

1999 Files

Page 30: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Logical

Volumes

Page 31: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Filesystems

Page 32: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Directories

& Files

Page 33: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Volume Groups

Physical

Volume

Files &

Directories

Filesystems

Logical Volumes

Page 34: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Filesystem Layout

* Redundancy

* Performance

* Growth

Page 35: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Mirroring

Production

Mirror

1 2 3 4 5

Disk 1

6 1 2 3 4 5

Disk 2

6

1 2 3 4 5

Disk 3

6 1 2 3 4 5

Disk 4

6

Page 36: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Striping

1 5 9 13 17

Dis k 1

2 6 10 14 18

Dis k 2

3 7 11 15 19

Dis k 3

4 8 12 16 20

Dis k 4

Page 37: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Striping & Mirroring

1 3 5 7 9

D i s k 1

11

2 4 6 8 10

D i s k 2

12

1 3 53

7 9

D i s k 3

1 2 4 6 8 1

D i s k 4

1

Page 38: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

RAID - Redundant Array of Inexpensive Disks

(RAID 0) Striped Disks If you are creating filesystems that need the ability to do many I/Os simultaneously, a better strategy for creating them is to use Disk Striping.

(RAID 1) Mirrored Disk mirroring provides a level of redundancy in your disk system.

(RAID 10) Striped & Mirrored. RAID 10 is a new term describing the concept of using disk striping (RAID 0) across multiple mirrored pairs (RAID 1).

Page 39: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

(RAID 5). RAID 5 is a popular industry buzzword that has emerged in the last few years. This technology provides disk redundancy to protect against disk failure, with a lower cost than RAID 1.

1 P3 4 P7 8

Dis k 1

P1 2 P4 5 P8

Dis k 2

P2 6 P5 9

Dis k 3

3 P6 7 P9

Dis k 4

Page 40: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Review 1

Page 41: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

!!!BREAK!!!

Page 42: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Types of Files ASCII

text files (readable)

binary compiled programs (unreadable)

encrypted file containing special characters

(unreadable) Determining File Type

# file <filename>

Page 43: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File View# more Display file 1 page at a time

<enter> Moves down 1 line

space bar Move down 1 page

/ ? Forward/Backward find

n Next occurrence

q Quit

v vi editor

Page 44: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

ASCII

$ more /etc/passwd

root:!:0:0:root:/:/bin/ksh

daemon:!:1:1::/etc:

bin:!:2:2::/bin:

sys:!:3:3::/usr/sys:

adm:!:4:4::/var/adm:

uucp:!:5:5::/usr/lib/uucp:

guest:!:100:100::/home/guest:/usr/bin/ksh

nobody:!:4294967294:4294967294::/:

kevina:!:200:1::/home/kevina:/usr/bin/ksh

Page 45: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Binary / Encrypted

$ more /usr/bin/awk^Aß^D2ûïXH^P^G^A^K^A^A:¬ð^Pþpê¤^P^AìM-^@^B

^B^D^C^E^C1L.text^P^A^P^A^A:¬^A

að^P^A;°@.bssð^Pð^PþpM-^@.loader>^E^B+À^PM-^PbM-^PM-^B^D|^^øM-^AB^P9 e)^D^BM-^Q*

#x|¯+xM-^Câ^TH]M-^@A^T}Äsx}å{xM-^@â^\9M-^Q^GHe`M-^@,^GAM-^@b^LH^EM-^YM-^@A^T^L @

M-^AM-^B^XM-^PA^TM-^@^LM-^@L^D| ^C¦NM-^@^D ^LM-^@¾!ÿÄ^B¦;^DM-^PM-^T!ÿM-^@:ãM-^P¡

^TM-^HãM-^B"$(^Ga8`ÿÿ8M-^Q9^AM-^@â(@±^GH^DiM-^@A^T0M-^Q^D8`^CH^DYM-^@A^TM-^A^B0M

^Aÿÿ1(ÿÿ})A^PM-^Q'H^DMM-^@A^T,^W^AM-^BÂ<M-^Câ@M-^Pv0Ñ0@M-^B08M-^@^A8 5H^DIM-^@A^

^T8`^BH^DuM-^@A^T0q^PH^DM-^MM-^@A^TM-^@âTM-^PgH^D¡`8`^A8M-^XH^R `M-^@âM-^D0±^XM-

M-^@A^T,^Cÿÿ8ÿ2q 3'@: ^AAM-^B^A,3qØM-^C¢^B\3ñM-^DM-^CÂM-^LM-^CM-^BM-^PM-^CB^A/M-

Page 46: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File View# pg Page a File

<enter> Moves down 1 page

+/-? Moves up/down by the number you input.

$ Last Page

q Quit

Page 47: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File View# head filename Display the beginning of

file

Displays the first 20 lines from a file

# head -100 /usr/tmp/rptlog

/smit.log

# tail filename Display the end of file

Displays the last 10 lines from a file

# tail -100 /usr/tmp/rptlog

/smit.log

Page 48: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File Manipulation

# mv filename newfileMove a File

# rm filename Remove a File

-i interactive

-r recursive

# cp filename newfileCopy a File

Page 49: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Directories

# mkdir Make a Directory

# mvdir Move a Directory

# rmdir Remove a Directory

Page 50: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File & Directory ManipulationRedirection:

> Redirect & overwrite

>> Redirect & append

| Pipe into another command

Search:

strings Search for text in binary files

grep Search for string

Page 51: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Permissions -r-xr-xr-x 1 bin bin 2206 Jul 05 12:08 /etc/profile

Type User Group Other

- r-x r-x r-x bin bin profile

r View content = 4

w Alter file content = 2

x Run executable file = 1 _______

rwx full Permissions = 7

Page 52: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Permissions

-rw-rwxr-- root bin asciifile

owner =

group =

other =

Page 53: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Permissions

-rw-rwxr-- root bin asciifile

owner = 6 (r+w)

group =

other =

Page 54: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Permissions

-rw-rwxr-- root bin asciifile

owner = 6 (r+w)

group = 7 (r+w+x)

other =

Page 55: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Permissions

-rw-rwxr-- root bin asciifile

owner = 6 (r+w)

group = 7 (r+w+x)

other = 4 (r)

Page 56: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File & Directory Manipulationchmod - Change Mode

chown - Change Owner

chgrp - Change Group

# chmod 774 asciifile

-rwx-rwx-r-- root bin asciifile

# chown paul asciifile

-rw-rwx-r-- paul bin asciifile

# chgrp other asciifile

-rw-rwx-r-- root other asciifile

Page 57: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File & Directory Manipulationchmod - Change Mode

# chmod 774 asciifile

-rwxrwxr-- bin bin asciifile

# chmod ug=7 asciifile

-rwxrwxr-- bin bin asciifile

# chmod +w asciifile

-rw-rwx-r-- root other asciifile

Page 58: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File & Directory Manipulationchmod - Change Mode

# chmod 774 asciifile

-rwxrwxr-- bin bin asciifile

# chmod ug=7 asciifile

-rwxrwxr-- bin bin asciifile

# chmod +w asciifile

-rw-rwx-r-- root other asciifile

Page 59: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Directory ProtectionAccess Resulting AvailabilityGranted for Normal Users - - - No activity allowed

r - - Lists files but no attributes

- - x Allows user to run programs but will not list files.

r - x Work with programs, list contents. No creates or

deletes.

r w x Work with programs, list contents & create or delete

files.

Page 60: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

File Protection On On

Command Itself Directory

cd /home/test N/A x

ls /home/test/*.c none r

ls -s /home/test/*.cnone rx

cat runme r x

cat >> runme w x

runme (binary) x x

runme (script) rx x

rm runme none wx

Page 61: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Review 2

Page 62: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Text Editor - viCommand Mode (ESC)

i Insert Mode

r Replace Mode

o Open a New Line

y Yank a line

p Put a line

dd delete a line

x delete a character

/ find

Page 63: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

SHELL SCRIPT PROGRAMMINGWhat is shell programming?

Submitting commands to UNIX.

What is a script?Text file that contains one or more UNIX

commands.

Why use it?Save a lot of time by preparing scripts to

handle repetitive processes.

Page 64: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Scripts/rd/bin - Directory where most NxTrend

scripts exist

/rd/bin/backup.data - Typically a Monday - Friday process that backs up the

databases and users home

directories

/rd/bin/backup.full - Typically a full system

backup (includes all filesystems)

Page 65: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

LAB 1

Page 66: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

!!B r E a K!!

Page 67: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Utilitiespasswd Changes password

finger Shows user informationwho Lists who is logged

in

man Operating System Manual

uname System information

hostname System Hostname

find finds files

whence location of pathed files

type file location/information

Page 68: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Checking Filesystem Sizes

# df Display FilesystemsFilesystem 512-blocks Free %Used Iused %Iused Mounted on/dev/hd4 98304 13360 87% 2100 9% //dev/hd2 1376256 56112 96% 27064 16% /usr/dev/hd9var 344064 54256 85% 4918 12% /var

# df -k Display Filesystems in 1024-blocks

# bdf Display Filesystems in 1024-blocks (HP)

# dfspace Display Filesystems in 1024-blocks (Unixware)

Page 69: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Checking Directory Sizes

# du /rd/src Disk Usage (512k blks)256 /rd/src/alpha

147008 /rd/src

# du -k /rd/src (1024k blks)

128 /rd/src/alpha

73504 /rd/src

# du -s /rd/src(summary)

147008 /rd/src

Page 70: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Printing Utilities# lp Print Command

# lp file prints to default

# lp -dprinter file prints to selected printerJob number is: 66

# lpstat -t Printer Statusscheduler is running

no system default destination

system for jrnl: trnd (as printer jrnl)

66-jrnl 1000 bytes 10/10/98

# cancel 66-jrnl Cancels Print Jobs

Page 71: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Process Utilitiesps list Processes

ps -e ps -ef

ps -fu

ps -ef | grep (tty/username/processname)

kill Kills a Process

kill -9 vs. Kill -15

Page 72: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day
Page 73: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Security

UNIX: Passwords / root &

super user privileges

Trend: Passwords

Room Security: keys, tapes

Page 74: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

MaintenanceOn a regular basis:

Daily Backup & Disk space

Weekly Backup System, clean log

files

Monthly Disk space, OS backup,

Reboot

As needed:

Upgrades (OS, Progress, Trend)

Config Report

Port Maps

Page 75: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Backup Utilities

tar - Tape Archive

dd - data dump

cpio - copy in and out

Page 76: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

CPIO OptionsCommonly used CPIO options

i - Read in from output o - Write to out output c - Wrote or read header information in ASCII

character form for portability. d - Make directories as needed. u - Copy unconditionally (normally, older files

do not overwrite newer files with the same name.

Page 77: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

CPIO OptionsCommonly used CPIO options

m - Retain previous file modification time. This option does not affect directories that are being copiedhp, dg

v - Verbose. Cause a list of file names to be printed. When used with the t option, the table of contents looks like the output of an ls -l command. hp, ibm

Page 78: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

CPIO OptionsCommonly used CPIO options

B - Block input/output at 5120 bytes to the record (does not apply to the cpio -p option. This options is meaningful only with data directed to or from devices that support variable-length records such as a magnetic tape.hp, dg

B -Block input/output at 512 bytes. Note when using -B to extract or create a tape archive, the blocking factor must be a multiple of the physical block size for the tape deivce. ibm

Page 79: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Common CPIO Commands

Backup to tape drive: cat file | cpio -ocuvdB > /dev/rmt/0m

Backup to file: cat file | cpio -ocuvdB > /usr/tmp/file

Read Tape Table of Contents cpio -ictuvB < /dev/rmt/0m | more

Page 80: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Common CPIO Commands

Restore all files from tape: Determine how files were backed up:

• # cpio -ictuvB < /dev/rmt/0m Relative path: files appear as bin/, usr/ , rd/ on

tapelist)• # cd /

• # cpio -icdumvB < /dev/rmt/0m Full path: files appear as /bin , /usr, /rd on tapelist)

• # cpio -icdumvB < /dev/rmt/0m

Page 81: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

NxTrend CPIO

NxTrend Backup ScriptsBackup.data

Backup.full

Back Up Verificationbulog

tapelist

Page 82: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

System Shutdown Shutdown the system at least every 30

days

Cleans-up hung (zombie) processes

Make sure you halt the system to reset internal components

Page 83: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

shutdown [-r] [-h] [-y] [grace]

-r reboots the system after it reaches single user mode

-h halts the system after it reaches single-user mode.

-y turns off user interaction. The shutdown process is normally interactive, posing questions and requiring a ‘y’es or ‘n’o answer.

The -y option disables interaction allowing shutdown to run continuously

grace number of seconds that shutdown will wait before terminating all the processes running. Default is 60.

Page 84: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Reboot now (no grace)

shutdown -r now

Halt the system in 60 seconds

shutdown -h 60

Reboot in 60 seconds

shutdown

Page 85: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

reboot

Reboot [-h|-r] [-n|-s] [-m mesg] [-t time] [q]

-h halt the system

-r reboot the system (default)

-n no sync before halt or reboot

-s sync before halt or reboot (default

-m supply message to users

-t halt at a specified time

-q quick and silent

Page 86: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Reboot now

reboot -r

Halt the system

reboot -h

Reboot now

reboot

Page 87: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

shutdown vs. reboot shutdown shuts down more slowly but more

gracefully. Maintaining filesystem integrity

shutdown uses kill -15 to kill processes, reboot uses kill -9

reboot should only be used when in single mode or if system problems prevent you from running shutdown.

Page 88: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

What are cron & at processes?

cron & at

UNIX facilities that allow you to schedule processes to run at a given time in the future in the background.

Page 89: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

at vs cron

at

Schedule one time only

into the future

cron

Schedule for repetitive

processing in the future

Page 90: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

at command syntax

at [c|k|s|q Queue Name ] [-m] [-f File Name]

{-t Date|Time [Day] [increment]

c Request a csh command

k Request a ksh command

s Request a bsh command

q Requests a queue

m Mail a message to user

f Use the filename that follows

standard input

Page 91: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

{-t Date|Time [Day] [increment]

Time Date Increment

hrs month +n minutes

hrs:min day +n hours

hrmin year +n days

now day of week +n weeks

noon today +n months

midnight tomorrow +n years

next

at command syntax

Page 92: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

How do you use the at facility?

# at command <enter> process you wish to run <enter>

<ctrl> D

Job userid.job# .a will be run at Day of week Month Day HH:MM:SS Timezone Year

#

Page 93: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Scheduling at Processes...

# at noon today <enter>

ps -e |sort +2 <enter>

<ctrl -d >Job root.800600.a will run at Thu June 18 12:00:00 MDT 1998

#

Run a ps -e command at 12:00 p.m. today and sort by the second column

Page 94: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Show who is logged in at 8 p.m. on July 4

# at 20 July 4 <enter> who > /usr/tmp/atwho.log <enter> <ctrl -d >Job root.800601.a will run at Sat July 4 20:00:00 MDT 1998

#

# at 8 pm July 4 <enter>Job root.800601.a will run at Sat July 4 20:00:00 MDT 1998

# at 20:00 July 4 1999 <enter>Job root.800601.a will run at Sat July 4 20:00:00 MDT 1999

# at 8 July 4 <enter>Job root.800601.a will run at Sat July 4 8:00:00 MDT 1998

Page 95: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

List at Process:

# at -l <enter>

root.899600.a Thu Jun 18 12:00:00 MDT 1998

root.899601.a Sat Jul 4 20:00:00 MDT 1998

#

Remove at Process:

# at -r root.899600.a <enter>

The root.899600.a is deleted

#

Page 96: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Advanced Tips...

You can view all at jobs via the /usr/spool/cron/atjobs

directory. Each file exists as

username . Jobnumber . queuenumber.

You can view the job file using; more , pg , cat , etc…

The last line of the file indicates what command is to be processed.

Page 97: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Security

Restricting access to the at command

using /usr/lib/cron/at.allow &

/usr/lib/cron/at.deny files.

Page 98: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

at.allow at.deny Who can use

_______ ________ superuser

exists ignored every userin at.allow

________ exists every userwho is not inat.deny

empty ignored superuser

________ empty all users

Page 99: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Restrict users by their UNIX login

Create the necessary files in /usr/lib/cron and add the UNIX login names to the appropriate files

/usr/lib/cron/at.allow

root

bobj

uucp

/usr/lib/cron/at.deny

cindyj

scottl

Page 100: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

cron

facility not a command

controlled by the /etc/cron system

daemon

commands are executed through a

“cronfile”

Page 101: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Cronfiles...

exist in /usr/spool/cron/crontab{s}UNIX user names are used as cronfile namesmade up of six columns which determines

frequency of execution and what is to be executed

always copy existing cronfile to a save name before making changes.

Page 102: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Cronfiles1st column Minute 0 - 59

2nd column Hour 0 - 23

3rd column Day of Month 1 - 31

4th column Month of Year 1 - 12

5th column Day of Week 0 - 6 (0=Sunday)

6th column Command Command /Script

* Selects all values

, Separates values within each column

space/tab Separates each column

Page 103: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Scheduling cron Processes...

0 12 * * 1 ps -e >> /usr/tmp/process.log

Run a ps -e command every Monday at 12:00 p.m.

Minutes

Hours

Day of Month

Month

Day of Week COMMAND

Page 104: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Add the following entries to a cronfile:

List all users logged into the system from 4-5 a.m. every Saturday

* 4,5 * * 6 /usr/bin/who >> /usr/tmp/cronwho.log

Page 105: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

crontab

crontab [ -e | -l | -r | -v |File ]

e Starts an editing session for your cronfile

l Lists your cronfile

r Removes your cronfile

v Lists the status of your cron jobs

File Submits a new cronfile to UNIX

Page 106: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

crontabList the current cronfile:

# crontab -l <enter>

0 1 * * 1- 4 /usr/bin/backup.daily

#

Remove a cronfile. Use at your own risk!!!:

# crontab -r <enter>

#

Re-submit cronfile:

# crontab cronfile

#

Page 107: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Security

Restricting access to the cron

command using /usr/lib/cron/cron.allow &

/usr/lib/cron/cron.deny files.

Page 108: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

cron.allow cron.deny Who can use

_______ ________ superuser

exists ignored every user incron.allow

________ exists every userwho is not incron.deny

empty ignored superuser

________ empty all users

Page 109: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

Restrict users by their UNIX login

Create the necessary files in /usr/lib/cron and add the UNIX login names to the appropriate files

/usr/lib/cron/cron.allow

root

bobj

uucp

/usr/lib/cron/cron.deny

cindyj

scottl

Page 110: UNIX. System Administration Agenda §Day 1: Introduction to UNIX §Day 2: Introduction to Progress §Day 3: Platform Specific - half day

LAB 2