Sei sulla pagina 1di 2

Congratulations!

You'velearnedfivecommandscommonlyusedtonavigatethefilesystem
fromthecommandline.Whatcanwegeneralizesofar?

Thecommandlineisatextinterfaceforthecomputer'soperatingsystem.Toaccessthe
commandline,weusetheterminal.

Afilesystemorganizesacomputer'sfilesanddirectoriesintoatreestructure.Itstartswith
therootdirectory.Eachparentdirectorycancontainmorechilddirectoriesandfiles.
Fromthecommandline,youcannavigatethroughfilesandfoldersonyourcomputer:

pwdoutputsthenameofthecurrentworkingdirectory.
lslistsallfilesanddirectoriesintheworkingdirectory.
cdswitchesyouintothedirectoryyouspecify.
mkdircreatesanewdirectoryintheworkingdirectory.
touchcreatesanewfileinsidetheworkingdirectory
Congratulations!Youlearnedhowtousethecommandlinetoviewandmanipulatethe
filesystem.Whatcanwegeneralizesofar?
Optionsmodifythebehaviorofcommands:

lsalistsallcontentsofadirectory,includinghiddenfilesanddirectories
lsllistsallcontentsinlongformat
lstordersfilesanddirectoriesbythetimetheywerelastmodified
Multipleoptionscanbeusedtogether,likelsalt
Fromthecommandline,youcanalsocopy,move,andremovefilesanddirectories:

cpcopiesfiles
mvmovesandrenamesfiles
rmremovesfiles
rmrremovesdirectories
Wildcardsareusefulforselectinggroupsoffilesanddirectories
Congratulations!Youlearnedhowtousethecommandlinetoredirectstandardinputand
standardoutput.Whatcanwegeneralizesofar?

Redirectionreroutesstandardinput,standardoutput,andstandarderror.
Thecommonredirectioncommandsare:

>redirectsstandardoutputofacommandtoafile,overwritingpreviouscontent.
>>redirectsstandardoutputofacommandtoafile,appendingnewcontenttooldcontent.

<redirectsstandardinputtoacommand.
|redirectsstandardoutputofacommandtoanothercommand.
Anumberofothercommandsarepowerfulwhencombinedwithredirectioncommands:

sort:sortslinesoftextalphabetically.
uniq:filtersduplicate,adjacentlinesoftext.
grep:searchesforatextpatternandoutputsit.
sed:searchesforatextpattern,modifiesit,andoutputsit.
Congratulations!Youlearnedtousethebashprofiletoconfiguretheenvironment.Whatcan
wegeneralizesofar?

Theenvironmentreferstothepreferencesandsettingsofthecurrentuser.
Thenanoeditorisacommandlinetexteditorusedtoconfiguretheenvironment.
~/.bash_profileiswhereenvironmentsettingsarestored.Youcaneditthisfilewithnano.
environmentvariablesarevariablesthatcanbeusedacrosscommandsandprogramsand
holdinformationabouttheenvironment.

exportVARIABLE="Value"setsandexportsanenvironmentvariable.
USERisthenameofthecurrentuser.
PS1isthecommandprompt.
HOMEisthehomedirectory.Itisusuallynotcustomized.
PATHreturnsacolonseparatedlistoffilepaths.Itiscustomizedinadvancedcases.
envreturnsalistofenvironmentvariables

Potrebbero piacerti anche