chanakya_os-7_(autosaved)[1] (1) (1)

Upload: shiva-bandaru

Post on 02-Jun-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    1/16

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    2/16

    +) The ,inux environ"ent is a little different.-xecute ps to see that the default shell is bash #'ourne a!ain shell)

    ou can create new shells by typin! the shell identification on the co""andline#i.e.% sh) to create a new shell interfacetry a fewshcshbash

    then typepsto see that you have "ultiple shells available. lthou!h "ost shells reco!ni ethe sa"e basic co""ands% there are considerable differences as we will see.

    To chan!e to the 0 #or enhanced 0) shell use the co""andchsh

    or

    chsh $s /bin/csh

    -ither will re uire elevatin! your privile!es by enterin! your password andlo!!in! out and in a!ain $ if they wor2.#execute the co""and echo 345-,,to see if the shell was chan!ed).

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    3/16

    6. Try !rep co""ands in UNIX and ,inux to !et used to usin! fla!s such as

    #i& #n' and other constructs. (ou can use multiple flags for the same command

    Grep command selects and prints the lines from a file which matches the given string.

    !rep 7pattern8 9 : list all occurrences of 7pattern8 in

    current directory

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    4/16

    !rep pattern 9 : use uotes if a blan2 occurs within the pattern

    !rep $i 7pattern8 7file8 : the $i fla! provides case insensitivity.test an upper case pattern a!ainst a docu"ent that

    contains that pattern in lower case.

    !rep $n 7pattern8 7file8: the $n fla! will output the line nu"ber as well as the pattern in the file

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    5/16

    LINUX:

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    6/16

    ;) Use a pipe and the tee co""and #these are valid in all threeenviron"ents)tee saves inter"ediate results in a file% for exa"ple: !rep cd 9 < tee te"p < wcwill place the occurrences of cd inside te"p and print the word countof te"p on the ter"inal.

    =utput the te"p file.

    pipe # < ) allows partial output to be!in to be processed by anotherprocess.

    Try: "an !rep < "ore

    The above will pipe the output of the help #"an) file one pa!e at a ti"e totheter"inal. (= N=T >?INT T5I4 @I,- =UT.

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    7/16

    A) >ipes wor2 in the indows co""and pro"pt.In co""and pro"pt try ipconfi! < "ore < find I>v;or Bust plain ipconfi! < find v;

    In indows >owershell executeipconfi! < "ore < findstr I>v;

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    8/16

    C) create a s"all file in UNIX or ,inux called firstscriptithin the file place the co""and

    echo hello

    0lose the file and "a2e it executable #ch"od DEE firstscript)

    execute the file:firstscript

    Now para"eteri e the file by chan!in! the file data to

    echo 31

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    9/16

    -xecute the file with a strin! followin! the file na"e such as ./firstscript hello$(r.,evine

    Now try it with spaces in the para"eters% i.e.% hello (r. ,evine ouFll see that UNIX ter"inates input upon findin! a blan2% such as when you execute .,evine

    three lines of data with para"eters in the file. echo 31 echo 3+ echo 36

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    10/16

    Now execute the file with 6 para"eters ./firstfile hello (r. ,evine

    one line of data with para"eters in the file and execute the file with6 para"eters:echo 31 3+ 36

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    11/16

    The difference is in the first data is executed in three lines.hereas in the later it is executed in sin!le line.

    The difference is in the first data is executed in three lines.hereas in the later it is executed in sin!le line.

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    12/16

    D) ou are !oin! to create another s"all shell script called secondscript.

    0hoose one of your existin! files in the current directory #say child.c)and write that na"e into secondscript for co"pilation and execution:

    r" ./a.outcc ./child.c

    ./a.out G >s

    ssi!n execution ri!hts to secondscript and execute it.

    >ara"eteri e this script by replacin! the co""and

    cc ./child.c

    with the line

    cc 31

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    13/16

    -xecute secondscript with the filena"e as a para"eter% such as ./secondscript ./child.c

    H)In UNIX or ,inux write a shell script for creatin! a copy of a !iven#none"pty)file% where the copy has each line nu"bered. (o this byprintin! out the file with a line nu"ber #cat $n) and redirectin! itto another filena"e.

    cat $n filena"e 8 newfile Then print out the new file on the ter"inal.(onFt for!et that you "ust specify the path in our ,inux syste"% but notin our UNIX environ"ent. #the path includes your current directory)

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    14/16

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    15/16

    )In indows D co""and pro"pt%create a file with a .bat extension #say batchfile.bat). This "a2es the fileauto"atically executable. 4ee if there is an editor #-(IT) in co""and pro"pt.

    )

  • 8/10/2019 chanakya_os-7_(Autosaved)[1] (1) (1)

    16/16

    1E) ?esearch ,inux fra"ewor2s.-xplain what a ,inux fra"ewor2 is. 5ow does it help developers custo"i e

    their operatin! syste"s*

    ) "inux#based system is a modular nix#li e operating system. It derives much of its basic design from principles established in nix. *uch a system uses a monolithic ernel& the "inux ernel& which handles process control& networ ing& and peripheral and file system access. +evice drivers are either integrateddirectly with the ernel or added as modules loaded while the system is running.

    *eparate pro,ects that interface with the ernel provide much of the system-s higher#level functionality.he GN user land is an important part of most "inux#based systems& providing the most common

    implementation of the / library& a popular /"I shell& and many of the common nix tools which carry outmany basic operating system tas s.

    he best feature of "inux 0ramewor is its low susceptibility to virus and malware infestation. "inux isalmost always a free operating system with multiple sources distribution. In contrast& 1indows and 2ac3* 4 are some of the most expensive operating systems available. "inux is an open source platformswith plenty of developers wor ing on applications& functions& features and add#ons that are guaranteed toimprove your user experience.

    .