Professional Documents
Culture Documents
Commands Exercises
Commands Exercises
1. Loginasthesysadminuser: Atthegraphicalloginwindowloginusing username:sysadmin password:<giveninclass> 2. Openaterminalwindow UnderApplicationsmenuopentheAccessoriessubmenuandthenchooseTerminal. Onceyouhaveaterminalwindowopenyoucanproceedwiththeexercises. 3. Viewfiles: Uselstolistfiles: $cd $ls Doyouseeanything?Trythisinstead: $lslah What'sinsideoneofthesefiles? $cat.bashrc [gotoyourhomedirectory]
4. Workingwiththecommandprompt: Youcanrecoverpreviouscommandsbyusingtheuparrowanddownarrowkeys.Givethis atrynow. Alternately,trytypingthiscommand: $history Ifyouwishtoexecuteoneofthecommandsinthelistyousawtype: $!nn Wherennisthenumberofthecommandinthehistorylist.Thisisusefulifyouwantto runapastcommandthatwaslongand/orcomplicated. Commandcompletion: Withthebashshellyoucanautocompletecommandsusingthetabkey.Thismeans,ifyou typepartofacommand,onceyouhaveauniquestringifyoupresstheTABkeythe commandwillcomplete.IfyoupresstheTABkeytwiceyou'llseeallyouravailableoptions. Yourinstructorwilldemonstratethis,butgiveitatrybydoing: $hist<TAB> $del<TAB><TAB> $rm<TAB><TAB> 5. Workingwithpipes: Wesawanexampleofusingpipeswhenwesortedthecontentsofour/sbindirectoryduring thepresentation.Whatifyouwantedtohavethisinformationavailableinafileandsorted?
AdoptedfromNSRCwithpermission.
[Includethespaceaftertherm]
Youshouldseesomethinglike inst:*:1001:1001::/home/sysadmin:/bin/bash Thepreviousitemsaboveare: userid:passwd:uid:gid:Name:HomeDir:LoginShell grepisoftenusedwithapipetoreducethenumberofresults.Forinstance: $history|grepls Willdisplayyourprevioususeofthelscommandfromexercise2. 7. Editingthecommandlinerevisited: Itisparticularlyusefultorealizethatyoucaneditacommandjustasyouwouldalineof textinafile.Forinstance,youcan: Useyourbackarrowandforwardarrowkeystochangetextinacommand. UsetheHomeandEndkeystogotothestartandtheendofacommand. Note:youdonotneedtogototheendofacommandbeforepressing<ENTER>toexecute thecommand. Youcanusethehistorycommandwithgreptofindapreviouscommand.Youcan copyandpastethiscommand,theneditittomakeadjustments.Forlongcommandsthiscan saveconsiderabletime. Alternativelyyoucanusethereversesearchfeatureofbash: 1.)Pressctrlr. 2.)typethetermyouaresearchingfor.
AdoptedfromNSRCwithpermission.
Then,let'slookforperlin/usr/share/perl5.Trythis: ctrlr,typeperl,thenpressleftarrow.Editthepreviouscommand(whichyoushouldnow have)andadd/perl5pastshare.Usetheleftarrowkeytomove.Youshouldnowhave: $lslah/usr/share/perl5|grepperl* Withyourcursorjustpastthe5inperl5.Press<ENTER>toexecutethecommand. (bytheway,youwon'tfindanything.) 8. Copyandpastingcommands: AnicefeatureinUnixisthebuiltinautomaticcopybuffer(thinkautomaticclipboard). Assoonasyouhighlighttextitisavailableinyourcopybuffer.Youdonotneedneedtouse thectrlc,ctrlvkeyboardcombinationtocopyandpastetext. Afteryouhavehighlightedtext,thenyoucanplaceyourcursorwhereyouwanttopastethe highlightedtextandpressthemiddlemousebuttontodothetextpaste. Givethisatry: $history|grepperl Locatethepreviouscommandfromexercise5andhighlightjustthatcommand.Highlight thecommandtext(notthenumbernexttoit). Nowpressthemiddlemousekey.Thecommandshouldbepastedtoyourprompt. Didthiswork?Nowyoucouldeditthecommandorjustpressentertoexecuteit. Thisisveryusefulifyouhavetwoterminalsopenandwanttousetextfromoneterminalin adifferentterminal.Or,ifyouwishtocopyresultingtextfromacommandinoneterminal intoafilethat'sopeninanotherterminaletc. 9. SoftwareInstallation
AdoptedfromNSRCwithpermission.
Ifyouareloggedinastherootuserpleasedothefollowing: #exit Tobecomeanormaluser,likesysadmin.Yourpromptshould changetoincludea$sign. $ Let'sfigureoutwhatpackageinstallsthelynxtextbasedwebbrowser $aptcachesearchlynx Nosurprisewhatitis...Now,let'sinstallthis: $sudoaptgetinstalllynx Nowlet'suseit... $lynxnsrc.org Press q to exit lynx.
AdoptedfromNSRCwithpermission.