Introduction1.RedHatSystemAdministrationIRedHatSystemAdministrationIintroductionRedHatSystemAdministrationI(RH124)isdesignedforITprofessionalswithoutpreviousLinuxsystemadministrationexperience.ThecourseisintendedtoprovidestudentswithLinuxadministration"survivalskills"byfocusingoncoreadministrationtasks.RedHatSystemAdministrationIalsoprovidesafoundationforstudentsplanningtobecomefull-timeLinuxsystemadministratorsbyintroducingkeycommand-lineconceptsandenterprise-leveltools.Theseconceptsarefurtherdevelopedinthefollow-oncourse,RedHatSystemAdministrationII(RH134).CourseobjectivesoGainsufficientskilltoperformcoresystemadministrationtasksonRedHatEnterpriseLinux.oBuildfoundationalskillsneededbyanRHCSA-certifiedRedHatEnterpriseLinuxsystemadministrator.AudienceoITprofessionalsacrossabroadrangeofdisciplineswhoneedtoperformessentialLinuxadministrationtasks,includinginstallation,establishingnetworkconnectivity,managingphysicalstorageandbasicsecurityadministration.PrerequisitesoTherearenoformalprerequisitesforthiscourse;however,previoussystemadministrationexperienceonotheroperatingsystemswillbeverybeneficial.2.OrientationtotheClassroomEnvironmentInthiscourse,studentswilldomosthands-onpracticeexercisesandlabworkwithtwocomputersystems,whichwillbereferredtoasdesktopandserver.ThesemachineshavethehostnamesdesktopX.example.comandserverX.example.com,wheretheXinthecomputers'hostnameswillbeanumberthatwillvaryfromstudenttostudent.Bothmachineshaveastandarduseraccount,student,withthepasswordstudent.Therootpasswordonbothsystemsisredhat.EachstudentisontheIPv4network172.25.X.0/24,wheretheXmatchesthenumberoftheirdesktopXandserverXsystems.Theinstructorrunsacentralutilityserver,classroom.example.com,whichactsasarouterfortheclassroomnetworksandprovidesDNS,DHCP,HTTP,andothercontentservices.ClassroomMachinesMachinenameIPaddressesRole
MachinenameIPaddressesRoledesktopX.example.com172.25.X.10Student"client"computerserverX.example.com172.25.X.11Student"server"computerclassroom.example.com172.25.254.254Classroomutilityserver3.InternationalizationLanguagesupportRedHatEnterpriseLinux7officiallysupports22languages:English,Assamese,Bengali,Chinese(Simplified),Chinese(Traditional),French,German,Gujarati,Hindi,Italian,Japanese,Kannada,Korean,Malayalam,Marathi,Odia,Portuguese(Brazilian),Punjabi,Russian,Spanish,Tamil,andTelugu.Per-userlanguageselectionUsersmayprefertouseadifferentlanguagefortheirdesktopenvironmentthanthesystem-widedefault.Theymayalsowanttosettheiraccounttouseadifferentkeyboardlayoutorinputmethod.LanguagesettingsIntheGNOMEdesktopenvironment,theusermaybepromptedtosettheirpreferredlanguageandinputmethodonfirstlogin.Ifnot,thentheeasiestwayforanindividualusertoadjusttheirpreferredlanguageandinputmethodsettingsistousetheRegion&Languageapplication.Runthecommandgnome-control-centerregion,orfromthetopbar,select(User)→Settings.Inthewindowthatopens,selectRegion&Language.TheusercanclicktheLanguageboxandselecttheirpreferredlanguagefromthelistthatappears.ThiswillalsoupdatetheFormatssettingtothedefaultforthatlanguage.Thenexttimetheuserlogsin,thesechangeswilltakefulleffect.ThesesettingsaffecttheGNOMEdesktopenvironmentandanyapplications,includinggnome-terminal,startedinsideit.However,theydonotapplytothataccountifaccessedthroughansshloginfromaremotesystemoralocaltextconsole(suchastty2).NoteAusercanmaketheirshellenvironmentusethesameLANGsettingastheirgraphicalenvironment,evenwhentheyloginthroughatextconsoleoroverssh.Onewaytodothisistoplacecodesimilartothefollowingintheuser's~/.bashrcfile.Thisexamplecodewillsetthelanguageusedonatextlogintomatchtheonecurrentlysetfortheuser'sGNOMEdesktopenvironment:i=$(grep'Language='/var/lib/AccountService/users/${USER}\|sed's/Language=//')if["$i"!=""];thenexportLANG=$ifiJapanese,Korean,Chinese,orotherlanguageswithanon-Latincharactersetmaynotdisplayproperlyonlocaltextconsoles.IndividualcommandscanbemadetouseanotherlanguagebysettingtheLANGvariableonthe
commandline:[user@host~]$LANG=fr_FR.utf8datejeu.avril2417:55:01CDT2014Subsequentcommandswillreverttousingthesystem'sdefaultlanguageforoutput.ThelocalecommandcanbeusedtocheckthecurrentvalueofLANGandotherrelatedenvironmentvariables.InputmethodsettingsGNOME3inRedHatEnterpriseLinux7automaticallyusestheIBusinputmethodselectionsystem,whichmakesiteasytochangekeyboardlayoutsandinputmethodsquickly.TheRegion&Languageapplicationcanalsobeusedtoenablealternativeinputmethods.IntheRegion&Languageapplication'swindow,theInputSourcesboxshowswhatinputmethodsarecurrentlyavailable.Bydefault,English(US)maybetheonlyavailablemethod.HighlightEnglish(US)andclickthekeyboardicontoseethecurrentkeyboardlayout.Toaddanotherinputmethod,clickthe+buttonatthebottomleftoftheInputSourceswindow.AnAddanInputSourcewindowwillopen.Selectyourlanguage,andthenyourpreferredinputmethodorkeyboardlayout.Oncemorethanoneinputmethodisconfigured,theusercanswitchbetweenthemquicklybytypingSuper+Space(sometimescalledWindows+Space).AstatusindicatorwillalsoappearintheGNOMEtopbar,whichhastwofunctions:Itindicateswhichinputmethodisactive,andactsasamenuthatcanbeusedtoswitchbetweeninputmethodsorselectadvancedfeaturesofmorecomplexinputmethods.Someofthemethodsaremarkedwithgears,whichindicatethatthosemethodshaveadvancedconfigurationoptionsandcapabilities.Forexample,theJapaneseJapanese(KanaKanji)inputmethodallowstheusertopre-edittextinLatinanduseDownArrowandUpArrowkeystoselectthecorrectcharacterstouse.USEnglishspeakersmayfindalsothisuseful.Forexample,underEnglish(UnitedStates)isthekeyboardlayoutEnglish(internationalAltGrdeadkeys),whichtreatsAltGr(ortherightAlt)onaPC104/105-keykeyboardasa"secondary-shift"modifierkeyanddeadkeyactivationkeyfortypingadditionalcharacters.TherearealsoDvorakandotheralternativelayoutsavailable.NoteAnyUnicodecharactercanbeenteredintheGNOMEdesktopenvironmentiftheuserknowsthecharacter'sUnicodecodepoint,bytypingCtrl+Shift+U,followedbythecodepoint.AfterCtrl+Shift+Uhasbeentyped,anunderlineduwillbedisplayedtoindicatethatthesystemiswaitingforUnicodecodepointentry.Forexample,thelowercaseGreekletterlambdahasthecodepointU+03BB,andcanbeenteredbytypingCtrl+Shift+U,then03bb,thenEnter.System-widedefaultlanguagesettingsThesystem'sdefaultlanguageissettoUSEnglish,usingtheUTF-8encodingofUnicodeasitscharacterset(en_US.utf8),butthiscanbechangedduringorafterinstallation.Fromthecommandline,rootcanchangethesystem-widelocalesettingswiththelocalectlcommand.Iflocalectlisrunwithnoarguments,itwilldisplaythecurrentsystem-widelocalesettings.Tosetthesystem-widelanguage,runthecommandlocalectlset-locale
LANG=locale,wherelocaleistheappropriate$LANGfromthe"LanguageCodesReference"tableinthischapter.Thechangewilltakeeffectforusersontheirnextlogin,andisstoredin/etc/locale.conf.[root@host~]#localectlset-localeLANG=fr_FR.utf8InGNOME,anadministrativeusercanchangethissettingfromRegion&LanguageandclickingtheLoginScreenbuttonattheupper-rightcornerofthewindow.ChangingtheLanguageoftheloginscreenwillalsoadjustthesystem-widedefaultlanguagesettingstoredinthe/etc/locale.confconfigurationfile.ImportantLocaltextconsolessuchastty2aremorelimitedinthefontsthattheycandisplaythangnome-terminalandsshsessions.Forexample,Japanese,Korean,andChinesecharactersmaynotdisplayasexpectedonalocaltextconsole.Forthisreason,itmaymakesensetouseEnglishoranotherlanguagewithaLatincharactersetforthesystem'stextconsole.Likewise,localtextconsolesaremorelimitedintheinputmethodstheysupport,andthisismanagedseparatelyfromthegraphicaldesktopenvironment.TheavailableglobalinputsettingscanbeconfiguredthroughlocalectlforbothlocaltextvirtualconsolesandtheX11graphicalenvironment.Seethelocalectl(1),kbd(4),andvconsole.conf(5)manpagesformoreinformation.LanguagepacksWhenusingnon-Englishlanguages,youmaywanttoinstalladditional"languagepacks"toprovideadditionaltranslations,dictionaries,andsoforth.Toviewthelistofavailablelangpacks,runyumlangavailable.Toviewthelistoflangpackscurrentlyinstalledonthesystem,runyumlanglist.Toaddanadditionallangpacktothesystem,runyumlanginstallcode,wherecodeisthecodeinsquarebracketsafterthelanguagenameintheoutputofyumlangavailable.Referenceslocale(7),localectl(1),kbd(4),locale.conf(5),vconsole.conf(5),unicode(7),utf-8(7),andyum-langpacks(8)manpagesConversionsbetweenthenamesofthegraphicaldesktopenvironment'sX11layoutsandtheirnamesinlocalectlcanbefoundinthefile/usr/share/X11/xkb/rules/base.lst.3.1.LanguageCodesReferenceLanguageCodesLanguage$LANGvalueEnglish(US)en_US.utf8Assameseas_IN.utf8Bengalibn_IN.utf8Chinese(Simplified)zh_CN.utf8Chinese(Traditional)zh_TW.utf8
Language$LANGvalueFrenchfr_FR.utf8Germande_DE.utf8Gujaratigu_IN.utf8Hindihi_IN.utf8Italianit_IT.utf8Japaneseja_JP.utf8Kannadakn_IN.utf8Koreanko_KR.utf8Malayalamml_IN.utf8Marathimr_IN.utf8Odiaor_IN.utf8Portuguese(Brazilian)pt_BR.utf8Punjabipa_IN.utf8Russianru_RU.utf8Spanishes_ES.utf8Tamilta_IN.utf8Telugute_IN.utf81.AccessingtheCommandLineChapter1.AccessingtheCommandLine1.1.AccessingtheCommandLineUsingtheLocalConsole1.2.Practice:LocalConsoleAccessTerms1.3.AccessingtheCommandLineUsingtheDesktop1.4.Practice:TheGNOME3DesktopEnvironment
1.5.ExecutingCommandsUsingtheBashShell1.6.Practice:BashCommandsandKeyboardShortcuts1.7.Lab:AccessingtheCommandLineIntroductionOverviewGoalTologintoaLinuxsystemandrunsimplecommandsusingtheshell.ObjectivesoUseBashshellsyntaxtoentercommandsataLinuxconsole.oLaunchapplicationsinaGNOMEdesktopenvironment.oUseBashfeaturestoruncommandsfromashellpromptusingfewerkeystrokes.SectionsoAccessingtheCommandLineUsingtheLocalConsole(andPractice)oAccessingtheCommandLineUsingtheDesktop(andPractice)oExecutingCommandsUsingtheBashShell(andPractice)LaboAccessingtheCommandLine1.1.AccessingtheCommandLineUsingtheLocalConsoleObjectivesAftercompletingthissection,studentsshouldbeabletologintoaLinuxsystemonalocaltextconsoleandrunsimplecommandsusingtheshell.ThebashshellAcommandlineisatext-basedinterfacewhichcanbeusedtoinputinstructionstoacomputersystem.TheLinuxcommandlineisprovidedbyaprogramcalledtheshell.OverthelonghistoryofUNIX-likesystems,manyshellshavebeendeveloped.ThedefaultshellforusersinRedHatEnterpriseLinuxistheGNUBourne-AgainShell(bash).BashisanimprovedversionofoneofthemostsuccessfulshellsusedonUNIX-likesystems,theBourneShell(sh).Whenashellisusedinteractively,itdisplaysastringwhenitiswaitingforacommandfromtheuser.Thisiscalledtheshellprompt.Whenaregularuserstartsashell,thedefaultpromptendswitha$character.[student@desktopX~]$The$isreplacedbya#iftheshellisrunningasthesuperuser,root.Thismakesitmoreobviousthatitisasuperusershell,whichhelpstoavoidaccidentsandmistakesintheprivilegedaccount.[root@desktopX~]#Usingbashtoexecutecommandscanbepowerful.Thebashshellprovidesascriptinglanguagethatcansupportautomationoftasks.Theshellhasadditionalcapabilitiesthatcansimplifyormakepossibleoperationsthatarehardtoaccomplishefficientlywithgraphicaltools.IntroductiontoBashNote
ThebashshellissimilarinconcepttothecommandlineinterpreterfoundinrecentversionsofMicrosoftWindowscmd.exe,althoughbashhasamoresophisticatedscriptinglanguage.ItisalsosimilartoWindowsPowerShellinWindows7andWindowsServer2008R2.MacOSXadministratorswhousetheMacintosh'sTerminalutilitymaybepleasedtonotethatbashisthedefaultshellinMacOSX.VirtualconsolesUsersaccessthebashshellthroughaterminal.Aterminalprovidesakeyboardforuserinputandadisplayforoutput.Ontext-basedinstallations,thiscanbetheLinuxmachine'sphysicalconsole,thehardwarekeyboardanddisplay.Terminalaccesscanalsobeconfiguredthroughserialports.Anotherwaytoaccessashellisfromavirtualconsole.ALinuxmachine'sphysicalconsolesupportsmultiplevirtualconsoleswhichactlikeseparateterminals.Eachvirtualconsolesupportsanindependentloginsession.Ifthegraphicalenvironmentisavailable,itwillrunonthefirstvirtualconsoleinRedHatEnterpriseLinux7.Fiveadditionaltextloginpromptsareavailableonconsolestwothroughsix(oronethroughfiveifthegraphicalenvironmentisturnedoff).Withagraphicalenvironmentrunning,accessatextloginpromptonavirtualconsolebyholdingCtrl+Altandpressingafunctionkey(F2throughF6).PressCtrl+Alt+F1toreturntothefirstvirtualconsoleandthegraphicaldesktop.ImportantInthepre-configuredvirtualimagesdeliveredbyRedHat,loginpromptshavebeendisabledinthevirtualconsoles.NoteInRedHatEnterpriseLinux5andearlier,thefirstsixvirtualconsolesalwaysprovidedtextloginprompts.Whenthegraphicalenvironmentwaslaunched,itranonvirtualconsoleseven(accessedthroughCtrl+Alt+F7).ShellbasicsCommandsenteredattheshellprompthavethreebasicparts:oCommandtorunoOptionstoadjustthebehaviorofthecommandoArguments,whicharetypicallytargetsofthecommandThecommandisthenameoftheprogramtorun.Itmaybefollowedbyoneormoreoptions,whichadjustthebehaviorofthecommandorwhatitwilldo.Optionsnormallystartwithoneortwodashes(-aor--all,forexample)todistinguishthemfromarguments.Commandsmayalsobefollowedbyoneormorearguments,whichoftenindicateatargetthatthecommandshouldoperateon.Forexample,thecommandlineusermod-Lmorganhasacommand(usermod),anoption(-L),andanargument(morgan).Theeffectofthiscommandistolockthepasswordonusermorgan'saccount.Touseacommandeffectively,auserneedstoknowwhatoptionsandargumentsittakesandinwhatorderitexpectsthem(thesyntaxofthecommand).Mostcommandshavea--helpoption.Thiscausesthecommandtoprintadescriptionofwhatitdoes,a"usagestatement"thatdescribesthecommand'ssyntax,andalistoftheoptionsitacceptsandwhattheydo.Usagestatementsmayseemcomplicatedanddifficulttoread.Theybecomemuchsimplertounderstandonceauserbecomesfamiliarwithafewbasicconventions:oSquarebrackets,[],surroundoptionalitems.oAnythingfollowedby...representsanarbitrary-lengthlistofitemsofthattype.
oMultipleitemsseparatedbypipes,|,meansonlyoneofthemcanbespecified.oTextinanglebrackets,<>,representsvariabledata.Forexample,means“insertthefilenameyouwishtousehere”.Sometimesthesevariablesaresimplywrittenincapitalletters(e.g.,FILENAME).Considerthefirstusagestatementforthedatecommand:[student@desktopX~]$date--helpdate[OPTION]...[+FORMAT]Thisindicatesthatdatecantakeanoptionallistofoptions([OPTION]...),followedbyanoptionalformatstring,prefixedwithapluscharacter,+,thatdefineshowthecurrentdateshouldbedisplayed([+FORMAT]).Sincebothoftheseareoptional,datewillworkevenifitisnotgivenoptionsorarguments(itwillprintthecurrentdateandtimeusingitsdefaultformat).NoteThemanpageforacommandhasaSYNOPSISsectionthatprovidesinformationaboutthecommand'ssyntax.Theman-pages(7)manpagedescribeshowtointerpretallthesquarebrackets,verticalbars,andsoforththatusersseeinSYNOPSISorausagemessage.Whenauserisfinishedusingtheshellandwantstoquit,thereareacoupleofwaystoendthesession.Theexitcommandterminatesthecurrentshellsession.AnotherwaytofinishasessionisbytypingCtrl+D.Referencesintro(1),bash(1),console(4),pts(4),andman-pages(7)manpagesNote:Somedetailsoftheconsole(4)manpage,involvinginit(8)andinittab(5),areoutdated.1.2.Practice:LocalConsoleAccessTermsQuizMatchthefollowingitemstotheircounterpartsinthetable.DescriptionTermTheinterpreterthatexecutescommandstypedasstrings.ShellThevisualcuethatindicatesaninteractiveshelliswaitingfortheusertotypeacommand.PromptThenameofaprogramtorun.CommandThepartofthecommandlinethatadjuststhebehaviorofacommand.OptionThepartofthecommandlinethatspecifiesthetargetthatthecommandshouldoperateon.ArgumentThehardwaredisplayandkeyboardusedtointeractwithasystem.PhysicalconsoleOneofmultiplelogicalconsolesthatcaneachsupportanindependentloginsession.VirtualconsoleAninterfacethatprovidesadisplayforoutputandakeyboardforinputtoashellsession.Terminalgraderesetshowsolutionrh124-en_US-1.0-7.0-1.r23974full