ULP Lab.doc

download ULP Lab.doc

of 38

Transcript of ULP Lab.doc

  • 7/25/2019 ULP Lab.doc

    1/38

    PRACTICAL NO.1

    AIM -Install Linux on a PC having some other previously installe operating system.All Operating !ystems shoul "e usa"le.

    To install Red Hat Enterprise Linux 5 on your computer, take the following steps:

    !tep 1#-Right Click on My Computerand go to manageoption

    !tep $#-Click on %is& Managementoption and delete a partition to make it free for RHEL installation

    !tep '#-!nsert the media that you"ll use to #oot the Red Hat Enterprise Linux 5 installation program !t can#e the first Red Hat Enterprise Linux 5 C$ or $%$

    !tep (#-Restart the system

    !tep )#-&hen you see the #oot prompt press *NT*R key to install in graphical mode

  • 7/25/2019 ULP Lab.doc

    2/38

    !tep +#- Installation Metho# -Choose your installation method 'like Local C$R()* and press O,

    !tep #- +ress kip to skip the )edia test and start the installation

  • 7/25/2019 ULP Lab.doc

    3/38

    !tep #-&elcome creen:- The &elcome screen does not prompt you for any input .rom this screen youcan access the Release /otes for Red Hat Enterprise Linux 500 #y clicking on the Release /otes #uttonClick on the /ext #utton to continue

    !tep /#- Language !ele0tion# -1sing your mouse, select a language to use for the installation(nce you select the appropriate language, click /ext to continue

    !tep 1#- ,ey"oar Con2iguration#-1sing your mouse, select the correct layout type 'for example, 1English* for the key#oard you would prefer to use for the installation and as the system default 'refer to thefigure #elow*(nce you ha2e made your selection, click /ext to continue

  • 7/25/2019 ULP Lab.doc

    4/38

    !tep 11#- *nter the Installation Num"er# -Enter your !nstallation /um#er This num#er will determinethe package selection set that is a2aila#le to the installer !f you choose to skip entering the installationnum#er you will #e presented with a #asic selection of packages to install later on

    !tep 1$#-Create Custom Layout:-

    Click next once you ha2e made your selections to proceed

    !tep 1'#- Partitioning 3our !ystem# -!f you chose to create a custom layout, you must tell the installationprogram where to install Red Hat Enterprise Linux This is done #y defining mount points for one or more

  • 7/25/2019 ULP Lab.doc

    5/38

    disk partitions in which Red Hat Enterprise Linux is installed 3ou may also need to create and4or deletepartitions at this time

    !tep 1(#- Aing Partitions# -To add a new partition, select the ne4#utton dd the desired partitions

    !tep 1)#- 5oot Loaer Con2iguration# - To #oot the system without #oot media, you usually need to installa #oot loader #oot loader is the first software program that runs when a computer starts !t is responsi#lefor loading and transferring control to the operating system kernel software The kernel, in turn, initiali6esthe rest of the operating system (nce you"2e configured your partitions, set up a #oot loader !f you select

    /o 7oot Loader &ill 7e !nstalled, you"ll need to use a third-party #oot loader such as +artition )agic or)icrosoft"s /TL$R 1nless you want to set up a 7oot Loader +assword or Configure d2anced 7ootLoader (ptions, click Next

  • 7/25/2019 ULP Lab.doc

    6/38

    !tep 1+#- Net4or& Con2iguration# -Configure your connection to the network !f you don"t want the$HC+ ser2er to assign a hostname 'or you don"t ha2e a $HC+ ser2er*, you can assign it manually, as shownhere Click Nextto mo2e on

    !tep 1#- Time 6one Con2iguration# -et your time 6one #y selecting the city closest to your computer8sphysical location Click on the map to 6oom in to a particular geographical region of the world.rom here there are two ways for you to select your time 6one:

    9 1sing your mouse, click on the interacti2e map to select a specific city 'represented #y ayellow dot* red appears indicating your selection9 3ou can also scroll through the list at the #ottom of the screen to select your time 6one 1singyour mouse, click on a location to highlight your selection

  • 7/25/2019 ULP Lab.doc

    7/38

    !tep 1#- !et Root Pass4or# - etting up a root account and password is one of the most important steps

    during your installation The root account is used to install packages, upgrade R+)s, and perform mostsystem maintenance Logging in as root gi2es you complete control o2er your system

    !tep 1/#- Pa0&age 7roup !ele0tion# -There are two package customi6ation screens a2aila#le E2eryonesees the screen shown next 'The choices are slightly different for Red Hat Enterprise Linux 5 Client* 3ou

    can accept the defaults, select a2aila#le options, and4or select Customi6e /ow !t"s usually #est to customi6emodestly '!"2e selected the Customi6e /ow option*, #ased on the re;uirements on your particular!nstallation and Configuration exam Click /ext '!f you don"t select Customi6e /ow, skip the next step*

  • 7/25/2019 ULP Lab.doc

    8/38

    !tep $#-+ackage

  • 7/25/2019 ULP Lab.doc

    9/38

    The next screen congratulates you for completing the installation The next step is to re#oot your computerinto RHEL Click Re"oot

    PRACTICAL NO. $

    Aim# - 8amiliari9e 4ith :nix;Linux logging;logout an simple 0ommans.

    Login;Logout# -

    !t identifies you as a particular user!t starts up your own shell and desktop!t gi2es you appropriate permissions

    !yntax# -Login:+assword:= - :ser,

  • 7/25/2019 ULP Lab.doc

    10/38

    or not there is a hyphen !n options, list arguments should either #e comma-separated or space-separated andplaced inside dou#le ;uotes !n comparing the amount of output produced, note that e prints more than a andl prints more than f for each entry

    !yntax# -ps >options?Option# - - a# - s a, list all processes on a terminal- #- elect all processes except session leaders-e= -A #- elect all processes

    0at# - Read 'concatenate* one or more files and print them on standard output Read standard input if nofiles are specified or if - is specified as one of the filesB input ends with E(. 3ou can use the operator tocom#ine se2eral files into a new file, or to append files to an existing file &hen appending to an existingfile, use Ctrl-$, the end-of-file sym#ol, to end the session

    !yntax# - cat >options? >files?Options: - -"= --num"er-non"lan -/um#er all non#lank output lines, starting with D-*= --sho4-ens# - +rint dollarB at the end of each line-n= --num"er #-/um#er all output lines, starting with D-s= --s>uee9e-"lan& #- ;uee6e down multiple #lank lines to one #lank line

    40# -To count the num#er of characters , words lines in particular file!yntax# - wc>options?>file?

    Options# - -0# -To count characters only-4:- To count only words-l:- To count only lines

    0al# -+rint a DF-month calendar '#eginning with Ganuary* for the gi2en year, or a one-month calendar of thegi2en month and year month ranges from D to DF year ranges from D to @@@@ &ith no arguments, print acalendar for the current month

    !yntax# - cal >options? >>month? year?Options #- -? #- $isplay Gulian dates 'days num#ered D to I5*-m #- $isplay )onday as the first day of the week-y #- $isplay entire year

    ate# - +rint the current date and time 3ou may specify a display format format can consist of literal textstrings '#lanks must #e ;uoted* as well as field descriptors, whose 2alues will appear as descri#ed in thefollowing entries 'the listing shows some logical groupings* pri2ileged user can change the system8s dateand time

    !yntax# -date >options? >Jformat? >date?Option# --s ate= --set ate# - et the date@# -$ay of month '0D-D*@h# - ame as K#@ -Hour in F-hour format, without leading 6eros '0-F*@l# -Hour in DF-hour format, without leading 6eros 'D-DF*@m# - )onth of year '0D-DF*@p# - tring to indicate am or pm@4# -$ay of week 'unday M 0*@y# - Last two digits of year '00-@@*@# - Hour in F-hour format '00-F*@I# -Hour in DF-hour format '0D-DF*

    e0ho# - end 'echo* the input string to standard output This is the 4#in4echo commandecho also exists as acommand #uilt into #ash The following character se;uences ha2e special meanings: 'Na*lert ,'N#*7ackspace,'Nc* uppress trailing newline,'Nf *.orm feed,'Nn */ewline,'Nr *Carriage return,'Nt *Hori6ontal ta#,'N2 *%ertical ta#,'NN *Literal #ackslash,'Nnnn *The octal character whose C!! code is nnn

    !yntax # - echo >options? >string?Option #- -e :- Ena#le character se;uences with special meaning-* #- $isa#le character se;uences with special meaning

  • 7/25/2019 ULP Lab.doc

    11/38

    rm# - $elete one or more files To remo2e a file, you must ha2e write permission in the directory thatcontains the file, #ut you need not ha2e permission on the file itself !f you do not ha2e write permission onthe file, you will #e prompted 'y or n* to o2erride rm is often aliased to rm -i, especially for the root user, to

    protect against inad2ertently deleting files

    !yntax# - rm >options? filesOptions# --= --ire0tory:- Remo2e directories, e2en if they are not empty

    -2= --2or0e #- Remo2e write-protected files without prompting-i= --intera0tive #- +rompt for y 'remo2e the file* or n 'do not remo2e the file*

    uname# - +rint information a#out the machine and operating system &ithout options, print the name of the kernel'Linux*

    !yntax# -uname >options?Options# - -a=--all:-Com#ine all system information from the other options-i= --har4are-plat2orm #- +rint the system8s hardware platform-m= --ma0hine #- +rint name of the hardware that the system is running on-n= --noename #- +rint the machine8s hostname-o= --operating-system #- +rint the operating system name-p= --pro0essor #- +rint the type of processor

    -r= --&ernel-release #- +rint the release num#er of the kernel

    ls# - List contents of directories !f no names are gi2en, list the files in the current directory &ith one ormore names, list files contained in a directory name or that match a file name names can include filenamemetacharacters The options let you display a 2ariety of in formation in different formats The most usefuloptions include -., -R, -l, and -s ome options don8t make sense together 'eg, -u and -c*

    !yntax # -ls >options? >names?Options #--1= --2ormatBsingle-0olumn #- +rint one entry per line of output-a= --all #- List all files, including the normally hidden files whose names #egin with a period-= --ire0tory #- Report only on the directory, not its contents

  • 7/25/2019 ULP Lab.doc

    12/38

    -2 #- +rint directory contents in exactly the order in which they are stored, without attempting to sort them-h #- +rint si6es in kilo#ytes and mega#ytes-i= --inoe #- List the inode for each file-l= --2ormatBlong= --2ormatBver"ose #- Long format listing 'includes permissions, owner, si6e, modificationtime, etc*-r= --reverse #- List files in re2erse order '#y name or #y time*-s= --si9e #- +rint file si6e in #locks-x= --2ormatBa0ross= --2ormatBhori9ontal #- List files in rows going across the screen-R= --re0ursive #- List directories and their contents recursi2ely

    0hmo# - Change the access mode 'permissions* of one or more files (nly the owner of a file or apri2ileged user may change the mode mode can #e numeric or an expression in the form of who opcodepermission who is optional 'if omitted, default is a*B choose only one opcode )ultiple modes are separated#y commas

    !yntax# -chmod >options? mode files chmod >options? --referenceMfilename filesOptions# - -2= --silent= -->uiet #- $o not notify user of files that chmod cannot change-R= --re0ursive #- Tra2erse su#directories recursi2ely, applying changes-v= --ver"ose #- +rint information a#out each file, whether changed or not

    hou :- 1serg :-

  • 7/25/2019 ULP Lab.doc

    13/38

    w :- &ritex :- Executes :- et user 'or group* !$t :- ticky #itB used on directories to pre2ent remo2al of files #y non-ownersu :- 1ser8s present permissiong :- options?newowner files chown >options? --referenceMfilename filesOptions# --2= --silent= -->uiet #- $o not print error messages a#out files that cannot #e changed

    -v= --ver"ose #- +rint information a#out all files that chown attempts to change, whether or not they areactually changed-R= --re0ursive #- Tra2erse su#directories recursi2ely, applying changes

    0hgrp# - Change the group of one or more files to newgroup newgroup is either a group !$ num#er or agroup name located in 4etc4group (nly the owner of a file or a pri2ileged user may change the group

    !yntax# - chgrp >options? newgroup fileschgrp >options?Options# - -2= --silent= -->uiet #- $o not print error messages a#outfiles that cannot #e changed-R= --re0ursive #- Tra2erse su#directories recursi2ely, applying changes

    0p# -Copy fileD to fileF, or copy one or more files to the same names under directory !f the destination is

    an existing file, the file is o2erwrittenB if the destination is an existing directory, the file is copied into thedirectory 'the directory is not o2erwritten*

    !yntax# - cp >options? fileD fileF cp >options? files directoryOptions# - -a= --ar0hive:- +reser2e attri#utes of original files where possi#le-2= --2or0e #- Remo2e existing files in the destination-i= --intera0tive #- +rompt #efore o2erwriting destination files-r= -R= --re0ursive #- Copy directories recursi2ely

    OM*# - how the home directory, where user"s personal files are stored

    !yntax# -=H()Ep4 #-+rint the full pathname of the current working directory

    !yntax# -pwd0lear# - Clear the terminal display E;ui2alent to pressing Ctrl-L

    !yntax #-clear

  • 7/25/2019 ULP Lab.doc

    14/38

    mv# -The m2 command is often aliased as m2 -i in the #ashrc file, especially for the root account, topre2ent inad2ertently o2erwriting files

    !yntax# - m2>file?>fileF?Options# - -":- 7ack up files #efore remo2ing-2= --2or0e #- .orce the mo2e, e2en if target file existsB suppress messages a#out restricted access modes-i= --intera0tive #- Ouery user #efore remo2ing files-u= --upate #- $o not remo2e a file or link if its modification date is the same as or newer than that of its

    replacementm&ir# - Create one or moredirectories.3ou must ha2e write permission in the parent directory in orderto create a directory ee also rmir The default mode of the new directory is 0PPP, modified #y the systemor user8s umas&

    !yntax# -mkdir >options? directoriesOptions# --m = --moe mode#- et the access modefor new directories-p, --parents:- Create inter2ening parent directories if they don8t exist-v= --ver"ose #-+rint a message for each directory created

    rmir# - $elete the named directories 'not the contents* directories are deleted from the parent directoryand must #e empty 'if not, rm -r can #e used instead*

    !yntax# -rmdir >options? directoriesOptions# - --ignore-2ail-on-non-empty #- !gnore failure to remo2e non-empty directories-p= --parents #- Remo2e directories and any inter2ening parent directories that #ecome empty as a result 1seful forremo2ing su#directory trees

    "0 # - #c is a language 'and compiler* whose syntax resem#les that of C, #ut with unlimited-precisionarithmetic #c consists of identifiers, keywords, and sym#ols, which are #riefly descri#ed in the followingentries Examples are gi2en at the end !nteracti2ely perform ar#itrary-precision arithmetic or con2ertnum#ers from one #ase to another !nput can #e taken from files or read from the standard input

    !yntax # - "0 DoptionsE DfilesE

  • 7/25/2019 ULP Lab.doc

    15/38

    PRACTICAL NO. '

    Aim# -:sing5ash shell evelops simple programs.1. - rite a program to per2orm the "asi0 arithmeti0 operation.

    echo QEnter the two nosQread aread #echo Qddition is:Qexpr =a J =#

    echo Qu#traction is:Qexpr =a - =#

    echo Q)ultiplication is:Qexpr =a N =#

    echo Q$i2ision is:Qexpr =a 4 =#

    $. - rite a program to 0al0ulate the 2a0torial o2 a num"er.

    echo QEnter a num#erQread numiMFfactMDif > =num -ge F ?then

    while > =i -le =num ?dofactMSexpr =fact N =iSiMSexpr =i J DS

    donefiecho Q.actoral of a num#er is =factQ

    '. - rite a program to 2in greatest o2 three num"ers.

  • 7/25/2019 ULP Lab.doc

    16/38

    echo QEnter the three num#ersQread aread #read cif test =a -gt =# -a =a -gt =cBthenecho Q.irst no is greaterQelif test =a -lt =# -a =# -gt =cBthenecho Qecond num#er is largestQelseecho QThird num#er is largestQfi

    (. - rite a program to per2orm the "asi0 0al0ulator operations.

    echo QEnter two nosQ

    read aread #echo QD for additionQecho QF for su#tractionQecho Q for multiplicationQecho Q for di2isionQecho QEnter your choiceQread chcase Q=chQ inD* cM=''aJ#**echo Qum of two nos is =cQ

    BB

    F* cM=''a-#**echo Qu#traction of two nos is =cQBB

    * cM=''a#**echo Q)ult of two nos is =cQBB

    * cM=''a4#**

    echo Q$i2 of two nos is =cQBB* echo Q&rong choiceQesac

    ). - rite a program to 2in a num"er 4hether even or o.

    echo QEnter a num#erQread numif > Sexpr =num K FS -e; 0 ?then

    echo Q=num is e2enQelseecho Q=num is oddQfi

  • 7/25/2019 ULP Lab.doc

    17/38

  • 7/25/2019 ULP Lab.doc

    18/38

  • 7/25/2019 ULP Lab.doc

    19/38

    PRACTICAL NO. (

    AIM# -.amiliari6e with 2i" editor and Linux

  • 7/25/2019 ULP Lab.doc

    20/38

    Insertion moe# -!n this mode all key passed #y user are interpreted to the editor commands that is

    for mo2ing cursor for left-right top-#ottom etc !n this the key pressed are not displayed on screen7y default 2i editor in command mode

    *xe0ute moe# -This mode is used to handle the files and perform su#stitutions !t always starts

    with columns :"

    Input moe# -

    Insert an appen#-

    i- To insert the text in a file to anywhere!- To insert the text in a file only at the #eginning of a linea- To append the text in file any where- To append the text at end of line

    Repla0e #-

    r- Replace single terminal character in a files- (ne character replaced #y multiple charactersR- Replace all text on the right of cursor position- Replace entire line

    Open line# -

    o- Line editing at #elow of current line(- Line editing at upper of current line

    *xe0ution moe# -These are following command:w- sa2es file and remains in editing mode:w 2ikitxt - a2es to file 2ikitxt:wW 2ikitxt - s a#o2e, #ut o2erwrites exiting file

    :w 2ikitxt - ppends current file contents to file 2ikitxt: nD,nw 2ikitxt - &rites lines nD to n to file 2ikitxt:w 2ikitxt - &rites current line to file 2ikitxt#Fw 2ikitxt - writes last line to file 2ikitxt

    #.=Fw 2ikitxt - writes current to last line to 2ikitxt:x- sa2es file and ;uits editing mode:w;- same as :x":;- ;uit from editor without sa2ing the #uffer:;W- forcefully ;uit from the editor without sa2ing the #uffer:sh- escapes to 1/! shell:reco2er- reco2ers file from a crash

    Navigation# -There are se2eral na2igation keys for controlling the cursor mo2ement These are as:k- )o2es cursor up

    V- )o2es cursor downh- )o2es cursor leftl- )o2es cursor right

    #- )o2es #ack to #eginning of worde- )o2es forward to end of wordw- )o2es forward to #eginning of word0'6ero* - mo2ing to the #eginning of a line

    X- to position the cursor to certain column=- mo2es to end of line>Ctrl-f? - crolls forward>Ctrl-#? - scrolls #ackward>Ctrl-d? Y scrolls half page forward

  • 7/25/2019 ULP Lab.doc

    21/38

    >Ctrl-u? - scrolls half page #ackward< Ygoes to end of file

    *iting text# -The editing facilities in 2i are 2ery ela#orate and in2ol2e the use of operators There aretwo operators:

    d- $eletey- 3ank 'copy*

    d and y are not commands, #ut they can #e used for deleting and copying entire lines These are following

    commands for editing operations:x- $eletes a single character under the cursorx-deletes the current character as well as three characters from the rightdd- $elete the entire linedd -deletes the current line and the lines #elowyy- 3ank the entire lineD0yy- yanks current line and @ lines #elow

    p- +uts the data #elow the current line+- +uts the data a#o2e the current lineG- 1sed to Voin the linesG-Voins following lines with current line

    u- To undo the last change made1- Re2erse all change made to the current line

    Repeating the last 0omman#-the 2i editor has the facility to repeat the last command, #ut mosteditor do not ha2e The dot '* Command is used for repeating #oth !nput and Command mode that performediting tasks

    !ear0hing 2or a pattern# -2i is strong in search and replacement acti2ities earching can #e made in#oth forward and re2erse directions, and can #e repeated !t is initiated from the Command mode #y pressinga 4, which shows up in last line as :

    4 - .or forward searchZ - .or #ackward search

    Command for repeating the last pattern searches are:n- Repeats search in the same direction along which pre2ious search was made

    /- Repeats search in direction opposite to that along which pre2ious search was made

    !u"stitution# -2i offers yet another powerful feature, that of su#station, which is achie2ed with the exmodes" command The syntax is as:

    :address4source[pattern4target[pattern4flags

    The source[pattern is replaced with target[pattern in all lines specified #y address The address can #e one

    or a pair of num#ers, separated #y a comma The most commonly used flag is g, which su#stitute alloccurrences of the pattern in a line .or example::D,=s4director4mem#er4g

    The target pattern is optional !f you lea2e it out, then you"ll delete all occurrences of the source pattern inall lines matched #y address .or example:

    :D,Fs4mem#er44g

    !nteracti2e su#stitution:- something like to selecti2ely replace a string !n this case, add the c"'confirmatory* parameter as the flag at the end:

    :D,=s4director4mem#er4gc

    %isavantages# - There are no of self explanatory error message in 2i if anything goes wrong then there is an error

    message appear (nly speaker keeps to inform that something wrong

  • 7/25/2019 ULP Lab.doc

    22/38

    /o help a2aila#le in 2i editor

    There are three mode in which 2i editor work #ut in each mode same key create different effects

    2i is key sensiti2e %i can handle that maintain plain text that no fstyle in fault /o graphic Vust

    simple text file we can create, edit and print

  • 7/25/2019 ULP Lab.doc

    23/38

  • 7/25/2019 ULP Lab.doc

    24/38

    PRACTICAL NO. )

    AIM# -$e2elop some programs using grep and sed $isplay the lines containing director $elete those lines whose employ id is two thousand

    Count the lines containing manager as designation

  • 7/25/2019 ULP Lab.doc

    25/38

    $isplay the line num#er record ha2ing sales as $epartment

    $isplay the lines where salary lies #etween A0000-A@@@@

    Replace the manager with executi2e

    Replace pipe sym#ol with colon sym#ol in the emplst

    dd prefix \e] to all employ id"s

  • 7/25/2019 ULP Lab.doc

    26/38

  • 7/25/2019 ULP Lab.doc

    27/38

    PRACTICAL N. +

    AIM# -$e2elop ad2anced shell programs using awk

    .irst, we create a ta#le including empid, name, designation, department and #asic pay

    A4& #- !t is similar to find and sedThe awk command com#ines the functions of grep and sed, making itone of the most powerful 1nix commands 1sing awk, you can su#stitute words from an input file8s lines for

  • 7/25/2019 ULP Lab.doc

    28/38

    words in a template or perform calculations on num#ers within a file The command uses the followingsyntax:awk options selection_criteraia (action) filename(s)The selection[criteria filters input and selects lines` print M whitespace permitted` print =0 M =0 is the complete lines

    Programs #-

    * $isplay name, designation of all employees #elonging to marketing department7* &rite a program to count manager drawing salary exceeding P000C* &rite a program to calculate a2erage #asic pay of the employees ha2ing salary greater than A000$* &rite program to calculate a2erage #asic pay , a2erage hra, a2erage da and total salary of the employees

    #elonging to sales or marketing department

    emp.a4& #-

    7E

    printf QKd K-F0s K-DFs KdNnQ, kount,=F,=,=5E/$ `

    printf QNnNtThe a2erage #asic pay is KIdNnQ, tot4kount

    *mp$.a4& #-7E

    printf QKFsNnQ, Q7asic $a Hra D? JM =5 B tot>F? JM da B tot>? JM hra B tot>? JM gpkountJJE/$ `

    printf QNt 2erage K5d K5d K5d K5dNnQ, Ntot>D?4kount, tot>F?4kount, tot>?4kount, tot>?4kount

  • 7/25/2019 ULP Lab.doc

    29/38

    PRACTICAL NO.

    AIM-Compile and de#ug 2arious C programs using different options

    7CCThe

  • 7/25/2019 ULP Lab.doc

    30/38

    = 4aout= gcc Yo ulpP ulpPc= 4ulpP

    arnings# -

    = gcc Y&all Yo ulpP ulpPc= gcc Y&all -&error Yo ulpP ulpPc

    Optimi9ation 4ith g00# -

    = time 4ulpP= gcc Y&all Y(D Yo ulpP ulpPc= time 4ulpP

    %e"ugging 4ith g00# -

    = gcc Yg Y&all Yo ulpP ulpc=gcc Yggd# Y&all Yo ulpP ulpPc= gd# ulpP'gd#*#reak main'gd#*run'gd#*step'gd#*;uit

  • 7/25/2019 ULP Lab.doc

    31/38

  • 7/25/2019 ULP Lab.doc

    32/38

    PRACTICAL NO.

    Aim# - Create a simple make file and smarter make file

    7N: Ma&e# -s your programs get larger, the process necessary to #uild them #ecomes more complex and time-consuming The Linux en2ironment pro2ides a tool to help you with this process:

  • 7/25/2019 ULP Lab.doc

    33/38

    )akefile is nothing more than a collection of rules rule consists of following things: -

    Target # -The \thing] make ultimately tries to create

    %epenen0ies# - list of one or more dependencies 'usually files* re;uired to #uild the target

    Commans# - list of commands to execute to create the target from the specified dependencies

    $ependencies aren"t necessarily the files that are #uilt They can #e other ar#itrary files .or instance, a Cprogram might list an include file as a dependency This means that if the include file is updated, the C filewill #e recompiled to take into account the changes

    !marter ma&e2ile# -3ou can use 2aria#les in your marter )akefile This not only reduces the typing 'andpossi#le errors* necessary to create your rules, #ut also ena#les you to change the rules throughout the entirefile #y modifying one or two lines This can #e a #ig win for large filesetting 2aria#les in a )akefile is similar to doing the same in 7ashB you use the e;uals sign 'M* to separatethe 2aria#le name, on the left, from the new 2alue on the right To access the contents of the 2aria#le later,the syntax is slightly different &ith make, you use ='%R!7LE* to access the contents of the 2aria#lenamed %R!7LE

    Intelligent Ma&e2ilesthat can automatically detect many things a#out their en2ironment so that you oftendon"t need to tell them e2en the names of the files that comprise your programW

    8or 0ompute.0= the sour0e is# -

    extern int someglo#alBint computer'2oid*`

    return 5 someglo#alB

    8or init.0= the sour0e is# -

    include stdiohinclude \myprogramh]

    int someglo#al M DDBint main'2oid*`

    foo'*Breturn 0B

    8or io.0= the sour0e is# -

    include stdiohinclude \myprogramh]int foo'2oid*`

    printf'\The 2alue is: KdNn], computer'**Breturn DB

    8or the heaer 2ile= myprogram.h= the sour0e is# -

    int computer'2oid*Bint foo'2oid*B

    Coe 2or ma&e2ile# -

    all: myprogrammyprogram: ioo inito computeogcc -o myprogram ioo inito computeo

    computeo: computecgcc -&all -c -o computeo computec

  • 7/25/2019 ULP Lab.doc

    34/38

    inito: initc myprogramhgcc -&all -c -o inito initc

    ioo: ioc myprogramhgcc -&all -c -o ioo ioc

    Coe 2or smarter ma&e2ile# -

    CCMgccC.L

  • 7/25/2019 ULP Lab.doc

    35/38

    Experiment /o: - @

    Aim# - To create a smarter makefile

    !marter ma&e2ile# -3ou can use 2aria#les in your marter )akefile This not only reduces the typing 'andpossi#le errors* necessary to create your rules, #ut also ena#les you to change the rules throughout the entirefile #y modifying one or two lines This can #e a #ig win for large filesetting 2aria#les in a )akefile is similar to doing the same in 7ashB you use the e;uals sign 'M* to separatethe 2aria#le name, on the left, from the new 2alue on the right To access the contents of the 2aria#le later,the syntax is slightly different &ith make, you use ='%R!7LE* to access the contents of the 2aria#lenamed %R!7LE

    Coe 2or smarter ma&e2ile# -

    CCMgccC.L

  • 7/25/2019 ULP Lab.doc

    36/38

    *xperiment No# - 1

    Aim#- Learning of installation and upgradation of Linux operating system

    Theory# -!nstalling Linux on a personal computer may not #e as difficult as you think This documentexplains how to install Linux on a +C, starting at the #eginning: choosing a distri#utionThe first step for setting up Linux on a +C is the most time consuming, it is simply to use a run from C$2ersion of all distri#utions that you are interested in to pick the 2ersion you want to install (nce you pickthe distri#utions you want to check out, go to the distri#ution8s &e# sites and download the li2e C$4mo2e

    !( image for it Then, using the method for your C$ #urning software, #urn the !( image to C$R()&ith the C$R() in the dri2e, re#oot the computer and you are now running the Linux 2ersion(nce you ha2e selected which distri#ution's* you will install, you can go #ack to that distri#ution8s &e# siteand download the install 2ersion of the distri#ution, which is most commonly made up of three C$R()!( images fter these are downloaded, #urn the !( images to C$R()$elete the images from your hard dri2e after #urning them to C$s3ou will then ha2e to decide, #efore going any further, if you wish to multi-#oot and keep &indows on thesystem !f you are going to keep &indows, you will ha2e to run a defragmenting utility on the dri2e #eforegoing any furtherCompletely cleaning up your hard dri2e, remo2ing all temp files and defragmenting it #efore #acking up thedata is always a good idea, and #acking up your system is recommended #efore installing a new operating

    system 7ecause )icrosoft8s /T. is not D00 percent supported, this is e2en more important if you arerunning any /T-#ased 2ersion of &indows!f you ha2e chosen to use a Q7oxed setQ of Linux, there is a set of Q$(Q tools on one of the C$s, whichwill run in &indows and allow you to resi6e the partition for &indows !f you are using a downloaded2ersion, then you can use the Linux tools during installation, #ut you may ha2e to completely delete the&indows partition 500)7 in si6e ?

    3ou will need to create a partition with the la#el 4 >5

  • 7/25/2019 ULP Lab.doc

    37/38

    Create a partition with the la#el 4home >remaining amount of space for distri#ution?

    Create a partition with the la#el 4usr >5 D or F dou#le your R) in si6e?

    &hen creating the partitions you will notice that you ha2e a num#er of file system type optionsB the oldestone #eing the extFfs !n a graphic installer, the file system types usually ha2e an explanation of what theymean The current default file system is the reiserfs, a Vournaled file system This has a small hit on speed,

    #ut a maVor impro2ement on data protection, compared to a non Vournaled file systempeed and relia#ility for data input4output #eing important, the reiserfs or the extfs are the #est supportedfile systems !f speed is more important than relia#ility, use the extFfs This does not mean maVor risk of dataloss, #ut power fluctuations may cause some data loss or corruption, if you ha2e spotty power, and do notha2e an interrupti#le power supply, go with a Vournali6ed file system.ollow the prompts for the distri#ution you are installing Each distri#ution has a different installation

    process, so detailing them here is not a 2ia#le option !f you are using one with a console 4text interface, thespace #ar selects, and the right arrow will expand a category, the left arrow will collapse a category, up anddown arrows will mo2e you up and down in the listing The enter key will finish the selection process andstart the installation graphic interface installation program will ha2e mouse support!ele0ting a pa0&age

    +ackage selection is a #ig part of installing Linux &hen first trying Linux it doesn8t hurt to installe2erything, as this ena#les you to see which applications you like and will use There are far more optionsthan the li2e C$ 2ersions can include, so while you ha2e some idea a#out packages from ha2ing looked atthe li2e C$, there are more options than those shown

  • 7/25/2019 ULP Lab.doc

    38/38

    multi-#oot for each new distri#ution !t may #e useful to la#el each distro #y its name in the #oot menu asyou go, this will make the #oot options clearer when you are choosing one&hen updating the Red Hat EL or LE operating system on nodes, if the )ode attri#ute is PreManage,then after the operating system upgrade, the )ode attri#ute 2alue is changed to Manage !f the )odeattri#ute is Manage, then it is not changed !f the )ode attri#ute is MinManage#efore the operatingsystem upgrade, then the )ode attri#ute 2alue remains MinManage!f the installnoecommand fails for a PreManagenode, the attri#ute 2alue of the node is PreManageorInstalling !f the installnoecommand fails for a MinManagenode, the attri#ute 2alue of the node isMinManageor MinManage-InstallingTo upgrade the operating system and C) on all the nodes, issue the following command:installnode -aThe Red Hat EL nodes with the !nstall)ethod attri#ute set to &i0&start-upgraeare re#ooted and upgradedwith the new le2el of the operating system, re#ooted, and then C) is updated if necessary The Red Hat ELoperating system upgrade runs asynchronously !mmediately after the operating system upgrade process isinitiated 'that is, when the node is re#ooted*, the installnoecommand exits, e2en though the operatingsystem upgrade is not completeThe LE nodes with the !nstall)ethod attri#ute set to youare updated with the new le2el of the operatingsystem, re#ooted to pick up the new kernel, and then C) is upgraded if necessary The installnoe

    command continues to run as the LE operating system is updated This may take a while to run Then,installnoere#oots the node, and exits The rest of the upgrade process 'C.), ), osupgraepostre"ootscripts, upgrading C)* continues asynchronously3ou can use the -t flag on the installnode command to pro2ide a timeout 2alue in minutes !f you do notspecify a 2alue for timeout, the default is I0 minutes:installnode -+ -t timeout!f the operating system upgrade process does not complete within the timeout period specified, C)considers the operating system upgrade process as failed 3ou can use the monitorinstall command to

    pro2ide output information for the installation processfter the operating system is updated, the following Vo#s run on the node:

    D The osupgraeprere"ootcustomi6ation scripts are run

    F The node re#oots to its local hard disk C) is installed, along with the software listed in +lanning for C) for Linux The node8s )ode attri#ute changes to Manage, or remains MinManage5 H or RH are set up on the node so that the node is accessi#le from the management ser2erI ny C.) files are transferred to the nodeP ) is run to install or update software, if it is configuredA The osupgraepostre"oot customi6ation scripts are run

    !f you defined ber#eros options with the csmconfig command when you defined the management ser2er, theinstallnoecommand sets up the ber#eros options for the clusterfter an operating system upgrade the node 7!( #oot order can remain:

    D diskette

    F C$-R() network hard disk

    E2ery time the node #oots, it uses $ynamic Host Configuration +rotocol '$HC+* to contact themanagement ser2er or install ser2er, which uses pxelinuxto #oot the node from its hard dri2e lternately,after the operating system upgrade is complete, you can change the #oot order in the 7!( to the following:

    D disketteF C$-R() hard disk network

    http://publib.boulder.ibm.com/infocenter/clresctr/vxrx/topic/com.ibm.cluster.csm16010.install.doc/am7il_softreq.html#softreqhttp://publib.boulder.ibm.com/infocenter/clresctr/vxrx/topic/com.ibm.cluster.csm16010.install.doc/am7il_softreq.html#softreq