15CS35 SEMESTER III 04082016 Syllabus and course outcomes Link for syllabus Operating system The o perating s ystem OS is the most important program that runs on a computer ID: 750166
Download Presentation The PPT/PDF document "Unix and shell programming -" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Unix and shell programming - 15CS35
SEMESTER – III
04-08-2016Slide2
Syllabus and course outcomes
Link for syllabusSlide3
Operating system
The
o
perating
s
ystem (
OS
)
is the most important program that runs on a computer.
Every
general-purpose computer must have an operating system to run other programs and
applications
.
It is like a traffic cop -- it makes sure that different programs and
users
running at the same time do not interfere with each other.
The
operating system is also responsible for
security
,
it ensuring
that unauthorized users do not
access
the system.Slide4
DiagramSlide5
Classification of Operating systems
Multi-user
:
Allows two or more users to run programs at the same time. Some operating systems permit hundreds or even thousands of concurrent users.
Multiprocessing
:
Supports running a program on more than one
CPU
.
Multitasking
:
Allows more than one program to run concurrently.
Multithreading
:
Allows different parts of a single program to run concurrently.
Real
time
:
Responds to input instantly. Slide6
overview
Operating systems
provide a
software
platform
on top of which other
programs
, called
application
programs,
can
run
The application programs must be written to run on top of a particular operating system.
Slide7
Interacting With the Operating System
As a user, you normally interact with the operating system through a set of
commands
.
For example, the DOS operating system contains commands such as COPY and RENAME for
copying
files and changing the
names
of files, respectively
The commands are accepted and
executed
by a part of the operating system called
the
command
processor
or command line interpreter.
Graphical user interfaces
allow you to enter commands by pointing and
clicking
at
objects
that appear on the screen. Slide8
System
A
group of interdependent items that interact regularly to perform a task
.
A
computer system
refers to the
hardware
and
software
components that run a computer or computers.
An
information
system
is
a system that collects and stores data.
System
often simply refers to the
operating system
. Slide9
Operating systemSlide10
Definition
An
operating system
(
OS
)
Is
system software
that manages
computer hardware
and
software
resources and provides
common
services
for
computer programs
.
Application programs
usually require an operating system to function. Slide11
Types of operating systems
Single- and multi-tasking
A single-tasking system can only run one program at a time, while a
multi-tasking
operating system allows more than
one
program to be running in concurrency.
Single- and multi-user
Single-user operating systems have no facilities to distinguish users, but may allow multiple programs to
run.
A
multi-user
operating system extends the basic concept of multi-tasking with facilities that identify processes and resources Slide12
Continued…..
Distributed
A
distributed operating system
manages a group of distinct computers and makes them appear to be a single computer.
Embedded
Embedded operating systems
are designed to be used in
embedded computer systems
. They are designed to operate on small machines Slide13
Clear picture on what we understood Slide14
Memory Management
Memory management refers to management of Primary Memory or Main Memory.
Main memory is a large array of words or bytes where each word or byte has its own address.
Main memory provides a fast storage that can be accessed directly by the CPU.
For
a program
to be executed, it must in the main memory.
Allocates the memory
and
De-allocates the memory Slide15
Processor Management
In multiprogramming environment, the OS decides which process gets the processor when and for how much time.
This function is called
process scheduling
.
An operating system keep track of Keeps tracks of processor and status of process.. Also it Allocates and
De-allocates
the processor (CPU) to a process
.Slide16
Device Management
An Operating System manages device communication via their respective drivers.
OS does:
Keeps tracks of all devices. Program responsible for this task is known as the
I/O controller
.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient
way and De-allocates
devices.Slide17
File Management
A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions.
OS does:
Keeps track of information, location, uses, status etc. The collective facilities are often known as
file system
.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.Slide18
Other Important Activities of OS
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other
software's
and users
Slide19
Components of Unix System
Unix
Operating System has primarily three components
Kernel
− Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware.
System Library
− System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features.
System Utility
− System Utility programs are responsible to do specialized, individual level tasks.Slide20
What is Unix ?
The UNIX operating system is a set of programs that act as a link between the computer and the user
.
The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel
.
Users
communicates
with the kernel through a program known as the shell.
The
shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel
.
Unix
was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis
RitchieSlide21
Continued…
There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples. Linux is also a flavor of Unix which is freely available
.
Several
people can use a UNIX computer at the same time; hence UNIX is called a multiuser system
.
A user can also run multiple programs at the same time; hence UNIX is called multitasking.Slide22
Following are some of the important features of Unix Operating
System
Portable
Open Source
Multi-User
Multiprogramming
Hierarchical File System
Shell
Security Slide23
ARCHITECTURESlide24
Unix ArchitectureSlide25
Components
Kernel:
The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memory management, task scheduling and file management
.
Shell:
The shell is the utility that processes your requests. When you type in a command at your terminal, the shell interprets the command and calls the program that you want.
C Shell, Bourne Shell and
Korn
Shell are most famous shells which are available with most of the Unix variants
.Slide26
Continued…
Commands and Utilities:
There are various command and utilities which you would use in your day to day activities.
cp
, mv, cat
and
grep
etc.
Files and Directories:
All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the file system.Slide27
Features
Main Features of UNIX
This section contains a brief overview of the main features of UNIX.
multi-user
more than one user can use the machine at a time supported via terminals (serial or network connection)
multi-tasking
, more than one program can be run at a time
hierarchical directory structure
, to support the
organization
and maintenance of files
portability Slide28
28
Hierarchical File SystemSlide29
Spring 2004
FSU COP 4342 Unix Tools
29
Shells
What is a shell?
A command interpreter
“protects you from the kernel”
It really protects the kernel from youSlide30
30
Many Shells
Bourne shell
(
sh
)
Creator Steve Bourne in the early 80’s
First shell Used for
shell programming
C shell
(
csh
)
Created at UCB their Unix implementation in the early 80’s
Users wanted more familiar syntax
More features (for interactive uses) than
sh
(e.g.
job control and history
)Slide31
31
Many Shells
Korn
shell
(
ksh
)
Created by David
Korn
in the mid 80’s
Compatible with
sh
but having most features of
csh
Features history editing (a.k.a. command-line editing)
Was available on System V
Public-domain version is
pdksh
T-shell
(
tcsh
)
has all
csh
features and less bugs
Bourne-again shell
(bash)
Offered by FSF (free software foundation)
Similar to
ksh
and
csh
Command-line editingSlide32
32
What’s my shell?
Check your prompt
Usually bash uses $
Usually
csh
uses %
Usually
tcsh
uses >
Superuser
“root” usually is # Slide33
UNIX Commands Structure
To give a command to a UNIX system you type the name of the command, along with any associated information, such as a filename, and press the <Return> key
.
The typed line is called the command
line
UNIX uses a special program, called the shell or the command line
interpreter
The components of the command line are:
the command;
any options required by the command
the command's arguments (if required).
For example, the general form of a UNIX command is:
command [-option(s)] [argument(s)]Slide34
POSIX Single UNIX SpecificationSlide35
Unix Commands
UNIX commands:
– Internal (
builtin
) and external command
Some
commands are internal, built into the shell.
cd
command is built-in. (the shell interprets that command and changes your current directory).
ls
command is an external program stored in the file /bin/
ls
. • The shell does not start a separate process to run
internal
commands.
External
commands require the shell to fork and exec a new
sub process
; this takes some time, especially on a busy system.
Check
a command is internal or external: – $
type cd
–
cd is a shell
builtin
Slide36
Internal and External Commands
Unix commands are grouped into two categories-
Internal
and
External
.
Internal
There
is a set of commands which are part of the shell and to execute them the shell does not need to search the given path in the
PATH
variable.
These
are also called
shell
builtins
or Internal
Commands.
External
Commands that are available as independently compiled C programs usually located in the /bin or the /
usr
/bin directory are called
External Commands.
Slide37
Spring 2004
FSU COP 4342 Unix Tools
37
Internal and External Commands
Internal commands
built into the shell
the shell performs the command
E.g.
chdir
or
cd
External commands
Require the shell to
fork
and
exec
and a
subprocess
will start
E.g.
lsSlide38
Continued…
Example
:
$ type
ls
ls
is /bin/ls
the above command returns the location or the path of the
ls
command .Therefore
ls
is an external command
.
$ type
echo
echo
is a shell
builtin
the 'echo' command is an Internal Command or a shell
builtin
.
$ type
LS
LS
: not foundSlide39
39
Summary on same
…!!
Shell checks what type of command the user is trying to run
Check if built-in
Else check if absolute path
Else check alias (except
bash
)
Check for executable in search path
Search path is a list of
dir
that the shell must check
An environment variable
PATH
lists these
dir
Look at an example
Search path is specified in the shell start up filesSlide40
System Boot-up
If you have a computer which has UNIX operating system installed on it, then you simply need to turn on its power to make it live.
As soon as you turn on the power, system starts booting up and finally it prompts you to log into the system, which is an activity to log into the system and use it for your day to day activities.Slide41
Login Unix
To log
in
Have your
userid
(user identification) and password ready. Contact your system administrator if you don't have these yet.
Type your
userid
at the login prompt, then press ENTER. Your
userid
is case-sensitive, so be sure you type it exactly as your system administrator instructed.
Type your password at the password prompt, then press ENTER. Your password is also case-sensitive.
If you provided correct
userid
and password then you would be allowed to enter into the system. Read the information and messages that come up on the screen something as below.Slide42
UISlide43
to check calendar you need to type cal command as follows −Slide44
Change Password
All Unix systems require passwords to help ensure that your files and data remain your own and that the system itself is
secure
from hackers and crackers
.
Here are the steps to change your password −
To start, type
passwd
at command prompt as shown below.
Enter your old password the one you're currently using.
Type in your new password. Always keep your password complex enough so that no body can guess it. But make sure, you remember it.
You would need to verify the password by typing it again.Slide45
UISlide46
Listing Directories and Files
All data in UNIX is organized into files.
All
files are organized into directories.
These
directories are organized into a tree-like structure called the
file system
You can use
ls
command to list out all the
files
Following
is the example of using
ls
command with
-l
option.Slide47
UISlide48
Who Are You?
While
you're logged in to the system, you might be willing to know :
Who am I
?
The easiest way to find out "who you are" is to enter the
who am
i
command
−Slide49
Who is Logged In?
Sometime you might be interested to know who is logged in to the computer at the same time.
There are three commands are available to get you this information, based on how much you'd like to learn about the other users:
users, who,
and
w
.Slide50
Logging Out
When you finish your session, you need to log out of the system to ensure that nobody else accesses your files while masquerading as you
.
just
type
logout
command at command prompt, and the system will clean up everything and break the
connectionSlide51
System ShutdownSlide52
Flexibility in using commands
$
Wc
note;
ls
–l noteSlide53
Command line can overflow
$echo “ this is
>a three line
>text message”
o/p
This is
A three line
Text message
To break – press
ctrl+zSlide54
When things go wrong
Terminal and keyboard have no uniform
behaviroul
pattern
Backspacing will not work all time
Wen you use backspace u can see ^H^H
Ctrl+h
or delete hey
Killing a line
Ctrl+u
Break by
Ctrl+d
Ctrl+zSlide55Slide56
Knowing the user terminal
About
tty
Print the
file name of the
terminal connected to
standard input
.
tty
syntax
tty
[
OPTION
]...
Options
-s
,
--silent
,
--quiet
Print nothing, only return an exit status.
--help
display this help and exit.
--version
output version information and exit. Slide57
Continued….
tty
examples
$
tty
Running
tty
by itself will display the current
tty
session as shown below:
/
dev
/pts/0Slide58
stty
About
stty
$
Stty
changes
and prints terminal line settings
.
Description
stty
displays or changes the characteristics of the terminal
.Slide59
displaying its characteristics and setting characteristicsSlide60Slide61Slide62Slide63Slide64Slide65Slide66
Root
root
is the user name or account that by default has access to all
commands and
files on a
Linux or other
Unix-like
operating system
.
The
root directory, which is the top level directory
on a
system That
is, it is the
directory in which all other directories, including their
subdirectories
and files reside. The root directory is designated by a
forward slash ( /
).
Root privileges
are the powers that the root account has on the system.
root's powers are the ability to modify the system in any way desired and to grant and revoke
access permissions
Login in terminalSlide67
Su: Acquiring superuser
status
$
su
Password:******
#
pwd
/home/
sh
Prompt changes but directory
dosen’t
From super user access we can switch to other user by using
$
su
– username
Without passwordSlide68
Administrators Privileges
Change the contents or attributes of any file like its permissions and ownerships
He can delete the file even if the directory is write protected
Initiate or kill any process
Change any user password without knowing the existing one
Set system clock with date
Address all users concurrently -----
wall
Limit the file size fir each users
Control overall access with FTP as well.Slide69
Date setting Slide70
Wall : communicating with users
It address all users simultaneously
#wall
Welcome all for the day 3 session
All the user who are currently logged in will this message
Ulimit
Restricts the size
As super user we can also modify the same.Slide71
Continued
…Slide72
user management
Creating the user involves the following parameters
UID and user Name
GID and group name
The home directory
The login shell
Mailbox in
var
/mail
The password
------------------------------------------------------
Most of these are found in single line identifying the user in
/
etc
/
passwdSlide73
useradd and
usermod
,
userdel
Adds the new user to the system
All parameters related to the user should be provided in
command line
Example:
#
useradd
–u 210 –g dba –c “the
rdbms
” –d /home/oracle –s /bin/
ksh
–m oracle
Usermod and userdel
#usermod
#userdelSlide74
/etc
/
passwd
and
/
etc
/shadow
All user information except the password encryption is now stored in
/
etc
/
passwd
The encryption itself is stored in
/
etc
/shadow Slide75Slide76
DiscussionsSlide77
Thank you