Title: Introduction to UNIX System
1Introduction to UNIX System
2Introduction
- Developed at Bell Laboratories in the late 1960s
by Dennis Ritchie and Ken Thompson - Shell is simply a program that reads in the
commands you type and converts them into a form
that is more readily understandable by the UNIX
system
3Introduction (continue.)
- Shell includes some fundamental programming
constructs that let you make decisions, loop, and
store values in variables - Bourne shell was written by Stephen Bourne in
Bell laboratories - Bourne shell is the standard shell
4UNIX System
- The UNIX system is logically divided into two
pieces - Kernel
- Utilities
5UNIX System (continue.)
- Kernel is the heart of the UNIX system and
resides in the computers memory
Utilities
UNIX system kernel
disks
Memory
6UNIX System (continue.)
- Utility resides on the computers disk and are
only brought into memory as requested. - Virtually every command under UNIX is a utility
- Shell is a utility program loaded into memory for
execution whenever you log into the system
7Logging in a UNIX system
- Terminal is connected to a UNIX system through
- Direct wire
- Modem
- LAN
- After you connect the UNIX system a login
message appears
8Logging in a UNIX system (continue.)
9Logging in a UNIX system (continue.)
- init is the UNIX system
- init automatically starts up a getty program on
each terminal port whenever the system is
allowing users to log in - After getty displays the message login and some
types the usernames followed by RETURN, it starts
up a program called login to finish the process
of logging in. Then getty disappears - /etc/passwd file has one line per user
10Logging in a UNIX system (continue.)
login Skan password
UNIX SYSTEM KERNEL
login
login
getty
getty
login
11Logging in a UNIX system (continue.)
- After login begins execution, Password message
appears - User types the password and hits RETURN
- The user name and the password will be checked
against the corresponding entry in the file
/etc/passwd
12Logging in a UNIX system (continue.)
- Every line has seven fields separated by .
- The fields are
- Login name
- Password (encrypted form).
- User ID
- Group ID
- User information which could be First and Last
name, etc - Home directory
- Program to start up when user logs in. Usually a
shell program
13Logging in a UNIX system (continue.)
cat /etc/passwd rootx01Super-User//sbin/sh
daemonx11/ binx22/usr/bin sysx33
/ admx44Admin/var/adm lpx718Line
Printer Admin/usr/spool/lp uucpx55uucp
Admin/usr/lib/uucp nuucpx99uucp
Admin/var/spool/uucppublic/usr/lib/uucp/uucico l
istenx374Network Admin/usr/net/nls nobodyx
6000160001Nobody/ noaccessx6000260002No
Access User/ nobody4x6553465534SunOS 4.x
Nobody/ oracle10167DBA Account/export/home
/oracle/bin/csh webuser102102Web
User/export/home/webuser/bin/csh abuzneidx103
100Abdelshakour Abuzneid/home/abuzneid/sbin/csh
14Logging in a UNIX system (continue.)
login Skan password
UNIX SYSTEM KERNEL
/bin/sh
login
login Med password
/usr/lbin/ksh
/usr/data/bin /dat_entry
login
login slim password
15After Shell starts
- When shell starts up, it displays a command
prompt - in Bourne shell and Korn shell
- in C shell
- Shell goes to sleep after every command or
program followed by RETUN until the program has
finished - This copied program is called a process
16After Shell starts (continue.)
shell
shell
ls
1.
2.
3.
4.
ls
shell
Foo rje
ls Foo rje
7.
8.
6.
5.
17Login cycle
init
init
init
getty
init
sh
init
login
18Login cycle (continue.)
19Responsibilities of Shell
- Program Execution
- Variable and File Name Substitution
- I/O Redirection
- Pipeline Hookup
- Environment Control
- Interpreted Programming Language
20Program Execution
- Format program-name arguments
- The shell scans the command line and determines
the name of the program to be executed and what
argument to pass to the program - Multiple occurrences of white spaces characters
are simple learned
21Program Execution (continue.)
- mv oldfile newfile
- echo Smile, you are in Bridgeport City
- Smile, you are in Bridgeport City
-
oldfile newfile
mv
arguments
Smile, you are in Bridgeport City
echo
arguments
22Program Execution (continue.)
- Shell has some built_in commands which execute
them directly without searching the disk - cd, pwd and echo are built_in commands
23Variables and File Name Substitution
- assign values to variables
- listls
- ls
- Carthage
- Damas
- list
- Carthage
- Damas
- file name substitution on the command line
-
- ?
24Variables and File Name Substitution (continue.)
ls Documents Memos mail personal
25Variables and File Name Substitution (continue.)
echo Documents Memos mail personal
Documents Memos mail personal
arguments
echo
26Variables and File Name Substitution (continue.)
ls Documents mail Documents a.doc c.doc p1
p11 mail p1 p2
27Input/Output Redirection
wc -l list 2 list wc -l 2
28Input/Output Redirection (continue.)
-l users
wc
arguments
wc
-l
arguments
29Input/Output Redirection (continue.)
- In the first command line, two arguments where
passed to wc (word count) utility -l and users - In the second command line, one argument is
passed to wc utility -l. This gives the
indication that the number of lines appearing on
standard input is to count
30Pipeline Hookup
- Connects to commands
- Pipe characters
-
-
- Connects the standard output from the command
preceding to the standard input of the one
following the
31Pipeline Hookup (continue.)
- Example
- who wc -l
- Counts the number of users login to the system by
connecting the standard output of who to the
standard output for wc
32Environment Control
- Shell provides variables that customize the
environment - Examples
33Interpreted Programming Language
- The shell has its own built_in programming
language - This language is interpreted shell analyzes each
statement in the language one line at a time and
then execute it - Different than high level programming language
like C/C where the programming statements are
typically compiled into a machine_executable form
they are executed
34References
- UNIX SHELLS BY EXAMPLE BY ELLIE QUIGLEY
- UNIX FOR PROGRAMMERS AND USERS BY G. GLASS AND K
ABLES - UNIX SHELL PROGRAMMING BY S. KOCHAN AND P. WOOD