330 likes | 339 Views
This module provides an introduction to UNIX, covering topics such as the four functional parts of UNIX, C Shell functions, logging on/off, viewing MOTD, basic UNIX prompts, parsing command lines, erasing typing errors, changing passwords, using online documentation, identifying system users, and changing shells.
E N D
Introduction to UNIX A. Basic Environment UNIX - Basic Environment
Performance Objectives Capabilities you should be able to perform following this module. 1. Describe the four functional parts of UNIX. 2. List three primary functions of the C Shell. 3. Log ON/OFF, view MOTD (logout, exit, sync). 4. Identify basic UNIX Prompts (% $ #). 5. Parse a UNIX command line. 6. Erase typing errors (stty erase). 7. Change passwords, (passwd). 8. Use Online Documentation (man, which, whereis, whatis). 9. Identify system users (who, finger). 10. Change shells (csh, sh) UNIX - Basic Environment
Workstation Components • Hardware • Monitor • CPU • Keyboard • Mouse / pad • File Server UNIX - Basic Environment
Network Environment • Typical Network • Types of Networks • Local Area Network - LAN • Campus • Wide Area Backbone LAN Router WS WS WS Gateway Other LANs Internet UNIX - Basic Environment
UNIX - Software • Multi-tasking • Multi-user • UNIX Flavors • Berkeley (BSD) • AT&T (System V) UNIX - Basic Environment
Structure of UNIX • Hardware • Kernel • Utilities • Shell Hardware Kernel Utilities Shell UNIX - Basic Environment
Logging On • Every user has a unique name associated with a password: host login: dhk Password: (password not echoed) host% • Message of the Day displayed UNIX - Basic Environment
Message of the Day - MOTD • Advise users of important activities regarding the computing environment. • /etc/motd • Must be kept current or users start ignoring. UNIX - Basic Environment
Log Off • Either ^d or the command logout if: • set ignoreeof • is defined in .cshrc file • Problems logging out: • There are stopped jobs (Interrupted jobs) • Not login shell (type exit then logout) UNIX - Basic Environment
The UNIX Shell • Command Interpreter - identifies the program to run and data streams to connect to it (file expansion). host% cd host% (successful) host% cxmod cxmod: command not found (unsuccessful) UNIX - Basic Environment
The UNIX Shell • Programming - Shell Scripts • Files containing commands: #!/bin/sh echo -n "Enter desired root = " read root ls -l $root/* > x sort +5n -r x | more -10 UNIX - Basic Environment
The UNIX Shell • Customize Sessions & Environments • Establish "dot" files" • .cshrc • .login • .profile UNIX - Basic Environment
Different Shells • 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. UNIX - Basic Environment
Changing Shells • 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) UNIX - Basic Environment
UNIX Prompts • Identifies the "shell" you are operating in: • % C-Shell or T-Shell • $ Bourne Shell • # Root (super user) • System checks the /etc/passwd file to determine default shell: ths:K/zY94QSf:1059:8010:tedsmith,081347:/u3/ths:/bin/tcsh UNIX - Basic Environment
UNIX Prompts • Host name prefixed to prompt to identify "current" host: • host% • mode:~> UNIX - Basic Environment
UNIX Command Line • Syntax command [options] filename ... cp -i /etc/passwd passwd • lowercase • options preceded with a - (minus) • spaces are important UNIX - Basic Environment
UNIX Command Line • To continue a command on next line use a backslash (\) <RETURN> grep "ldf -e rgb" /usr/tmp/ths/sub1 | sort +4 >\ ~abc/doc/for.team5 • Commands on same line separated by semicolon (;) mv passwd file.b ; cp file.b file.d UNIX - Basic Environment
Special Keyboard Characters • <RETURN> (completes a command line) • <BACKSPACE> ^H • <DELETE> ^? • <CONTROL> (^c ^z ^d) • <ESCAPE> (or as defined by specific utility) • <SPACEBAR> UNIX - Basic Environment
Changing The Backspace • The delete key was established as the backspace/erase function by the .login file. • It can be changed interactively with the stty command: • stty erase [shift-backspace]<RETURN> • Displays as: • stty erase ^H • Effective only for the current session. UNIX - Basic Environment
Changing Passwords • Change yearly • Ground Rules UNIX - Basic Environment
Network Information Services • NIS host% passwd Changing passwd for userid Old password: New password: Retype new password: NIS passwd changed on fileserver host% • Changes /etc/passwd file UNIX - Basic Environment
The Password File • Lists all users of the system and attributes • Available on some systems from the path: /etc/passwd • Execute the following to bring a copy into your home directory and view it: cp ~chidhkra/passwd . cat passwd UNIX - Basic Environment
Sample passwd File: sunclass1% more passwd root:5I2ESdPMj6rhc: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:/usr/diag/sysdiag/sysdiag sundiag:*:0:1:System Diagnostic:/usr/diag/sundiag:/usr/diag/sundiag/sundiag nobody:NoLoginAllowed:-2:-2:Account with no privelege:/tmp:/bin/csh dao:dn2dbqtIcZ/9I:323:8006:Debbie Ortiz, 090112:/home/sunclass1/dao:/bin/csh psn:1z.sMh0vow65w:7500:8008:Paul Norris, c-8, 087500:/home/sunclass1/psn:/bin/csh pam:*:1016:8008:Pat Max:/home/sunclass1/pam:/bin/csh pav:B7SdcWEcSeKSU:1002:8006:Pat Vucenic:/home/sunclass1/pav:/bin/csh ths:6q3y/n8TQ:1059:8006:Ted Spitzmiller,081347,8006x33d:/home/sunclass1/ths:/bin/csh UNIX - Basic Environment
Learning More About UNIX • 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 UNIX - Basic Environment
Each entry consists of the following elements: *NAME *SYNOPSIS *DESCRIPTION SYSTEM V SYNOPSIS OPTIONS *present for all commands SYSTEM V OPTIONS FILES SEE ALSO DIAGNOSTICS BUGS User Reference Manual UNIX - Basic Environment
On-line Documentation • 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) ... UNIX - Basic Environment
On-line Documentation • 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 UNIX - Basic Environment
Identifying Which Command • Using which host% which passwd /usr/local/bin/passwd host% which lo lo: aliased to exit host% which xyz xyz: Command not found. UNIX - Basic Environment
Which Path? • Whereis will show the locations of the utility • Use full pathname • Change the order of directories in path • echo $PATH • Whatis gives quick description UNIX - Basic Environment
Identifying UNIX Users • 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 UNIX - Basic Environment
Identifying UNIX Users • The who command identifies current users who are logged on: host% who rbarrett ttyp0 Apr 03 13:46 (spam.lanl.gov) ahg ttyp1 Apr 02 08:27 (penning.lanl.gov) jbp ttyp2 Apr 02 08:58 (telemachus.lanl.) jimm ttyp3 Apr 02 08:52 (ts800-1-tig.lanl) operator ttyp6 Apr 02 09:20 (ibm-op) cadams ttyp7 Apr 15 10:28 (maccda2.mst.lanl) UNIX - Basic Environment
End of Module Complete Getting Logged on to Unix UNIX - Basic Environment