Unix.latest

Embed Size (px)

Citation preview

  • 8/9/2019 Unix.latest

    1/34

    Embedded Systems Group IIT DelhiSlide

    1

    Orientation for fresh VDTT Students

    Introduction to UNIX

    July 28, 2001

    Anup Gangwar

  • 8/9/2019 Unix.latest

    2/34

    Embedded Systems Group IIT DelhiSlid

    e

    2

    Overview

    Prerequisites and goals of this course

    Differences between U!" and #indows

    $%er%iew of unices

    &asic U!" co''ands and utilities

    Lunch Break

    (ile editors in U!"

    Progra''ing and Shell Scri)ting

    Docu'ent for'atting using U!" *eferences and further study

    Thank You

  • 8/9/2019 Unix.latest

    3/34

    Embedded Systems Group IIT DelhiSlid

    e

    +

    Prerequisites and Goas

    What you should know

    &asic fa'iliarity with co')uters

    #or-ing .nowledge of atleast one o)erating syste'

    A will to learn What you will know

    /his is not a co')lete U!" tutorial

    Dont try to learn the whole U!" in one day

    ow to do the 'ost co''on set of tas-s with U!"

    Selfel) is the best hel)

    Pointers for further infor'ation

  • 8/9/2019 Unix.latest

    4/34

    Embedded Systems Group IIT DelhiSlid

    e

    3

    Differences! UNIX and "indows

    /he U!" and #indows )hiloso)hies

    4lientSer%er 'odel of 4o')utation

    5ultiUser and 5ulti/as-ing6 7ogin

    4once)t of the .ernel and User Shell 4once)t of file ownershi) and grou)s

    9U! on U!" and " windows

    /i)s:

    U!" is the 'ost used $S in scientific and industrial co''unity !nstead of a%oiding U!" ta-e it heads on

    7earning U!" now will hel) you sa%e )recious ti'e later on

  • 8/9/2019 Unix.latest

    5/34

    Embedded Systems Group IIT DelhiSlid

    e

    ;

    Overview of Unices#$

    /he original U!"

    /he * and &SD

    $thers: PU", Solaris, 7inu?,

  • 8/9/2019 Unix.latest

    6/34

    Embedded Systems Group IIT DelhiSlid

    e

    A

    Overview of Unices#%

    PU"

    Processors: P P

  • 8/9/2019 Unix.latest

    7/34

    Embedded Systems Group IIT Delhi Slid

    e

    D

    Overview of Unices#&

    7inu?C9U Syste's

    Processors: !ntel +8A and u), Sun Ultra S)arc, !&5

    PowerP4 etc6

    >endors: (reeC9U 9P7

    5ar-ets: 7ow Bnd Ser%ers and #or-stations

    Processors: !&5 Power P4

    >endors: !&5 5ar-ets:

  • 8/9/2019 Unix.latest

    8/34

    Embedded Systems Group IIT Delhi Slid

    e

    8

    Overview of Unices#'

    !*!"

    Processors: 5!PS

    >endors: S9! ESilicon 9ra)hics !nternationalF

    5ar-ets: igh Bnd 9ra)hics Ser%ers and #or-stations

    $thers

    &e$S, (ree&SD etc6

    */$Ss: PSoS, G", */B5S, */7inu? etc6

  • 8/9/2019 Unix.latest

    9/34

    Embedded Systems Group IIT Delhi Slid

    e

    H

    "hat we have

    Phili)s >7S! Design 7ab P Ser%er running PU"

    Sun #or-station

    7inu? #or-stations

    >D// 7ab 7inu? #or-stations

    #indows / #or-stations

    ew >7S! 7ab

    Sun #or-stations #indows / #or-stations

  • 8/9/2019 Unix.latest

    10/34

    Embedded Systems Group IIT DelhiSlide

    10

    (asic UNIX )o**ands and Utiities#$

    (iles and Directories

    (ile /y)es: #indows and U!"

    (ile and Directory creation EBditors, '-dir, ln etc6F

    7isting contents of a directory ElsF (ile and Directory deletion Er'dir, r' etc6F

    (ile and Directory )er'issions Ech'odF

    (ile and Directory ownershi) Echown, chgr)F

    $rganiIing your wor- in directories E'%F

    /i)s:

    U!" doesnt ha%e a recycle bin@

    /ry not to 'a-e the 'ista-e of r' rf co''and

  • 8/9/2019 Unix.latest

    11/34

    Embedded Systems Group IIT DelhiSlide

    11

    (asic UNIX )o**ands and Utiities#%

    5anaging your account

    #hat is 'eant by 'anaging your account

    4once)t of setu) files

    #hy are there so 'any different Shells

    Bn%iron'ent %ariables

    6bashrc and 6cshrc files

    4usto'iIing your en%iron'ent with 6bashrc and 6cshrc files

    B?a')le: /he /B*5 en%iron'ent %ariable and stty /i)s:

    /ry an en%iron'ent %ariable on co''andline first

  • 8/9/2019 Unix.latest

    12/34

    Embedded Systems Group IIT DelhiSlide

    12

    (asic UNIX )o**ands and Utiities#&

    *e'ote )rocess e?ecution #hy do we need re'ote )rocess e?ecution

    /elnet and rlogin

    *e'ote e?ecution of gra)hics )rogra's

    "Security, granting )er'issions and color'a) /he D!SP7

  • 8/9/2019 Unix.latest

    13/34

    Embedded Systems Group IIT DelhiSlide

    1+

    (asic UNIX )o**ands and Utiities#'

    /a-ing )rintouts

    4once)t of networ- and local )rinters

    Printer languages: Postscri)t and P47

    9host>iew and

  • 8/9/2019 Unix.latest

    14/34

    Embedded Systems Group IIT DelhiSlide

    13

    (asic UNIX )o**ands and Utiities#+ 5iscellaneous stuff

    (orcing a )rocess in bac-ground E=, fg, bgF

    Setting aliases

    $nline 'anual )ages, man

    4once)t of !S and (S

    4hanging )assword, passwd (?yppasswd?)

    Searching for )atterns, grep and regular expressions

    #or-ing with files with s)ecial characters in na'es /he fileutility

    finger who andrwho

    ps and kill

    5ailand 'ail clients, netscape pine emacsand mail

    startx !"clients and!xinitrc files

    /i)s: !nstead of as-ing so'eone try 'an -

    !t is a good )ractice to stic- to one shell Ecsh is a%ailable on allF

  • 8/9/2019 Unix.latest

    15/34

    Embedded Systems Group IIT DelhiSlide

    1;

    ,unch ( ea-

  • 8/9/2019 Unix.latest

    16/34

    Embedded Systems Group IIT DelhiSlide

    1A

    .ditors in UNIX#$

    #hat all is a%ailable, >i, B'acs, Pico, Joe, edit

    >i: /he -ing of all editors /utorial

    #hy learn %i

    9etting in and out

    &asic -eys for editing

    5o%ing around, deleting, Moining lines

    *e)eating co''ands

    Search and re)lace

    /i)s: >i' is not >i

    7earn the -ey)ad scroll -ey co'binations instead of arrow -eys

    >i is fast, try to 'a-e the best use of its ca)abilities

  • 8/9/2019 Unix.latest

    17/34

    Embedded Systems Group IIT DelhiSlide

    1D

    .ditors in UNIX#%

    B'acs: 5uch 'ore than an editor

    #hy learn B'acs istory, /utorial

    9etting in and out

    &asic -eys for editing

    5o%ing around, deleting a line Search and re)lace

    (or'atted te?t, )ostscri)t s)ooling

    'ail in e'acs

    Synta? highlighting and te')lates

    /i)s: B'acs recogniIes 20L languages out of the bo?

    B'acs is slow

    B'acs is not a%ailable by default on all unices

  • 8/9/2019 Unix.latest

    18/34

    Embedded Systems Group IIT DelhiSlide

    18

    .ditors in UNIX#&

    Pico: !s there really a need

    Pico and Pine

    Bditor .eys

    Joe, edit

    .eys si'ilar to orton Bditor

    edit has so'e features si'ilar to B'acs

    /i)s:

    Dont fall for Pico or edit

    7earn >i and B'acs if you really want to get into U!"

    !n the end it is a 'atter of choice

  • 8/9/2019 Unix.latest

    19/34

    Embedded Systems Group IIT DelhiSlide

    1H

    Progra**ing on UNIX#$

    !s )rogra''ing on U!" tough #hat all is a%ailable

    4once)t of !DB and differences with /urbo4LL

    4o')ilers, 7in-ers, Debuggers and frontends

    5anaging big )roMects: 'a-e and co')arison with /4)roMect file

    B?a')le of a si')le 'a-efile

    9U! de%elo)'ent on U!"

    Ja%a /i)s:

    U!" is a )rogra''ers )aradise

  • 8/9/2019 Unix.latest

    20/34

    Embedded Systems Group IIT DelhiSlide

    20

    Progra**ing on UNIX#%

    9cc, /he 9U 4C4LL co')iler

    Si')lest )ossible way to use: gcc Nfilena'eO

    4o''on o)tions

    out)ut filena'e: o

    co')ile only: c #arnings: #all

    o)ti'iIations: $1,2,+,3Q

    Debug: g

    7in-ing: lNlibraryna'eO

    /i)s: ot e%ery U!" syste's will ha%e gcc

    /urning on o)ti'iIation 'a-es the co')ilation slow

    Debugging and o)ti'iIing donot go together

  • 8/9/2019 Unix.latest

    21/34

    Embedded Systems Group IIT DelhiSlide

    21

    Progra**ing on UNIX#&

    7d, /he 7in-er

    #hat e?actly are libraries

    Shared and static libraries

    !s there a need to call 7d e?)licitly

    Passing o)tions to 7d fro' gcc

    /he l o)tion

    /he 7 o)tion

    /he 7DR7!&*

  • 8/9/2019 Unix.latest

    22/34

    Embedded Systems Group IIT DelhiSlide

    22

    Progra**ing on UNIX#'

    9db, /he 9U 4C4LL debugger

    #hy is a debugger needed

    gdb and core (ile

    4o''on co''ands

    list run, brea-, resu'e

    bac-trace and where

    /i)s:

    Using gdb directly 'ight be tedious

    /ry the %arious frontends to gdb: e'acs, ??gdb, '?gdb etc6

    ot e%ery syste' will ha%e gdb, you Must 'ight ha%e to use db?

  • 8/9/2019 Unix.latest

    23/34

    Embedded Systems Group IIT DelhiSlide

    2+

    Progra**ing on UNIX#+

    9'a-e or 9U 'a-e

    #hat is the need for a 5a-efile

    De)endencies

    /argets in a 'a-efile Patterns in 'a-efile

  • 8/9/2019 Unix.latest

    24/34

    Embedded Systems Group IIT DelhiSlide

    23

    Progra**ing on UNIX#/

    B?a')le of a 'a-efile

    CC=gcc

    COPTS= -g -Wall

    TARGET=run.xSRCS=hello.c junk.c

    OBJS=$(SRCS.c=.o!

    all$(OBJS!

    $(CC! $(COPTS! $(OBJS! -o $(TARGET!

    cleanr" -# $(OBJS! core

    .o.c

    $(CC! $(COPTS! -c $%

  • 8/9/2019 Unix.latest

    25/34

    Embedded Systems Group IIT DelhiSlide

    2;

    Progra**ing on UNIX#0

    9U! in U!"

    Differences with /urbo4LL

    >anilla " windows )rogra''ing, why not

    /47C/-

    #idget libraries

    5otif

    9/.

    G/, etc6 /i)s:

  • 8/9/2019 Unix.latest

    26/34

    Embedded Systems Group IIT DelhiSlide

    2A

    Progra**ing on UNIX#1

    Ja%a

    #hat is really different with the windows %ersion

    !s Jfc, Ja%a2D, Ja%a+D a%ailable

    !DBs for Ja%a o%er U!"

    /i)s:

    Dont try to use a 6class de)endency with 'a-e

    !f you run Ja%a fro' a ser%er, gra)hics would be slow

  • 8/9/2019 Unix.latest

    27/34

    Embedded Systems Group IIT DelhiSlide

    2D

    Introduction to She Progra**ing#$

    #hat is the need for shell )rogra''ing

    &ourne shell Esh, -sh, Ish and bashF

    c shell Ecsh, tcshF B?a')les of shell )rogra''ing

    5o%ing all a6iQ6t?t files to a6iL1Q6t?t

    4leaning u) your directory at the end of a day

    /i)s: Perl Must 'ight be a better o)tion

    Dont forget sed and aw-

  • 8/9/2019 Unix.latest

    28/34

    Embedded Systems Group IIT DelhiSlide

    28

    Introduction to She Progra**ing#%

    5o%ing files scri)t

    #$%&in%sh 'fL*+L,T-.ls / grep 01!23'451!0 .

    for 6788+L* in 9L*+L,T: do

    8,T+;.

    ;7

  • 8/9/2019 Unix.latest

    29/34

    Embedded Systems Group IIT DelhiSlide

    2H

    Introduction to She Progra**ing#&

    4leanu) directory scri)t#$%&in%csh 'f

    # Assume that ps pdf etc! directories are present

    set L*+L,T-.ls.

    foreach 6788+L* ( 9L*+L,T )

    set T,T-.echo 96788+L* / grep 1!pdf19 .

    if( 9T,T $- 00 ) then

    mE 96788+L* pdf

    endif

    set T,T-.echo 96788+L* / grep 1!ps19 .

    if( 9T,T $- 00 ) thenmE 96788+L* ps

    endif

    end

  • 8/9/2019 Unix.latest

    30/34

    Embedded Systems Group IIT DelhiSlide

    +0

    Te2t for*atting using UNIX#$

    #hat is the need for te?t for'atting

    #KS#K9 or $/

    7a/e" = B'acs PS renderer

    7a/e" #KS#K9 frontend 7y?

    $ther te?t for'atters: troff

    ow to 'a-e Presentations Slides

    /i)s: PowerPoint is still the best software for 'a-ing )resentations

    !t is easy to con%ert PowerPoint slides to ht'l

  • 8/9/2019 Unix.latest

    31/34

    Embedded Systems Group IIT DelhiSlide

    +1

    Te2t for*atting using UNIX#%

    7a/e"

    origin: 7a/e" and /e"

    usage

    7a/e" tutorials and 'anuals

    < not so short introduction to 7a/e"

    /he 7a/e" 'anual

    7a/e" by 7esslie 7a')ort

    7y? a #KS#!9 interface to 7a/e"

    B'acs )srenderer and troff /i)s:

    (or s'all for'atted te?t B'acs is still the best

  • 8/9/2019 Unix.latest

    32/34

    Embedded Systems Group IIT DelhiSlide

    +2

    (efore wrapping up

  • 8/9/2019 Unix.latest

    33/34

    Embedded Systems Group IIT DelhiSlide

    ++

    "rapping up

    Self hel) is the best hel)@

    /he U!" 'an )ages6 5anual sections

    Using 'an, whatis etc6

    B?)eri'ent6 Kou can ne%er -ill the syste'6

    7in-s

    htt):CCwww6gnu6org, for 9U tools and 'anuals

    htt):CCsunsite6unc6edu, worlds largest collection of free software

    htt):CCu)a%an6cse6iitd6ernet6in, Phili)s 7ab6 internal )age

    htt):CC)oor%i6cse6iitd6ernet6inClocal, !ntel cluster archi%es

    &oo-s

    /he U!" )rogra''ing en%iron'ent, .ernighan = Pi-e

  • 8/9/2019 Unix.latest

    34/34

    Embedded Systems Group IIT Delhi de

    +3

    Than- 3ou