20.12020LinuxLinux:LINUXCLINUXCLINUXCadmin,ar,gcc,ci,co,cvs,delta,emacs,gdb,get,grep,help,ident,indent,make,rcsmerge,nm,rcs,ranlib,rlog,strip,time20.2LinuxzLinuxInternetWebLinuxLinuxLinuxInternetLinuxzLinuxFreeSoftwareFoundationGNUGNUGNU’snotUNIXGNUGNULinuxCshellGNU20.3LinuxLinuxGNUzzzzzzifif-elseif-elsez(typedef)20.4LinuxLinuxzifzignore_space_change_flagiCantReadThisz20.522LinuxLinuxLinux8LinuxK&RThisVariableIsATemporaryCountertmp“count_active_users()”“cntusr()”20.620.220.2linuxshellperlvisualbasicvisualc++20.7Figure20.1Figure20.120.820.320.3Figure20.2Figure20.220.9Figure20.3Figure20.3TheprocessoftranslatingCprogramstoexecutablecodeTheprocessoftranslatingCprogramstoexecutablecodeC20.1020.520.5cviemacspicoCzBrianKernighanDennisRitchie(UnixC)CC(K&R)zLINUXindentCzindentGNU20.11$moresecond.cmain(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}$indentsecond.c$lssecond.csecond.c~$moresecond.cmain(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}indentindentsecond.csecond.csecond.csecond.csecond.csecond.c~~GNU20.12CC$moresecond.c~main(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}$20.13CC$indent-kr-stsecond.cmain(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}$indent-bad-kr-stsecond.cmain(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}K&R(-kr)-bad20.14CC$indent-orig-stsecond.cmain(){inti,j;for(i=0,j=10;ij;i++){printf(LINUX\n);}}Berkeley(-orig)20.1520.5.3c20.5.3cLinuxcgccGNUc/c++compilerC++g++gcczgcc[]z/-c.o-l-oa.out20.16cc$gccfirst.c#a.out$./a.out#Linux$gcc-osloganfirst.c#slogan$./slogan#Linux-c$gcc-cdriver.c#driver.o$gcc-cstack.c#stack.o$gcc-cmisc.c#misc.o$gccdriver.ostack.omisc.o–opolish20.17ccgcc-llabm.apower.o$gccpower.o-lm–opower“”20.1820.5.4make20.5.4makemake20.19makemakemakemakefileGNUmakemakefilemakefilemakefileGNUmakefilemakefileMakefilemakemakemakefileLinuxMakefile20.20makemakeMakefilemaketargetdependencycommandmakemake20.21makemakeMakefiletabMakefilez“”make“clean”z“”z“”makeTABmake“”“”“”20.22makemakeMakefile#Makefiletestprog.ocode.ogcc–otestprog.ocode.oprog.oprog.cprog.hcode.hgcc–cprog.c–oprog.ocode.ocode.ccode.hgcc–ccode.c–ocode.ocleanrm–f*.o20.23makemakeMakefiletestprog.ocode.ocleanMakefile\\make$maketargettargetMakefiletargetmakeMakefileMakefile“make”$maketesttestMakefilemaketesttesttestprog.ocode.o20.24makemakeprog.ocode.omakeprog.ocode.oprog.oprog.cprog.hcode.hmakeprog.omake“gcc–cprog.c–oprog.o”prog.ocode.ocode.ccode.hmakemaketestprog.ocode.o.otesttestmakegccprog.ocode.otestMakefilecleanMakefilemakemakemakefileMakefile20.25MakefileMakefileMakefilemakemakezgcczLinuxgcczgcc20.26MakefileMakefileMakefileMakefile“”VARNAME=string$${VARNAME}makeVARNAMEMakefileMakefileMakefile20.27MakefileMakefileMakefileOBJS=prog.ocode.oCC=gcctest${OBJS}${CC}–otest${OBJS}prog.oprog.cprog.hcode.h${CC}–cprog.c–oprog.ocode.ocode.ccode.h${CC}–ccode.c–ocode.ocleanrm–f*.o20.28MakefileMakefilemakemakemakeshellMakefileMakefileMakefile20.2920.4make20.4make20.3020.5make20.5make20.3120.620.6makemake20.32(functionpoints)gprof20.33GDBGDBLinuxGNUgdbCC++gdbzzzzzz20.34GDBGDB20.35GDBGDBgdbgdbgcc-ggdbgdbgdbgdb20.36GDBGDBGNUgdbRedHatLinux(5.3post-0.20021129.18rh)Copyright2003FreeSoftwareFoundation,Inc.GDBisfreesoftware,coveredbytheGNUGeneralPublicLicense,andyouarewelcometochangeitand/ordistributecopiesofitundercertainconditions.Typeshowcopyingtoseetheconditions.ThereisabsolutelynowarrantyforGDB.Typeshowwarrantyfordetails.ThisGDBwasconfiguredasi386-redhat-linux-gnu.(gdb)gdbhelp.gdbbreakgdbbreakbreakbreakLinuxShellmangdbman20.37GDBGDBgdb,gdbz1filez2cdz3pwdz4runz5killz6listz7breakz8tbreakbreaktbreak20.38GDBGDBz9watchz10awatchwatchz11rwatchwatchz12nextrunz13steprunz14displayz15infobreak20.39GDBGDBz16infofilesz17infofuncz18infolocalz19infoprogz20printz21deletez22shellLinuxShellz23makegdbz24helpgdbz25quitgdb20.40GDBGDB$gcc-gbugged.c-obugged$gdb-qbugged(gdb)gdb20.41timeshell“::.”time[]z()()()20.42RCS/CVSRCSrcsRCS1RCSRCS[root@wyhlinux]#mkdirRCSciRCS[root@wyhlinux]#citest.c20.43[root@wyhlinux]#cotest.c-l[root@wyhlinux]#co-ltest.cRCS-l[root@wyhlinux]#ci-ltest.cRCS[root@wyhlinux]#rcsdifftest.c2coRCSRCS-r[root@wyhlinux]#ci-l-r3.25test.c--3.2520.44[root@wyhlinux]#co-l-r1.2test.c--RCS1.2test.crcsdiff[root@wyhlinux]#rcsdiff-r3.25test.c--3.25test.c3RCSRCS$Author$RCS$Data$RCS$Header$RCS20.451[root@wyhlinux]#vitest.c2RCS[root@wyhlinux]#ci-ltest.c3co[root@wyhlinux]#co-ltest.c[root@wyhlinux]#cattest.c20.46CVS–1CVS“”“”20.47CVSROOTCVSinit#CVSROOT=/usr/local/cvsroot;exportCVSROOT#cvsinit#ls-l$CVSROOT2$CVSROOT/cvstest/c-mvicvstest/cCVSwu,cvstest20.483$CVSROOT/CVSROOT/modules:#cvscheckoutCVSROOT/modulesmodulesSOURCEcvstest/c20.49#cvscommit–m“AddSOURCE”cvstest/c#cvscheckoutSOURCE$CVSROOT2cvsadd[-kkflags][-mmessage]files...-k-mcvsremove[options]files20.503cvscommit[-Rl][-mmesg]files-R-l-m4cvsrelease–dSOURCEcvstest/crm–rfcvstest4#cvsupdate20.51CVStest.c1.4AB1.5ACVS2cvslog[-lR][-rrev][-ddate][-wlogin][files…]-l-R-r-d-wcvsannotate[-lR][-rrev|-Ddate]files20.52-l-R-rcvsrtag–b–rrev_rootre