Documente Academic
Documente Profesional
Documente Cultură
Day 1
Course Objective
To introduce the Unix Operating System To develop an ability to use general Unix commands To develop ability to write programs in shell To develop ability in using Unix utilities To introduce the security issues in Unix
References
Brain W. Kernighan and Rob Pike, The UNIX Programming Environment. Stephen Prata, Advanced UNIX - A Programmers Guide. Stephen G. Kochan and Patrick H. Wood, Exploring the Unix System. James R. Groff, Paul N. Weinberg , Understanding Unix - A conceptual guide. Maurice J. Bach, The Design of the Unix Operating System
Session Plan
Day 1
Introduction to Unix Unix System Architecture Basic Unix Commands Processes in Unix Regular Expressions Introduction to vi editor
Session Plan
Day 2
Text Processing Commands Process oriented Commands File Handling Commands Types of Shell Shell Programming
Session Plan
Day 3
Unix Utilities Unix Program Development Tools Unix Communication Security Features
Introduction to Unix
What is Unix
Unix is a very popular multi-user, multitasking, time-sharing operating system
Evolution of Unix
Started in 1965 when AT&T, GE, IBM and Project MAC joined together to develop a time-sharing system named MULTICS (Multiplexed Information and Computing Service)
Introduction to Unix
Flavors of Unix
AIX (Advanced IBM Unix)
HP-UX ( Hewlett Packard Unix) MINIX (Minimal Unix) SCO UNIX SOLARIS XENIX LINUX, etc
Features Of Unix
The important characteristic features are
Portability
Unix has been re-written in C , hence it can run on machines from microcomputers to mainframe computers
Security
Without the proper username and passwords, it is not possible to work on Unix
Background Processing
Jobs/Tasks are executed in the background with the minimal interaction from the user
Pipes
Work with multiple commands at the same time
Copyright 2005, Infosys Technologies Ltd # ER/CORP/CRS/OS31/003 Version No: 1.00
Communication
Unix has commands which allow communication between different users connected to the system
Shells
Unix has different types of shells .viz. Bourne, C, Korn, etc
System Architecture
Major components of Unix are :
Kernel
Monitors and controls the resources of a computer and allocates them among its users in an optimal manner
Shell
Provides a processing environment for the user programs and acts like a command translator
Utilities
Programs which are used for development purposes
User Applications
Programs written by the user
System Architecture
User
SHELL
UNIX
User
SHELL
OTHER APPLICATIONS
COMMANDS
HARDWARE
DATABASE
PACKAGES
KERNEL
COMPILERS
SHELL
SHELL
User
User
Processing Environment
User Program
Set of instructions written by the user
Process
Instance of a program under execution
Shell
Provides a processing environment for the user programs
/ (root)
home bin sh
dev ls tty lp
etc
tmp
lib
usr
passwd shadow
Note: Different variants of UNIX differ slightly in the file system structure. But some of the basic folders are still the same.
Another directory
file1 file2
Login Sequence.
Login id and password The /etc/passwd file and /etc/shadow file The /etc/profile file Shell prompt
System Settings.
The $PATH variable
Shows the location of executables
Aliases
Allows alternate name for commands
ls [option] [filenames]
t r t
t r t
C B A @9 C B A @9
S R QPI
whoami
H G F ED
Processes in Unix
Process:
Instance of an application in memory
Mi o o o u o n
Standard Files
Standard Input (0)
This file is opened by shell to accept information.
VU
Pipes
Output of one program is piped as input to another program
Special Files
/dev/tty
It is used to display on the terminal
/dev/null
This file is used to suppress the output from being displayed Used for suppressing error messages from being displayed on the screen in programs
Mi r s t
e dcb WXa X` YX X W
rd t
Regular Expressions
What is it?
String of ordinary and metacharacter which can be used to match more than one type of pattern. Uses character set
* , [], ^, $, {}, etc.
Mi r s t
t srq fgp gi hg g f
rd t
Unix.
The Vi Editor.
Editor in Unix
Need for editor in Unix Types of editor
Line Editor
ed : UC Berkeley ex : Powerful than ed, Bell Systems
The vi Editor.
The important characteristic features are:
Omnipresent
Works on different Unix flavors
Fast
Various operations are very fast
The vi Editor.
The limitations are:
Less user-friendly
No graphical user interface
Highly Case-sensitive
Letter in small case has a different implementation in comparison with the same letter in upper case
The vi Editor.
Modes of working:
Command Mode
Keys are interpreted as commands
Insert Mode
Keys are interpreted as data
Escape Mode
Keys are interpreted for saving/exiting purposes
vi Operating modes.
i, I , o, O, a, A ..
Command mode :
Enter esc
Insert mode
Escape mode
:q
Vi editor commands
To move around
h, j, k, l, ^D, ^U, G, 0, ^, $, w, b
Inserting/Deleting text
i, a, I, A, r, R, o, O, dd, dw, c$, D, x, X.
Changing/Replacing text.
cc, cw, c$, ~, J, u, . , yy, yw, p, P
File manipulation.
:w, :wq, ZZ, :w!, :q, :q! , :![command]
Searching a pattern
/pattern
Searches forward for first occurrence of a pattern.
?pattern
Searches backward for first occurrence of a pattern.
n
Repeats the last search.
N
Repeats the last search command in opposite direction.
Pattern Substitution.
:s/ptn1/ptn2
Replaces first occurrence of ptn1 with ptn2.
: s/ptn1/ptn2/g
Replaces all occurrences in the current line.
: m, n s/ptn1/ptn2/g
Replaces all occurrences in lines m to n.
: ., $ s/ptn1/ptn2/g
Replaces all occurrences from current line to end of file.
Customizing vi.
The set command
:set all :set nu
Vi Startup File
.exrc
vi reads .exrc before loading settings are permanent for a vi session
:n
Permits editing of next file in the buffer
: rew
Permits editing of first file in buffer
: args
Displays names of all files in the buffer
:f
Displays the name of the current file
Copyright 2005, Infosys Technologies Ltd # ER/CORP/CRS/OS31/003 Version No: 1.00
System Variables.
PATH
Search path referred by Unix for any command. echo $PATH
HOME
Indicates the home directory for the user. echo $HOME
y u u x w v
# ER/CORP/CRS/OS31/003 Version No: 1.00
PS2
Used for changing the secondary prompt.
Mi r s t
rd t
set command.
set command
Used for display all the environment variables. Shows the current values of system variables. Also allows conversion of arguments into positional parameters. Syntax : set
Mi r s t
rd t
man command.
A screenshot of the man command. Syntax: man <command name>
[ ] indicates optional content
Summary
Background Features of Unix Unix System Architecture Unix File System General Unix commands and utilities Processes Regular Expressions Vi Editor Modes of operation
Copyright 2005, Infosys Technologies Ltd # ER/CORP/CRS/OS31/003 Version No: 1.00
Thank You!
Copyright 2005, Infosys Technologies Ltd # ER/CORP/CRS/OS31/003 Version No: 1.00