Introduction to UNIX A Basic Environment June 1

Introduction to UNIX A. Basic Environment June 1, 1999 UNIX - Basic Environment 1

Performance Objectives Capabilities you should be able to perform following this module. 1. 2. 3. 4. 5. 6. 7. 8. Describe the four functional parts of UNIX. List three primary functions of the C Shell. Log ON/OFF, view MOTD (logout, exit, sync). Identify basic UNIX Prompts (% $ #). Parse a UNIX command line. Erase typing errors (stty erase). Change passwords, (passwd). Use Online Documentation (man, which, whereis, whatis). 9. Identify system users (who, finger). 10. Change shells (csh, sh) June 1, 1999 UNIX - Basic Environment 2

Workstation Components l Hardware n n n June 1, 1999 Monitor CPU Keyboard Mouse / pad File Server UNIX - Basic Environment 3

Network Environment l Typical Network Backbone LAN Router WS l WS WS Other LANs Types of Networks Gateway Internet Local Area Network - LAN è Campus è Wide Area è June 1, 1999 UNIX - Basic Environment 4

UNIX - Software l l l Multi-tasking Multi-user UNIX Flavors Berkeley (BSD) è AT&T (System V) è June 1, 1999 UNIX - Basic Environment 5

Structure of UNIX l l Hardware Kernel Utilities Shell June 1, 1999 UNIX - Basic Environment 6

Logging On l Every user has a unique name associated with a password: host login: dhk Password: host% l (password not echoed) Message of the Day displayed June 1, 1999 UNIX - Basic Environment 7

Message of the Day - MOTD l Advise users of important activities regarding the computing environment. è l /etc/motd Must be kept current or users start ignoring. June 1, 1999 UNIX - Basic Environment 8

Log Off l Either ^d or the command logout if: n n l set ignoreeof is defined in. cshrc file Problems logging out: n n June 1, 1999 There are stopped jobs (Interrupted jobs) Not login shell (type exit then logout) UNIX - Basic Environment 9

The UNIX Shell l Command Interpreter - identifies the program to run and data streams to connect to it (file expansion). June 1, 1999 host% cd host% (successful) host% cxmod: command not found (unsuccessful) UNIX - Basic Environment 10

The UNIX Shell l l Programming - Shell Scripts Files containing commands: #!/bin/sh echo -n "Enter desired root = " read root ls -l $root/* > x sort +5 n -r x | more -10 June 1, 1999 UNIX - Basic Environment 11

The UNIX Shell l l Customize Sessions & Environments Establish "dot" files" n n n June 1, 1999 . cshrc. login. profile UNIX - Basic Environment 12

Different Shells l l l The C-Shell (%) provides for good interactive control through History and Job Control. The Bourne Shell ($) has some attributes that make it well suited for scripts. The Korn Shell ($) is fully compatible with the Bourne shell and has several added features that emulate the C-Shell. June 1, 1999 UNIX - Basic Environment 13

Changing Shells l Change to another shell interactively with the shell commands: sh changes to the Bourne shell è csh changes to the C shell è tcsh changes to the T shell è bash changes to the Bourne Again shell è exit reverts to the previous shell (or logs out if in the login shell) è June 1, 1999 UNIX - Basic Environment 14

UNIX Prompts l Identifies the "shell" you are operating in: n n n l % C-Shell or T-Shell $ Bourne Shell # Root (super user) System checks the /etc/passwd file to determine default shell: ths: K/z. Y 94 QSf: 1059: 8010: ted smith, 081347: /u 3/ths: /bin/tcsh June 1, 1999 UNIX - Basic Environment 15

UNIX Prompts l Host name prefixed to prompt to identify "current" host: è è June 1, 1999 host% mode: ~> UNIX - Basic Environment 16
![UNIX Command Line l Syntax command [options] filename. . . cp l l l UNIX Command Line l Syntax command [options] filename. . . cp l l l](http://slidetodoc.com/presentation_image_h2/46ad00bba89d11bf715f4b0a44ba5bba/image-17.jpg)
UNIX Command Line l Syntax command [options] filename. . . cp l l l -i /etc/passwd lowercase options preceded with a - (minus) spaces are important June 1, 1999 UNIX - Basic Environment 17

UNIX Command Line l To continue a command on next line use a backslash () <RETURN> grep "ldf -e rgb" /usr/tmp/ths/sub 1 | sort +4 > ~abc/doc/for. team 5 l Commands on same line separated by semicolon (; ) mv passwd file. b ; cp file. b file. d June 1, 1999 UNIX - Basic Environment 18

Special Keyboard Characters l l l <RETURN> (completes a command line) <BACKSPACE> ^H <DELETE> ^? <CONTROL> (^c ^z ^d) <ESCAPE> (or as defined by specific utility) <SPACEBAR> June 1, 1999 UNIX - Basic Environment 19

Changing The Backspace l l The delete key was established as the backspace/erase function by the. login file. It can be changed interactively with the stty command: è l Displays as: è l stty erase [shift-backspace]<RETURN> stty erase ^H Effective only for the current session. June 1, 1999 UNIX - Basic Environment 20

Changing Passwords l l Change yearly Ground Rules June 1, 1999 UNIX - Basic Environment 21

Network Information Services l NIS host% passwd Changing passwd for userid Old password: New password: Retype new password: NIS passwd changed on fileserver host% l Changes /etc/passwd file June 1, 1999 UNIX - Basic Environment 22

The Password File l l Lists all users of the system and attributes Available on some systems from the path: /etc/passwd l Execute the following to bring a copy into your home directory and view it: cp ~chidhkra/passwd. cat passwd June 1, 1999 UNIX - Basic Environment 23

Sample passwd File: sunclass 1% more passwd root: 5 I 2 ESd. PMj 6 rhc: 0: 1: Operator: /: /bin/csh daemon: *: 1: 1: : /: sys: *: 2: 2: : /: /bin/csh bin: *: 3: 3: : /bin: uucp: *: 4: 8: : /var/spool/uucppublic: sysdiag: *: 0: 1: Old System Diagnostic: /usr/diag/sysdiag/sysdiag sundiag: *: 0: 1: System Diagnostic: /usr/diag/sundiag/sundiag nobody: No. Login. Allowed: -2: Account with no privelege: /tmp: /bin/csh dao: dn 2 dbqt. Ic. Z/9 I: 323: 8006: Debbie Ortiz, 090112: /home/sunclass 1/dao: /bin/csh psn: 1 z. s. Mh 0 vow 65 w: 7500: 8008: Paul Norris, c-8, 087500: /home/sunclass 1/psn: /bin/csh pam: *: 1016: 8008: Pat Max: /home/sunclass 1/pam: /bin/csh pav: B 7 Sdc. WEc. Se. KSU: 1002: 8006: Pat Vucenic: /home/sunclass 1/pav: /bin/csh ths: 6 q 3 y/n 8 TQ: 1059: 8006: Ted Spitzmiller, 081347, 8006 x 33 d: /home/sunclass 1/ths: /bin/csh June 1, 1999 UNIX - Basic Environment 24

Learning More About UNIX l l UNIX Reference Manual - URM Print and Online Consists of sections: 1 Commands 2 System Calls 3 Library Routines 4 Special Files and Devices 5 File Formats Macros & Misc. Tables 6 Games & Demos 7 Troff 8 System Maintenance June 1, 1999 UNIX - Basic Environment 25

User Reference Manual l Each entry consists of the following elements: *NAME *SYNOPSIS *DESCRIPTION SYSTEM V SYNOPSIS OPTIONS SYSTEM V OPTIONS FILES SEE ALSO DIAGNOSTICS BUGS *present for all commands June 1, 1999 UNIX - Basic Environment 26

On-line Documentation l Example - What information is there for rm? host% man rm NAME rm, rmdir - remove (unlink) files or directories SYNOPSIS rm [-] [-fir] filename. . . rmdir directory. . . DESCRIPTION rm removes (directory entries for) one. . . rmdir removes each named directory. . . OPTIONS ln(1), su(1) . . . June 1, 1999 UNIX - Basic Environment 27

On-line Documentation l MAN -K KEYWORD prints one-line summaries of all commands whose table of content entries contain any of the keywords. host% man -k password passwd (1)- change user password passwd (5)- password file vipw (8)- edit the password file getpass (3)- read a password yppasswd (1)- change login password in yellow pages host% man 5 passwd June 1, 1999 UNIX - Basic Environment 28

Identifying Which Command l Using which host% which passwd /usr/local/bin/passwd host% which lo lo: aliased to exit host% which xyz: Command not found. June 1, 1999 UNIX - Basic Environment 29

Which Path? l l l Whereis will show the locations of the utility Use full pathname Change the order of directories in path echo $PATH Whatis gives quick description June 1, 1999 UNIX - Basic Environment 30

Identifying UNIX Users l The finger command gives the ability to view detailed information about other users: host% finger spitzmiller Login name: ths In real life: Ted Spitzmiller Directory: /scc/users/ths Shell: /usr/bin/tcsh On since Apr 11 10: 33: 53 on pts/15 from pcted. lanl. gov June 1, 1999 UNIX - Basic Environment 31

Identifying UNIX Users l The who command identifies current users who are logged on: host% who rbarrett ahg ttyp 1 jbp ttyp 2 jimm ttyp 3 operator cadams ttyp 7 June 1, 1999 ttyp 0 Apr 02 ttyp 6 Apr 15 Apr 03 08: 27 08: 58 08: 52 Apr 02 10: 28 UNIX - Basic Environment 13: 46 (spam. lanl. gov) (penning. lanl. gov) (telemachus. lanl. ) (ts 800 -1 -tig. lanl) 09: 20 (ibm-op) (maccda 2. mst. lanl) 32

End of Module Complete Getting Logged on to Unix June 1, 1999 UNIX - Basic Environment 33
- Slides: 33