CHAPTER 1 –
INTRODUCING UNIX
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.1 The Operating System
2
A software that manages the hardware and
provides the environment for programs to run
Manages computer resources
Acts as a control program
Provides an interface to the user
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.1 The Operating System (continued)
3
How a Program Runs on a Computer:
OS Allocates memory and loads the program in it.
loads the CPU registers with control information.
OS keeps track of the executed instruction.
OS access hardware on behalf of the program.
OS saves the state of the program if the program
has to leave CPU temporarily.
After the program has completed execution, the
OS cleans up the memory and registers and
makes them available for the next program.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.1 The Operating System (continued)
4
Modern OS are:
1. multiprogramming
Allows multiple programs to reside in memory at the
same time
2. multiuser
It allows the machine to serve multiple users
3. multitasking
a single user can run multiple programs
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.2 UNIX Operating System
5
Written in C. It is not assembler.
portable
offers a rich set of programming tools to aid in
developing, debugging, and maintaining programs.
One of these program is the command’s interpreter,
called the shell
Interaction with UNIX system is through the shell.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.3 Knowing your Machine
6
Unlike Windows, UNIX can used by many users
concurrently
Users can use dumb terminals or their PC’s to access a
central UNIX computer
You can have a standalone UNIX machine. However,
you are often connected to a large, more powerful
computer
Why?
It is administered properly (backup, security, …)
Has more Powerful processing and memory
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.4 The System administrator
7
On a large system serving hundreds of users,
someone has to be in-charge of administering the
system.
Responsible for the management of the entire
setup.
allocating user accounts, maintain file systems, and
perform several other important functions.
If you run some flavor of UNIX on your machine,
then you are probably its administrator.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.7 Unix Variants
8
BSD, Free BSD from Berkley Software Design
SunOS and Solaris from Sun Microsystems
AIX from IBM
HP-UX from HP
Tru64 UNIX from DEC
IRIX from Silicon Graphics
MAC OS X from Apple
Linux and other Open Source variants
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.8 POSIX
9
Absence of a single conforming standard
affected the development of portable
applications.
The Portable Operating System Interface for
Computer Environment (POSIX) was developed
by IEEE
refers to OS in general, but was based on UNIX
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.9 Linux and GNU
10
Linux is free and distributed under the GNU
General Public License
Most popular flavors: Ubuntu, Fedora, ….
Can be downloaded free
Try to install a copy on your machine.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.10 The UNIX Architecture
11
Kernel
Shell
File and Process
System Calls
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
The kernel
12
Interacts with the machine’s hardware
It is the core of the OS
User’s applications communicate with the kernel via
system calls in order to access the hardware
Only one copy shared by all users.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
The shell
13
Commands Interpreter
Invoked only when the user logs in.
Responsible for executing user commands
One kernel – several shells
Examines the keyboard input (command) for special
characters prior to communicating with the kernel
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
The File and Process
14
Files
Containers for storing static information
Directories and devices are also files
Files are related to other files by being a part of single
hierarchical structure called file system
Process
A program in execution
Dynamic – resembles living organisms (born and die)
Also forms hierarchy – when a process is a child of another
process
UNIX provides tools to control processes
move them between foreground and background
or kill them
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
The System Calls
15
Programs access the kernel services by invoking
special functions called system calls
C programmers can not use system call on Windows
system; instead Windows system use the standard
library functions for everything
In UNIX, users have access to both.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
The UNIX Architecture- Summary
16
Everything in the system is represented as a file.
Work gets done by processes.
Workload is shared by two separate programs
(kernel and shell).
Kernel uses system calls to do most of the work.
All UNIX systems use the same system calls.
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.11 Features of UNIX
17
1. A multiuser system
These programs can be run by different users
Kernel uses the principle of time sharing
2. A multitasking system
A user can edit a file, print another one, send email to a friend, and
browse WWW – without leaving any of the applications
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.11 Features of UNIX (cont.)
18
3. Repository of Applications
Host of applications shipped with UNIX system
New tools are being added
4. The Building block
shell offers a mechanism called the pipe that allows the
output of one command to server as input to another
Explains why most commands are NOT interactive
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
1.11 Features of UNIX (cont.)
19
5. Pattern Matching
Use special characters to match a number of characters
6. Programming Facility
These features are used to design shell scripts
7. Documentation
The online help facility – man commands
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
Connecting via a UNIX Terminal
20
From your terminal( you should have a network
connection to the server) enter
IP address of the UNIX server (or hostname)
Then you got a screen to fill your username and
password
login: your_username <Enter>
password: your_password <Enter>
$
Now you are ready to enter commands.
The symbol $ is the shell symbol, it might be different on your system
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
A Hands-On Session (simple commands)
21
UNIX is case sensitive; and commands are generally in
lowercase; so date and DATE are not the same
Every UNIX system maintains an internal clock; you can access
it with a single command named date:
$ date
View the list of current users with the who
$ who
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
A Hands-On Session (simple commands)
22
Deleting files with rm
$rm [Link]
Creating directories with mkdir
$mkdir scripts
Try the command ls –F and explain the resulting output
copy files inside directories
$cp foo scripts
Directory navigation with cd and pwd
$pwd
$cd scripts
$pwd
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem
A Hands-On Session (simple commands)
23
Display file content with cat
$ cat foo
Copying files with cp
$cp foo [Link]
Deleting files with rm
$rm [Link]
Creating directories with mkdir
$mkdir scripts
Try the command ls –F and explain the resulting output
copy files inside directories
$cp foo scripts
Directory navigation with cd and pwd
$pwd
$cd scripts
$pwd
$ls
$cd /home
NES 202 : Introduction to UNIX, Done By : Eng. Rana AlQurem