Danh mục tài liệu

Introduction to the shell

Số trang: 34      Loại file: ppt      Dung lượng: 305.00 KB      Lượt xem: 27      Lượt tải: 0    
Xem trước 4 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Shell là Là một chương trình tiện ích với Linux là hệ thống phục vụ một giao diện giữa người sử dụng, hạt nhân - A shell is a utility program with the Linux system that serves as an interface between the user and the kernel
Nội dung trích xuất từ tài liệu:
Introduction to the shellObjectives Inthislesson,youwilllearnto: • DefinetheroleandfeaturesoftheLinuxshell • Usetheshellasacommandinterpreter • Createuserdefinedvariables • Useshellenvironmentvariables • CreateshellscriptsinLinuxIntroductiontotheShell• Ashell: • Isautilityprogramwiththe Linuxsystemthatservesas aninterfacebetweenthe userandthekernel • Playsanimportantroleof commandinterpretationfor thekernel• Theadjacentfigureshowsthe architectureoftheLinuxoperating system.FeaturesofaShell • Theshellhasthefollowingfeatures: • Interactiveprocessing • Backgroundprocessing • Input/outputredirection • Pipes • Shellscripts • Shellvariables • Programminglanguageconstructs • Commandhistory • Jobcontrol • Filenamecompletion • CommandcompletionShellasaCommandInterpreter • Theshell: • Readsthecommand • Locatesthefileinthedirectoriescontainingutilities • Loadstheutilityintomemory • ExecutestheutilityShellasaCommandInterpreter(Contd.) Theshellcreatesachildshellfortheexecutionofautility Theshellrequeststhekernelforanyhardwareinteraction UnixShells • SomeofthepopularUnixShellsare: • BourneShell:sh istheexecutablefilenameforthisshell • CShell:cshistheexecutablefilenameforthisshell • KornShell:Theexecutablefilenameisksh • RestrictedShell:IstypicallyusedforguestloginsLinuxShells • SomeofthepopularshellsavailableinLinuxare: • Bash: • Isanacronymfor‘BourneAgainShell’andisthedefaultshellformostLinux systems • Usesthesymboliclinksh • Tcsh: • Isanacronymfor‘Tom’sCshell’alsoknownastheTCshell • ItisanenhancementoftheCshell • Usesthesymboliclinkcsh • Canbeexecutedbyusingeithercshortcshattheshellprompt • ASH: • Isusuallysuitableonmachinesthathaveverylimitedmemory • Usesthesymboliclink,bshinFedoraCore2ChangingtheDefaultShell • Thedefaultshelloftheuserisspecifiedinthe/etc/passwdfile. • Thechshcommandcanbeusedforchangingthedefaultshellfortheuser [steve@linuxpc1 /etc]$ chsh ↵ Changing shell for Steve. Password: New shell [/bin/bash]: /bin/csh Shell changed. • Thefullpathforthenewshellhastobegivenwhenchangingtheshell. • AfterthedefaultshellhasbeenchangedfromBashtocsh, theentryfortheuser, steve,inthepasswdfilechangesasfollows steve:x:503:513:steve walker:/home/steve:/bin/cshShellScripts • AShellscript: • StoresasequenceoffrequentlyusedLinuxcommandsinafile • Enablestheshelltoreadthefileandexecutethecommandsinit • Allowsmanipulationofvariables,flowofcontrolanditerationconstructsthatmake programmingpossibleTheecho Command • TheechoCommand • Displaysmessagesonthescreen • Displaysthetext,enclosedwithindoublequotes • Putsanewlinecharacterattheendofthetextbydefault $ echo This is an example of the echo command ↵ This is an example of the echo command $ _ExecutingaShellScript • Ashellscriptcanbeexecuted: • Inanewshellby 1. Firstgrantingtheexecutepermissiontothespecifiedshellscript 2. Theninvokingitsnameatthe$prompt $ chmod u+x magic ↵ [ChangeFileAccessPermission] $ magic ↵ [Executetheshellscript] • Inthecurrentshellbyusingthedot(.)commandwiththescriptnameintheBash shell $ . magic ↵ [IntheBashshells]CreatingVariables • Variablesinshellscripts: • arenotdeclaredasintegersorcharacters • aretreatedascharacterstrings • canbemathematicallymanipulated • donothavetobeexplicitlydeclared • canbecreatedatanypointoftimebyasimpleassignmentofvalue • Thesyntaxforcreatingavariableis: = • Variablescanbecreated: • Inshellscripts:Avariablecreatedwithinashellscriptislostwhenthescriptstops executing. • Attheshellprompt:Avariablecreatedatthepromptremainsinexistenceuntilthe shellisterminated.Referencing ...