您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 悉尼科技大学UNIX教程lectureUnix1-Intro
UnixSystemsProgramming(32547)IntroductiontoUNIXLecture1:Introduction1.Whatissystemsprogramming2.WhyUnix?3.IntroductiontotheUnixshell4.AfirstsetofusefulUnixcommands5.Aone-slideintroductiontoPerlWhatisSystemsProgramming?•Systemsprogramming,inastrictsense,meansprogrammingsystemsoftware–softwarethatispartoforrelatedtoanOperatingSystem(OS).•AnOSisthebasicsoftwarethatpermitstheoperationofacomputer.Itoffersservicestotheapplicationprograms(bymeansofapplicationprogramminginterfaces(APIs)andsystemcalls)andtheuser(bymeansofuserinterfaces)•Inthissubject,weinterpretsystemprogramminginabroadersense,asprogramsthatareawareofOSfeatures.Inapplicationprogramming,instead,nosignificantknowledgeoftheOSisexpectedorneededAnOSarchitecture:theUnix“onion”modelHardwareDevicesKernelShellGraphicalUserInterfaceWhatthemodelmeans?Operatingsystemscanbeconstructedinasetoflayers:Kernel–centralcomponentoftheOSControlsthehardwaredirectlyVirtualization:providesaccessforotherprogramswhichdonotneedtobeawareofthehardware’sfeaturesExamplesofkernels:WindowsNTKernelandLinuxKernelfori386/PentiumSunOSandSolarisforSUNSPARCstationsShell-alsoknownasCommandLineInterface(CLI)(orInterpreter)AprogramthatmakesasetofcommandsavailabletotheuserExamples:sh,bash,cshontopofUnix/LinuxWindowsCommandPrompt/MS-DOSGraphicalUserInterface(GUI)WindowsGUIGnome,KDE,andXfcedesktopenvironmentsontopofX-WindowsontopofUnixHardwareKernelShellGUICLIversusGUI•However,theyareabsolutelyinconvenientforrepeatedoperations(theuserhastorepeatalloperationsstepbystep)•CLIsaremuchmoreflexibleandpowerfulforthat•GUIshavebecomeincreasinglypopularsincethefirstAppleMacintoshmadeitsappearancein1984•Theyareveryconvenientforcertainoperationssuchasbrowsingadirectory(akafolder),selectingafile,changingitsnameThisimageissourcedfromWikipediaanddepictscopyrightedsoftware;itsuseforthepurposeofillustratingthesoftwareisfairunderUSlawCLI:exampleExample:findthetextfileinthisdirectorywiththegreatestnumberoflinescontainingtheword“food”Withshellscriptingit’seasy…grep-cwfood*|sort-n-k2-t:|tail-n1SeefurthercommentsonNotesPageWhyUnix?•Bornin1969(AT&TBellLabs)Microsoft:DOS–1981,Windows-1983•BuiltbyprogrammersforprogrammersMicrosoft:fornon-programmers–wordprocessing,spreadsheet,graphics•Flexible,Scalable,Networked-basisoftheInternetforinternationalcommunicationMicrosoft:networkinglateinthepiece•Stability:almostnevercrashes•Security:mostusedbyadtministratorsandmaintained,thereforefewervirusesWarning!ThehistoryofUnixcourtesyofWikipedia,:Unix_history.en.svgWarning:2•Unixisnotsingle,monobrandOS–unlikeWindows•Manymainversionshavebeenreleased•Furthermore,manydifferentshellshavebeenproduced:sh,csh,tcsh,ksh,bashandothers•AcrossdifferentUnixversions,eventhesameshellperformssomehowdifferentlyCheckthedifferencesbetween:•lsonbashoncharliewithSunOS•lsonbashonaLinuxboxOughttobethesame,butitisn’t!://en.wikipedia.org/wiki/Single_UNIX_SpecificationLinux1.Linuxisbecomingapseudo-standardUnixbecause:•It’sfree:soeveryoneispleasedtouseit•It’sopensource:soifauserfindsabug,they’lloftenfixit•Ifthere’ssomethingnewrequired:auserwilldevelopitAsaresult,Linuxisgenerallywhat’sbeingusedonmanynewsystems2.Bashisalsobecomingapseudo-standardbecauseitincorporatesthebestfeaturesofoldershellssuchastheCshellandKornshellOurconventionsInthissubject(particularlyintests),whenwesay•UnixwegenerallymeanLinux(althoughcharlieisSunOS)•ShellwealwaysmeanbashUnixshellcommandsThegeneralsyntaxofaUnixshellcommandis:command[options][arguments]•commandisthecommandname•Theoptionsaretypicallyprecededbya“-”andmodifythebehaviourofthecommand•Theargumentsidentifythedata(usuallyafileorfiles)uponwhichthecommandperformsExamples:ls–allistallfilesinthisdirectoryinlonglistingformatcat–ndates.txtdisplaysfiledates.txtprecedingeachlinewithanumberGettinghelp(manpages)•man's[your]bestfriendUserCommandsman(1)NAMEman-findanddisplayreferencemanualpagesSYNOPSISman[-][-adFlrt][-Mpath][-Tmacro-package][-ssection]name...man[-Mpath]-kkeyword...man[-Mpath]-ffile...DESCRIPTIONThemancommanddisplaysinformationfromthereferencemanuals.Itdisplayscompletemanualpagesthatyouselectbyname,orone-linesummariesselectedeitherbykeyword(-k),orbythenameofanassociatedfile(-f).Ifnomanualpageislocated,manprintsanerrormessage.•man'spagesareofteninstalledontheUnixsystemorcanbefoundinwebsites(becarefulyou’reusingtherightones)Example•Youwanttoensurethatwhenyoumoveafiletoanewdestination,youwillbepromptedbythesystemifafilewiththesamenamealreadyexistsatthedestination•Yousearchthewebfor“unixmovecommand”anddiscoverthattheneededcommandismv.Then,manmv:bash-4.0$manmvUserCommandsmv(1)NAMEmv-movefilesSYNOPSIS/usr/bin/mv[-fi]sourcetarget_file[...]-imvwillpromptforconfirmationwheneverthemovewouldoverwriteanexistingtarget.[...]•mv–isourcedestinationistherightanswer•Afilesystemorganisesyourdatainfilesanddirectoriesandstoresthemacrosssessions•Afilesystemislogicallyorganisedlikeaninvertedtree:•Anabsolutepathnamereferstoafilesystemobjectfromthetree’sroot.Example
本文标题:悉尼科技大学UNIX教程lectureUnix1-Intro
链接地址:https://www.777doc.com/doc-2438629 .html