Starting A Terminal: in Unity

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 9

"UnderLinuxthereareGUIs(graphicaluserinterfaces),whereyoucanpointandclickanddrag,and hopefullygetworkdonewithoutfirstreadinglotsofdocumentation.ThetraditionalUnixenvironment isaCLI(commandlineinterface),whereyoutypecommandstotellthecomputerwhattodo.Thatis fasterandmorepowerful,butrequiresfindingoutwhatthecommandsare." frommanintro(1) TherearemanyvarietiesofLinux,butalmostallofthemusesimilarcommandsthatcanbeentered fromacommandlineinterfaceterminal. Therearealsomanygraphicaluserinterfaces(GUIs),buteachofthemworksdifferentlyandthereis littlestandardizationbetweenthem.ExperienceduserswhoworkwithmanydifferentLinux distributionsthereforefinditeasiertolearncommandsthatcanbeusedinallvarietiesofUbuntuand, indeed,inotherLinuxdistributionsaswell.

Forthenovice,commandslineinterfacecommandscanappeardaunting:
sudo gobbledegook blah_blah -w -t -h --long-switch aWkward/ComBinationOf/mixedCase/underscores_strokes/and.dots

However,itisimportanttonotethatevenexperiencedusersoftencutandpastecommands(froma guideormanual)intothecommandlineterminal;theydonotmemorizethem. Itisimportant,ofcourse,toknowhowtousethecommandlineterminalandanyonewhocan managetyping,backspacing,andcuttingandpastingcanmanagethecommandlineterminal(itisnot moredifficultthanthat). Thispagewilloutlineafewcraftyshortcutswhichcanmakeusingacommandlineinterfaceeasier.

StartingaTerminal
InUnity
UnityisthedefaultDesktopEnvironmentusedin11.04.WheresystemsarenotreadyforUnitythey reverttoGnomewhichisalsousedinpreviousreleasessuchasUbuntu10.04LTS(Lucid),seenext subsection. TheeasiestwaytoopentheTerminalistousethe'search'functiononthedash.Oryoucanclickonthe 'MoreApps'button,clickonthe'Seemoreresults'bytheinstalledsection,andfinditinthatlistof applications.Athirdway,availableafteryouclickonthe'MoreApps'button,istogotothesearchbar, andseethatthefarrightendofitsays'AllApplications'.Youthenclickonthat,andyou'llseethefull list.ThenyoucangotoAccessories>Terminalafterthat.So,themethodsinUnityare: Dash>SearchforTerminal Dash>MoreApps>'SeeMoreResults'>Terminal

Dash>MoreApps>Accessories>Terminal KeyboardShortcut:Ctrl+Alt+T

InGnome
GnomeistheClassicDesktopEnvironmentforUbuntu11.04(Natty)andisthedefaultDEinearlier releases,suchasUbuntu10.04LTS(Lucid). Applicationsmenu>Accessories>Terminal. KeyboardShortcut:Ctrl+Alt+T

InXfce(Xubuntu)
Applicationsmenu>System>Terminal.

InKDE(Kubuntu)
KMenu>System>TerminalProgram(Konsole).

InLXDE(Lubuntu)
Menu>Accessories>LXTerminal.

Commands
sudo:ExecutingCommandswithElevatedPrivileges
Mostofthefollowingcommandswillneedtobeprefacedwiththesudocommand.This elevatesprivilegestotherootuseradministrativeleveltemporarily,whichisnecessarywhen workingwithdirectoriesorfilesnotownedbyyouruseraccount.Whenusingsudoyouwillbe promptedforyourpassword.Onlyuserswithsudo(administrative)privilegeswillbeabletouse thiscommand.YoushouldneverusenormalsudotostartgraphicalapplicationsasRoot(Please seeRootSudoformoreinformationonusingsudocorrectly.)

File&DirectoryCommands
Thetilde(~)symbolstandsforyourhomedirectory.Ifyouareuser,thenthetilde(~)standsfor /home/user

pwd:Thepwdcommandwillallowyoutoknowinwhichdirectoryyou'relocated(pwdstands for"printworkingdirectory").Example:"pwd"intheDesktopdirectorywillshow "~/Desktop".NotethattheGnomeTerminalalsodisplaysthisinformationinthetitlebarofits window.Ausefulgnemonicis"presentworkingdirectory." ls:Thelscommandwillshowyou('list')thefilesinyourcurrentdirectory.Usedwithcertain options,youcanseesizesoffiles,whenfilesweremade,andpermissionsoffiles.Example:"ls ~"willshowyouthefilesthatareinyourhomedirectory. cd:Thecdcommandwillallowyoutochangedirectories.Whenyouopenaterminalyouwill beinyourhomedirectory.Tomovearoundthefilesystemyouwillusecd.Examples: Tonavigateintotherootdirectory,use"cd/" Tonavigatetoyourhomedirectory,use"cd"or"cd~" Tonavigateuponedirectorylevel,use"cd.." Tonavigatetothepreviousdirectory(orback),use"cd" Tonavigatethroughmultiplelevelsofdirectoryatonce,specifythefulldirectorypath thatyouwanttogoto.Forexample,use,"cd/var/www"togodirectlytothe/www subdirectoryof/var/.Asanotherexample,"cd~/Desktop"willmoveyoutothe Desktopsubdirectoryinsideyourhomedirectory. cp:Thecpcommandwillmakeacopyofafileforyou.Example:"cpfilefoo"willmakean exactcopyof"file"andnameit"foo",butthefile"file"willstillbethere.Ifyouarecopyinga directory,youmustuse"cprdirectoryfoo"(copyrecursively).(Tounderstandwhat "recursively"means,thinkofitthisway:tocopythedirectoryandallitsfilesandsubdirectories andalltheirfilesandsubdirectoriesofthesubdirectoriesandalltheirfiles,andonandon, "recursively") mv:Themvcommandwillmoveafiletoadifferentlocationorwillrenameafile.Examples areasfollows:"mvfilefoo"willrenamethefile"file"to"foo"."mvfoo~/Desktop"will movethefile"foo"toyourDesktopdirectorybutwillnotrenameit.Youmustspecifyanewfile nametorenameafile. Tosaveontyping,youcansubstitute'~'inplaceofthehomedirectory. Notethatifyouareusingmvwithsudoyoucanusethe~shortcut,becausetheterminal expandsthe~toyourhomedirectory.However,whenyouopenarootshellwithsudoi orsudos,~willrefertotherootaccount'shomedirectory,notyourown. rm:Usethiscommandtoremoveordeleteafileinyourdirectory. rmdir:Thermdircommandwilldeleteanemptydirectory.Todeleteadirectoryandallofits contentsrecursively,usermrinstead.

mkdir:Themkdircommandwillallowyoutocreatedirectories.Example:"mkdirmusic" willcreateadirectorycalled"music". man:Themancommandisusedtoshowyouthemanualofothercommands.Try"manman" togetthemanpageformanitself.Seethe"Man&GettingHelp"sectiondownthepagefor moreinformation.

RunningaFileWithinaDirectory
Soyou'vedecidedtorunafileusingthecommandline?Well...there'sacommandforthattoo! ./filename.extension Afternavigatingtothefile'sparentdirectory,thiscommandwillenableanyUbuntuusertoparsefiles compiledviagccoranyotherprogramminglanguage.Keepinmindthatthe'extension'willvary dependinguponthelanguagethesourcecodeiswrittenin.Forexample:".c"forCsource,".cpp" forC++,".rb"forRuby,".py"forpython,etc.Also,rememberthat(inthecaseofinterpretedlanguages likeRuby&Python)youmusthaveaversionofthatlanguageinstalledonUbuntubeforetryingto runfileswrittenwithit.

SystemInformationCommands
df:Thedfcommanddisplaysfilesystemdiskspaceusageforallmountedpartitions."dfh"is probablythemostusefulitusesmegabytes(M)andgigabytes(G)insteadofblockstoreport. (hmeans"humanreadable") du:Theducommanddisplaysthediskusageforadirectory.Itcaneitherdisplaythespaceused forallsubdirectoriesorthetotalforthedirectoryyouruniton.Example:
user@users-desktop:~$ du /media/floppy 1032 /media/floppy/files 1036 /media/floppy/ user@users-desktop:~$ du -sh /media/floppy 1.1M /media/floppy/

smeans"Summary"andhmeans"HumanReadable" free:Thefreecommanddisplaystheamountoffreeandusedmemoryinthesystem."freem" willgivetheinformationusingmegabytes,whichisprobablymostusefulforcurrentcomputers. top:ThetopcommanddisplaysinformationonyourLinuxsystem,runningprocessesand systemresources,includingCPU,RAM&swapusageandtotalnumberoftasksbeingrun.To exittop,press"q". unamea:Theunamecommandwiththeaoptionprintsallsysteminformation,including machinename,kernelname&version,andafewotherdetails.Mostusefulforcheckingwhich

kernelyou'reusing. lsb_releasea:Thelsb_releasecommandwiththeaoptionprintsversioninformationforthe Linuxreleaseyou'rerunning,forexample:


user@computer:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 11.10 Release: 11.10 Codename: oneiric

ipaddrreportsonyoursystem'snetworkinterfaces.

AddingANewUser
"addusernewuser"commandwillcreateanewgeneralusercalled"newuser"onyoursystem, andtoassignapasswordforthenewuseraccountuse"passwdnewuser".

Options
Thedefaultbehaviourforacommandmayusuallybemodifiedbyaddingaoptiontothecommand. Thelscommandforexamplehasansoptionsothat"lss"willincludefilesizesinthelisting.There isalsoahoptiontogetthosesizesina"humanreadable"format. Optionscanbegroupedinclustersso"lssh"isexactlythesamecommandas"lssh".Mostoptions havealongversion,prefixedwithtwodashesinsteadofone,soeven"lssizehumanreadable"is thesamecommand.

"Man"andgettinghelp
mancommand,infocommandandcommandhelparethemostimportanttoolsatthecommand line. NearlyeverycommandandapplicationinLinuxwillhaveaman(manual)file,sofindingthemisas simpleastyping"man"command""tobringupalongermanualentryforthespecifiedcommand. Forexample,"manmv"willbringupthemv(Move)manual. Moveupanddownthemanfilewiththearrowkeys,andquitbacktothecommandpromptwith"q". "manman"willbringupthemanualentryforthemancommand,whichisagoodplacetostart! "manintro"isespeciallyusefulitdisplaysthe"Introductiontousercommands"whichisawell written,fairlybriefintroductiontotheLinuxcommandline.

Therearealsoinfopages,whicharegenerallymoreindepththanmanpages.Try"infoinfo"forthe introductiontoinfopages. Somesoftwaredeveloperspreferinfotoman(forinstance,GNUdevelopers),soifyoufindavery widelyusedcommandorappthatdoesn'thaveamanpage,it'sworthcheckingforaninfopage. Virtuallyallcommandsunderstandtheh(orhelp)optionwhichwillproduceashortusage descriptionofthecommandandit'soptions,thenexitbacktothecommandprompt.Try"manh"or "manhelp"toseethisinaction. Caveat:It'spossible(butrare)thataprogramdoesn'tunderstandthehoptiontomeanhelp.Forthis reason,checkforamanorinfopagefirst,andtrythelongoptionhelpbeforeh.

Searchingformanfiles
Ifyouaren'tsurewhichcommandorapplicationyouneedtouse,youcantrysearchingthemanfiles. mankfoowillsearchthemanfilesforfoo.Try"manknautilus"toseehowthisworks. Notethatthisisthesameasdoingaproposcommand. manffoosearchesonlythetitlesofyoursystem'smanfiles.Try"manfgnome",for example. Notethatthisisthesameasdoingwhatiscommand.

OtherUsefulThings
PrettierManualPages
UserswhohaveKonquerorinstalledwillbepleasedtofindtheycanreadandsearchmanpagesina webbrowsercontext,prettifiedwiththeirchosendesktopfontsandalittlecolour,byvisiting man:/commandinKonqueror'saddressbar.Somepeoplemightfindthislightenstheloadifthere'slots ofdocumentationtoread/search.

Pastingincommands
Often,youwillbereferredtoinstructionsthatrequirecommandstobepastedintotheterminal.You mightbewonderingwhythetextyou'vecopiedfromawebpageusingctrl+Cwon'tpasteinwith ctrl+V.Surelyyoudon'thavetotypeinallthosenastycommandsandfilenames?Relax.ctrl+shift+V pastesintoaGnometerminal;youcanalsodoMiddleButtonClickonyourmouse(bothbuttons simultaneouslyonatwobuttonmouse)orRightClickandselectPastefromthemenu.However,ifyou

wanttoavoidthemouseandyetpasteit,use"Shift+Insert",topastethecommand.Ifyouhavetocopy itfromanotherterminal/webpage,youcanuse"Ctrl+Insert"tocopy.

Saveontyping
UpArrow Scrollsthroughthecommandsyou'veenteredpreviously. orctrl+p Down Arrowor ctrl+n Enter tab

Takesyoubacktoamorerecentcommand.

Whenyouhavethecommandyouwant. Averyusefulfeature.Itautocompletesanycommandsorfilenames,ifthere'sonlyone option,orelsegivesyoualistofoptions. Searchesforcommandsyou'vealreadytyped.Whenyouhaveenteredaverylong, complexcommandandneedtorepeatit,usingthiskeycombinationandthentypinga portionofthecommandwillsearchthroughyourcommandhistory.Whenyoufindit, simplypressEnter. Thehistorycommandshowsaverylonglistofcommandsthatyouhavetyped.Each commandisdisplayednexttoanumber.Youcantype!xtoexecuteapreviouslytyped commandfromthelist(replacetheXwithanumber).Ifyouhistoryoutputistoolong, thenusehistory|lessforascrollablelist.

ctrl+r

History

Changethetext
Themousewon'twork.UsetheLeft/Rightarrowkeystomovearoundtheline. Whenthecursoriswhereyouwantitintheline,typinginsertstextieitdoesn'tovertypewhat's alreadythere. ctrl+aorHome Movesthecursortothestartofaline. ctrl+eorEnd esc+b Movesthecursortotheendofaline. Movestothebeginningofthepreviousorcurrentword.

ctrl+k ctrl+u ctrl+w

Deletesfromthecurrentcursorpositiontotheendoftheline. Deletesfromthestartofthelinetothecurrentcursorposition. Deletesthewordbeforethecursor.

Morewaystorunaterminal
Youcanalsogetitwithafunctionkey Youcanrunmorethanoneintabsorseparatewindows Youcanalsoinstallguake(Gnome),tilda(XFCE/LXDE)oryakuake(KDE)andhaveaterminal whichappearsandhidesonshortcutkey.Thiscanbeparticularlyusefulifyouuseterminalalot

MoreInformation
AptGetHowto usingaptgettoinstallpackagesfromthecommandline. CommandlineRepositoryEditing addingtheUniverse/Multiverserepositoriesthroughthe commandline. grepHowto grepisapowerfulcommandlinesearchtool. findHowto locatefilesonthecommandline. CommandlineHowto longerandmorecompletethanthisbasicguide,butstillunfinished. HowToReadline informationonsomemoreadvancedcustomizationforthecommandline. FormoredetailedtutorialsontheLinuxcommandline,pleasesee: http://mywiki.wooledge.org/BashGuide Bashguidesuitableforbeginners.Oneofthefewto alsoteachgoodpractice. http://linuxcommand.org/ basicBASHtutorials,includingBASHscripting http://linuxsurvival.com/index.php Javabasedtutorials http://rute.2038bug.com/index.html.gz amassiveonlinebookaboutsystemadministration, almostallfromthecommandline. http://www.ss64.com/bash/ agoodlistacommands. http://tinyurl.com/ycyg4mk Listingof3helpfulsitesfrombeginnertoadvancedscripting

Ubuntuguide conciseanduptodateinformationforbothcommandlineandGUIusersof Ubuntu Kubuntuguide conciseanduptodateinformationforbothcommandlineandGUIusersof Kubuntu

You might also like