Upload
loganathan-ht
View
215
Download
0
Embed Size (px)
Citation preview
7/29/2019 Unix Level -0 1
1/36
Unix
Unix is almost 40 year old Os
In 1964 OS called MULTICS (Multiplexed Information and
Computing System) was developed by Bell Labs, MIT &
General Electric.
Ken Thompson (System programmer of Bell Labs) wrote OS
on PDP - 7 Computer (Program Data Processor Model - 7),
assembler and few utilities, this is know as Unix (1969).
But this version of Unix was not portable. Then Unix was
rewrote in C. Because Unix written in 'C', it is portable. It
means Unix can run on verity of Hardware platform (1970-71).
7/29/2019 Unix Level -0 1
2/36
Unix
Unix is a layered operating system. The innermost layer isthe hardware that provides the services for the OS.
The operating system, referred to in Unix as the kernel,interacts directly with the hardware and provides the
services to the user programs.
These user programs dont need to know anything aboutthe hardware. They just need to know how to interact with
the kernel and its up to the kernel to provide the desiredservice.
7/29/2019 Unix Level -0 1
3/36
Most well written user programs are independent of theunderlying hardware, making them readily portable tonew systems.
User programs interact with the kernel through a set ofstandard system calls.
These system calls request services to be provided by thekernel.
Unix
7/29/2019 Unix Level -0 1
4/36
Such services would include
accessing a file: open close, read, write, link, or execute a file;
starting or updating accounting records;
changing ownership of a file or directory; changing to a newdirectory;
creating, suspending, or killing a process;
Enabling access to hardware devices;
And setting limits on system resources.
Unix
7/29/2019 Unix Level -0 1
5/36
Unix
Multi-user.
Multitasking .
Internet-aware Network OS.
Unix is . .
7/29/2019 Unix Level -0 1
6/36
Unix
Unix, Linux runs on different hardware platform :
Intel x86 processor (Celeron/PII/PIII/PIV/Old-
Pentiums/80386/80486)
Macintosh PC's
Cyrix processor
AMD processor
Sun Microsystems Sparc processor
Alpha Processor (Compaq)
7/29/2019 Unix Level -0 1
7/36
Unix
Minimum hardware required :
Intel x86 processor (Celeron/PII/PIII/PIV/Old-
Pentiums/80386/80486)
4 MB RAM
80 MB hard disk )
! Unix cannot run on 8086 Microprocessor . Because it can support
only 1 MB of Ram .
7/29/2019 Unix Level -0 1
8/36
Unix Architecture
7/29/2019 Unix Level -0 1
9/36
Shell
Computers dont have the inherent capability of
translating commands into action.
They require an interpreter that job is done by theouter part of the operating system the shell .
Its the interface between the User & the Kernel .
7/29/2019 Unix Level -0 1
10/36
Shell
When you enter a command through the keyboard , the
shell thoroughly examines the keyboard input forspecial characters.
It rebuilds a simplified command line and finally
communicates with the kernel to see that the commandis executed.
Ex.
$ echo Red Hat LinuxRed Hat Linux
While processing , the shell compress all multiplecontiguous spaces in the above command to the singleone.
7/29/2019 Unix Level -0 1
11/36
Locating Commands
All commands in Unix are essentially a files
( executable files )
These files are Stored in directories
ex ls is a command found in /bin directory
7/29/2019 Unix Level -0 1
12/36
Locating Commands
typecommand
Locating the executable program
$ type ls
ls is /bin/ls
7/29/2019 Unix Level -0 1
13/36
Locating Commands
PATH variable
Locating the executable program
$ echo $PATH
the sequence of directories the shell searches tolook for a command is specified in its own PATH
variable
/bin: /usr/bin :/usr/local/bin :/usr/java/bin:.
7/29/2019 Unix Level -0 1
14/36
Internal & External Commands
ls is a program having an independent existence (
/bin/ls ) hence it is branded as external commands
commands which are not found anywhere and
which are not executed even if they are in one of the
directories specified by PATH are called as internal
commands.
7/29/2019 Unix Level -0 1
15/36
Internal & External Commands
to execute echo shell wont look in its PATHvariable (even if it is there in /bin). Rather it will
execute it from its own set of commands
even though the echo is found in /bin/echo the shell
always executes the internal echo command
$ type echo
echo is a shell built in
7/29/2019 Unix Level -0 1
16/36
Internal & External Commands
List of Internal Commands
cd
pwd
umask
exit
7/29/2019 Unix Level -0 1
17/36
Internal & External Commands
List of External Commands
ftp
telnet
ls
cp
7/29/2019 Unix Level -0 1
18/36
Command Structure
$ command [options ] [arguments]
Examples
$ lsl -a
$ lsla
$ ls$ lsl
$ lsla tmp$ lsla tmp tmp1 tmp2
7/29/2019 Unix Level -0 1
19/36
Combining Commands
wc note ; lsl note
7/29/2019 Unix Level -0 1
20/36
Command on different lines
echo This is
> a three-line
> Text message
7/29/2019 Unix Level -0 1
21/36
Man : The online help
Unix offers the online help manual with the man
command
$ man cp
man page for cp is displayed on the screen. It presents
the first page and pauses . It does this by sending its
output to the pager program which displays thecontents one page at a time
Different pagers are more or less
7/29/2019 Unix Level -0 1
22/36
Man : The online help
To advance to the next screen press for spacebar
To move back press b
7/29/2019 Unix Level -0 1
23/36
Man & its options
man -k
man withk option searches the summary database
and prints the online description of the command
$ mank awk
Alternatively you can use$ apropos awk
7/29/2019 Unix Level -0 1
24/36
Man & its options
man -f
It emulates the whatiscommand behavior
$ manf ftp
$ whatis ftp
7/29/2019 Unix Level -0 1
25/36
When things go wrong
List of Some Trap Signals
Ctrl-h Erases TextCtrl-c Interrupts a command
Ctrl-d Terminates a login session or a
program that expects input from thekeyboard
Ctrl-s Stops Scrolling of screen and locks
KeyboardCtrl-q Resumes Scrolling of screen and
unlocks Keyboard
Ctrl-z Suspends process and returns a shell
prompt
7/29/2019 Unix Level -0 1
26/36
When things go wrong
When you misspells a password and if
backspace doesnt work simply press ctrl - h
7/29/2019 Unix Level -0 1
27/36
General Purpose Utilities
To view the calendar of any specific month or a
complete year use the cal commandSyntax :
cal [ [ month ] year ]
Example :
$ cal
$ cal 03 2003$ cal 2003 | less
( Single argument to the cal command is interpreted as a
year )
7/29/2019 Unix Level -0 1
28/36
General Purpose Utilities
datecommand is used to display current date
and time
You can also have the formatted output$ date +%m
$ date +%h
$ date +%h %m
7/29/2019 Unix Level -0 1
29/36
General Purpose Utilities
printf an alternative to echo
example
Displaying Message
printf message using printf\nprintf my current shell is %s\n $SHELL
%s String
%30s print string in a space 30 character wide
%d Decimal Integer
%o Octal Integer
%x hexadecimal integer
%f floating point number
Following are the valid options :
7/29/2019 Unix Level -0 1
30/36
bc: The Calculator
General Purpose Utilities
bc is one of the powerful system tools
$ bc12 +517Ctrl + d to quit
Ex
You can enter multiple commands in the same line
12 +5 ; 2 ^ 1017
1024( Output is shown in different lines) (next ..)
7/29/2019 Unix Level -0 1
31/36
bc: The Calculator
General Purpose Utilities
To enable floating point computation set scale to the
number of digits of precision
scale = 2Ex
17 / 2
(next ..)
2.42
7/29/2019 Unix Level -0 1
32/36
bc: The Calculator
General Purpose Utilities
For converting numbers from one base to another
ibase = 2Ex
11001010
(next ..)
202
obase = 2
141110
Ex
Ex obase = 16
( Output in decimal )
( Binary of 14 )
14E
( Hexadecimal value of 14 )
7/29/2019 Unix Level -0 1
33/36
script: Recording your session
General Purpose Utilities
This command lets you record your login session in a
file
$ script
To stop recording type exit
The prompt returns all the keystroke to henceforth to
the file typescript
$ script -a$ script logfile
( Appends activity to existing file )
( logs activity to file logfile )
7/29/2019 Unix Level -0 1
34/36
General Purpose Utilities
who
Unix maintains an account of all users who are logged
on to the system
$ who
root Console Aug 1 07:51 (:0)
parag Pts/9 Aug 1 07:55 (192.168.1.2)
pratham Pts/10 Aug 1 07:56 (192.168.1.3)
Name Device name Time Machine name
7/29/2019 Unix Level -0 1
35/36
General Purpose Utilities
uname: Machines Characteristics
uname command is used to display certain features of
Operating System
$ unameSunOS Linux showsLinux
Release Name of UNIX
$ uname -r5.8 This is SunOS 5.8
7/29/2019 Unix Level -0 1
36/36
General Purpose Utilities
uname: Machines Characteristics
Implementation Name of Unix
$ uname -sSunOS
Machine Name
$ uname -ncipher