LinuxFilesystemStructurev1.x DanielQuinlan<quinlan@bucknell.edu> FilesystemStandardGroup ABSTRACT TheopenanddistributedprocessinwhichtheLinuxoperatingsystemhas developedfostersrapidgrowthoftheoperatingsystem,applications,andintegrated distributions.Thisdecentralizedprocess,however,hascreatedaneedfor standardizationoftheLinuxfilesystemstructure.Thisdocumentaimstospecify standardlocationsoffilesanddirectoriesinLinuxsystems.Thiswillallowusers, developers,anddistributorstoobtainsystemcomponentsfromvarioussourcesthat willworktogetherassmoothlyasiftheyhadbeendevelopedunderamonolithic developmentprocess.Itwillalsoeasesystemadministration,developmentofsecond andthirdpartypackages,andthewritingofimplementationindependent documentation. May3,1994 LinuxFilesystemStructure May3,1994 UNIXisaregisteredtrademarkoftheX/OpenCompany,Ltd. SunOS,SunMicrosystems,SunNIS,SunRPC,andNFSareregisteredtrademarksofSun Microsystems,Inc. SystemVandSVR4aretrademarksofAT&T. NovellandNovellNetWarearetrademarksofNovell. HP-UXisatrademarkofHewlettPackard. Linuxisnotatrademark,andhasnoconnectiontoUNIX. Allothercopyrightsareownedbytheirowners,unlessspecificallynotedotherwise.Useofaterm inthisdocumentshouldnotberegardedasaffectingthevalidityofanytrademarkorservice mark. Copyright◯c1994DanielQuinlan<quinlan@bucknell.edu> Permissionisgrantedtocopyanddistributeverbatimcopiesofthisstandardprovidedthe copyrightandthispermissionnoticearepreservedonallcopies. PermissionisgrantedforFSSTNDcontributorsandparticipantstocopyanddistributemodified versionsofthisstandardundertheconditionsforverbatimcopyingforpurposesoffilesystem standardizationactivitiesonly,andsubjecttothoserestrictionslistedbelow. Thefollowingrestrictionsapplytoreproducingortransmittingthedocumentinanyform: •Allcopiesorportionsthereofmustidentifythedocument’stitleandsection,andmustbe accompaniedbythisentirenoticeinaprominentlocation. •Noportionofthisdocumentmayberedistributedinanymodifiedorabridgedformwithout thepriorapprovaloftheFSSTNDcoordinator. Anyentitiesseekingpermissiontodistributeanymaterialderivedfromthisdocument(otherthan verbatimcopies)mustcontacttheFSSTNDcoordinatorfortheappropriatelicense.

LinuxFilesystemStructure May3,1994 Preface StatusoftheStandard ThisproposedstandardiscurrentlybeingdistributedtomembersoftheLinuxcommunityin ordertosolicittheirreactionstotheseriesofideas,concepts,andrecommendationsincluded withinit.Whiletheentirecontentofthisstandardmaynotbeidenticaltowhateveryindividual desires,ithasproventobeagoodstarttowardssolvingmanyproblems. Theguidelinesinthisstandardaresubjecttochange.Useofinformationcontainedinthis documentisatyourownrisk. OrganizationoftheStandard Thisstandardisdividedinto6parts: —General,includingastatementofscope,problems,objectives,andconformance requirements.(Section1) —TheFilesystem:astatementofsomeguidingprinciples.(Section2) —TheRootDirectory.(Section3) —The/usrHierarchy.(Section4) —The/varHierarchy.(Section5) —IssuesandAdditionalRationale.(Section6) TypographicalConventions Courierfontisusedforthenamesoffilesanddirectories. Componentsoffilenamesthatvaryarerepresentedbyadescriptionofthecontentsenclosedin "<"and">"characters,<thus>.Emailaddressesarealsoenclosedin"<"and">"butare shownintheusualtypeface. Optionalcomponentsoffilenamesareenclosedin"["and"]"charactersandmaybecombined withthe"<"and">"convention.Forexample,ifafileexistedwhichcouldbeeitherbefound eitherwithorwithoutanextension,itmightberepresentedby<filename>[.<extension>]. Variablesubstringsofdirectorynamesandfilenamesareindicatedby"*". -1-LinuxFilesystemStructure May3,1994 1.General 1.1Scope ThisdocumentspecifiesastandardfilesystemstructureforLinuxsystems,includingthelocation offilesanddirectories,andthecontentsofsomesystemfiles. ThefilesystemstandardhasbeendesignedtobeusedbyLinuxdistributiondevelopers,package developers,andsystemimplementors.However,itisprimarilyintendedtobeareferenceandis notatutorialonhowtomanageaLinuxfilesystemordirectoryhierarchy. Thesearesomeofthefundamentalproblemsthatoriginallymotivatedthisstandardizationeffort: •TherewasnosinglewellacceptedLinuxdirectorystructure.Instead,thereweremany differentones,eachincompatiblewithoneanother. •Themostwidelyusedfilesystemhierarchieswerenotwellstructuredanddiffered gratuitouslyfrommoremoderndirectorystructure"standards"(suchasSystemV,BSD, SunOS,andothers). •ThefilesystemwasunfamiliaranddiscomfortingtoexperiencedUNIXusersand administratorswhohaveexperienceonmoremainstreamUNIXsystems. •ThelackofregularitywasalsoconfusingfornewcomerstoLinux,especiallythosecoming fromanon-UNIXbackground. •AnyincompatibilitiesbetweenprimaryLinuxdistributionsandothersoftwarepackageswere typicallysolvedbymethodsofalessthanappealingnature. •Overall,symboliclinkswereusedmuchtoooftenwithinthefilesystemtofixproblems. (However,therearetimeswhensymboliclinksneedtobeusedtoensurebackward compatibilityortoallowspecificsystemstohaveanindividualfilesystemstructure.) Itistobeexpectedthatdifferencesinopinionaretoariseinanystandardizationeffortsuchas thisone.However,thesedifferencesshouldbeovershadowedbytheneedforconsensusand commonpracticewithintheLinuxcommunity. ThisfilesystemstandardwasprimarilydevelopedwithintheFSSTNDmailinglistandpreviously, theFSSTNDchanneloftheLinux-activistsmailinglist.Inputandcommentswerereceivedfroma greatnumberofLinuxdevelopers,notedLinuxprogrammers,systemadministrators,andusers. Thosevolunteerswhohavecontributedextensivelytothisstandardarelistedattheendofthis document.Thisstandardrepresentstheconsensusviewofthoseandothercontributors. Thisstandardseekstoaddresstheseproblemsbydescribingawelldesignedfilesystemstructure thatwehopetheLinuxcommunitywillvoluntarilyfollow.Althoughthisstandardismore comprehensiveandcompletethananyotherpreviousattemptatstandardization,itwillprobably neverbetrulyfinished.TheneedsoftheLinuxcommunitywillcontinuallychangeinrelationto emergingtechnology.Itisalsopossiblethatbettersolutionstotheproblemsweaddresswillbe discoveredorthatoursolutionswillnolongerbethebestpossiblesolutions.Forthesereasons, theFSSTNDgroupplanstoreleasesupplementarydraftsinadditiontoperiodicupdatestothis document. AnycommentsrelatedtothisstandardwouldbewelcomedbytheFSSTNDgroup.Such commentsorsuggestionsforchangesshouldbedirectedtotheFSSTNDcoordinator,orifyou prefer,anyofthelistedcontributors.Typographicalorgrammaticalcommentsshouldbedirected -2-LinuxFilesystemStructure May3,1994 totheFSSTNDcoordinator. ThereisalsoaFAQ,maintainedbyIanMcCloghrie,whichanswerssomeofthemorecommonly askedquestionsaboutthisstandard.IfyouwanttoimplementtheFSSTNDorifyouhavesome questions,pleasereadtheFSSTNDFAQfirst. PleasedonotsendmailtothemailinglistwithoutfirstcontactingtheFSSTNDcoordinatorora listedcontributor.Impropermessageswillnotbewellreceivedonthemailinglist. Questionsabouthowtointerpretitemsinthisdocumentmayoccasionallyarise.Ifyouhaveneed foraclarification,pleasecontacttheFSSTNDcoordinator.Sincethisstandardrepresentsthe consensusofmanyparticipants,itisimportanttomakecertainthatanyinterpretationalso representstheircollectiveopinion.Forthisreasonitmaynotbepossibletoprovideanimmediate responseunlesstheinquiryhasbeenthesubjectofpreviousdiscussion. TheFSSTNDcoordinatorisDanielQuinlan<quinlan@bucknell.edu>. 1.2SpecificProblems Naturally,whilestandardizingtheLinuxfilesystemstructure,thereweresomespecificproblems thatwesoughttocorrect.Herearesomeofthemostobviousandmajorones: •Theprimarybinarydirectories,/binand/usr/bin,donothavewelldefineddivisions betweenthem.Asaresult,thedistributionofthebinariesbetweenthesetwodirectories variesgreatlybetweentheLinuxdistributions. •Includingbothbinariesandconfigurationfilesin/etcmakesthisdirectorymoreconfusing andmoredifficulttomaintain,bothforinexperiencedusersandforsystemadministrators (especiallythosewithlargesystems). •Thedivisionbetweenwhatisasite-wideconfigurationfileandwhatisamachine-local configurationfileisdifficulttoestablish. •Manycommonimplementationsof/usrcannotbemountedread-onlybecausetheycontain variablefilesanddirectoriesthatneedtobewrittento. •InanetworkedenvironmentitisdesirabletoservesoftwaretoworkstationsviaaNFS mountedfilesystem.Suchfilesystemsneedtobemountedread-onlysothataccidentsor maliceononeworkstationcannotdamagethefilesontheserver.Thisrequiresidentification andseparationoffilesthatamachinemustwritetoandoffilesthatarespecifictoasingle machine. •CommonimplementationsoftheLinuxfilesystemaregenerallynotwellsuitedtonetworked installationswhichmayrequirearead-only/usrpartitionorinvolvedisklessworkstations. Whilethesearesomeofthemajorproblemsweaddressed,therewerenumerousadditional problemsthatneededtobesolved.Thisstandardattemptstoaddressmanyofthoseother problems,buttheremaybesomethingthatwasoverlooked.Ifyouwishtobringsomethingto ourattention,pleasenotetherearesomethingsthathavebeendiscussedatlength,butwerenot includedinthisstandard. -3-LinuxFilesystemStructure May3,1994 1.3Objectives Intryingtosolvetheproblemsabove,severalobjectiveswereidentifiedthatneededtobe achievedinadditiontothemoretechnicalmatters.Thesegoalscomprisethecorrectionof outstandingproblemsaswellasthevalidationofthisstandard. •Solvetheproblemslistedabovewhilelimitingtransitionaldifficultieswhilemovingaway fromtheformerde-factostandards. •Gainapprovalofdistributors,developers,andotherimportantpeopleintheLinux community,aswellasencouragingthemtogiveustheirsuggestions. •ProvideastandardthatthewholeLinuxcommunitywillchoosetofollowbecauseitsolves theproblemsaboveandprovidesthemostsensiblestructureforthefilesystemsofLinux installations. Someoftheseobjectiveshavealreadybeenfullyorpartiallymetduetothelimiteddistributionof anadvancedrafttoanydeveloperwhorequestedone. 1.4HistoryandProgress TheoriginalmessagethatmotivatedthisefforttorestructuretheLinuxfilesystemwaswrittenby OlafKirsh<okir@monad.swb.de>onAugust2,1993,totheNORMALchanneloftheLinux activistsmailinglist. Soonthereafter,itwasdecidedthatthebestpossiblewaytoaccomplishthenecessary restructuringoftheLinuxfilesystemwouldbetocreateamailinglistforthepurposeof developingaconsensusstandard. Afteracomprehensivediscussion,withsurprisinglyfewflames,apreliminarydraftwaswritten. Withthehelpofseveraldedicatedpeople,thedraftwasfinishedandtheresultingdraftsubmitted totheFSSTNDchannelformorediscussion.Thefirstdraftwassubmittedtothechannelon September18,1993,byDanielQuinlan. AsthediscussioncontinuedandearlydraftsofFSSTNDrecommendationsweredevelopedfurther, contactswereestablishedwithaccessibleLinuxdistributorswhothenofferedtheirinputand supporttooureffort.ManyLinuxdevelopersalreadyagreethatwhatwearedoingisagood thing. ThesearesomeofthedeveloperswhoaimtofollowtheFSSTNDstandard[alphabeticalorder]: •DebianLinux IanA.Murdock<imurdock@gnu.ai.mit.edu> •LILO WernerAlmesberger<almesber@nessie.cs.id.ethz.ch> •Linux/PRO FredN.vanKempen<waltje@uwalt.nl.mugnet.org> •MCCInterimLinux OwenLeBlanc<LeBlanc@mcc.ac.uk> •SlackwareLinux PatrickJ.Volkerding<volkerdi@mhd1.moorhead.msus.edu> -4-LinuxFilesystemStructure May3,1994 •TAMULinux DaveSafford<dave.safford@net.tamu.edu> •util-linuxpackages RikFaith<faith@cs.unc.edu> 1.5ConformancewiththisDocument Thissectiondefinesthemeaningsoftheterms"compliant"and"compatible"withrespecttothis standard,andof"partial"complianceandconformance. An"implementation"herereferstoadistribution,aninstalledsystem,aprogram,apackage(or somesimilarpieceofsoftwareordata),orsomecomponentthereof. Animplementationisfullycompliantwiththisstandardifeveryrequirementinthisstandardis met.Everyfileordirectorywhichispartoftheimplementationmustbelocatedasspecifiedin thisdocument.Ifthecontentsofafilearedescribedheretheactualcontentsmustcorrespondto thedescription.Theimplementationmustalsoattempttofindanyfilesordirectories(externalto itself)primarilyorexclusivelyinthelocationspecifiedinthisstandard. Animplementationisfullycompatiblewiththisstandardifeveryfileordirectorywhichit containscanbefoundbylookinginthelocationspecifiedhereandwillbefoundwiththecontents asspecifiedhere,evenifthatisnottheprimaryorphysicallocationofthefileordirectoryin question.Theimplementationmust,whenitattemptstofindanyfilesordirectorieswhichare notpartofit,dosointhelocationspecifiedinthisstandard,thoughitmayalsoattempttofind itinother(non-standard)locations. Animplementationispartiallycompliantorcompatibleifitcomplieswithoriscompatiblewitha significantsubsetofthisdocument.Partialcomplianceorcompatibilityisonlyintendedtoapply todistributionsandnottoseparateprograms.Thephrase"asignificantsubset"isadmittedly subjective,andinborderlinecases,theconcernedpartyshouldcontacttheFSSTNDcoordinator. Itisanticipatedthatsomevariationwillbetoleratedinborderlinecases. InordertoqualifyaspartiallyFSSTNDcompliantorpartiallyFSSTNDcompatiblean implementationmustprovidealistofallplacesatwhichitandtheFSSTNDdocumentdifferin additiontoabriefexplanationofthereasoningforthisdifference.Thislistshallbeprovidedwith theimplementationinquestion,andalsomadeavailabletotheFSSTNDmailinglistorthe FSSTNDcoordinator. Theterms"must","should","contains","is"andsoforthshouldbereadasrequirementsfor complianceorcompatibility. Certainportionsofthisdocumentareoptional—inthiscasethiswillbestatedexplicitly,or indicatedwiththeuseofoneormoreof"may","recommend",or"suggest". Notethatanimplementationneednotcontainoptionalfilesanddirectoriestobecompliantor compatible.Animplementationwhichisastandalonepackageoradistributionthatexcludes non-essentialsystemcomponents(suchasgames,theXWindowsystem,andTEX)mayleaveout thosenon-essentialcomponentsandstillbecompliantorcompatible.Itismerelynecessaryfor thosefilesthatitdoescontaintobelocatedappropriately. -5-LinuxFilesystemStructure May3,1994 2.TheFilesystem TheUNIXfilesystemischaracterizedby: •Ahierarchicalstructure •Consistenttreatmentoffiledata •Protectionoffiledata ThisstandardontheLinuxfilesystemfollowsthesamebasicprinciplesthatmostUNIX filesystemsfollow.Notethatthisstandarddoesnotattempttoagreeineverypossiblerespect withanyparticularUNIXsystem’simplementation.However,manyaspectsofthisstandardare basedonideasfoundinUNIXandotherUNIX-likesystems. Thisisaftercarefulconsiderationofotherfactors,including: •Common(good)practicesintheLinuxcommunity •Theexistenceofotherfilesystemstructures •Applicablestandards Itispossibletodefinetwoorthogonalcategorizationsoffiles:shareablevs.unshareableand variablevs.static. Shareabledataisthatwhichcanbesharedbetweenseveraldifferentmachines;unshareableisthat whichmustbelocaltoaparticularmachine. Staticdataincludesbinaries,libraries,documentation,andanythingthatdoesnotchangewithout systemadministratorintervention;variabledataisanythingthatdoeschangewithoutsystem administratorintervention. Throughoutthisdocument,andinanywellplannedfilesystem,anunderstandingofthesebasic principleswillhelpguidethestructureandlenditadditionalconsistency. Thedistinctionbetweenshareableandunshareabledataisneededforseveralreasons: •Inanetworkedenvironment(i.e.morethanonehostatasite),thereisagooddealofdata thatcanbesharedbetweendifferentmachinestosavespaceandeasethetaskof maintenance. •Inanetworkedenvironment,certainfilesystemscontaininformationspecifictoasingle machine.Thereforethesefilesystemscannotbeshared(withouttakingspecialmeasures). •Thede-factoimplementationof/usrcannotbemountedread-onlybecauseitcontainsfiles anddirectoriesthatneedtobewrittento.Thisisafactorthatmustbeaddressedwhen /usrissharedonanetworkormountedread-onlybecauseofotherconsiderationssuchas safety. The"shareable"distinctioncanbeusedtosupport,forexample: •A/usrmounted(read-only)throughthenetwork(usingNFS). •A/usrmountedfromread-onlymedia.(YoucanthinkofthatCD-ROMdriveasa filesystemthatyouaresharingwithotherLinuxsystems,usingpostalmailasanetwork.) The"static"versus"variable"distinctionaffectsthefilesystemin2majorways: -6-LinuxFilesystemStructure May3,1994 •Since/containsbothvariableandstaticdata,itneedstobemountedread-write. •Sincethetraditional/usrcontainsbothvariableandstaticdata,andsincewemaywantto mountitread-only(seeabove),itisnecessarytoprovideamethodtohave/usrmounted read-only.Thisisdonethroughthecreationofa/varhierarchythatismountedread-write (orisapartofanotherread-writepartition,suchas/),takingovermuchofthe/usr partition’straditionalfunctionality.

LinuxFilesystemStructure May3,1994 3.TheRootDirectory Thissectiondescribestherootdirectorystructure.Thecontentsoftherootpartitionshouldbe adequatetoboot,restore,recover,and/orrepairthesystem: (1)Tobootasystem,enoughmustbepresenttomount/usr.Thisincludesutilities, configuration,bootloaderinformation,andotheressentialstart-updata. (2)Toenablerecoveryand/orrepairofasystem,thoseutilitiesneededbyanexperienced usertodiagnoseandreconstructadamagedsystemshouldbepresentontheroot filesystem. (3)Torestoreasystem,thoseutilitiesneededtorestorefromsystembackups(onfloppy, tape,etc.)shouldbepresentontherootfilesystem. Theprimaryconcernusedtobalancetheseconsiderations,whichfavorplacingmanythingsonthe rootfilesystem,isthegoalofkeepingrootassmallasreasonablypossible.Forseveralreasonsit isdesirabletokeeptherootfilesystemsmall: (1)Itisoftenmountedfromverysmallmedia.Forexample,manyLinuxusersinstalland dorecoverybymountingrootoffaRAMdiskwhichiscopiedfromasingle1.44Mor 1.2Mfloppydisk. (2)Therootpartitionhasmanysystem-specificconfigurationfilesinit.Possibleexamples includeakernelthatisspecifictothesystem,adifferenthostname,etc.Thismeans thattherootpartitionisn’talwaysshareablebetweennetworkedsystems.Keepingit smallonnetworkedsystemsminimizestheamountofspacelostonserverstounshareable files.Italsoallowsworkstationswithsmallerlocalharddrives. (3)Whileyoumayhavealargerootpartition,andmaybeabletofillittoyourheart’s content,therewillbepeoplewithsmallerpartitions.Ifyouhavemorefilesinstalled,you mayfindincompatibilitieswithothersystemsusinglimitedrootpartitions.Ifyouarea developerthenyoumaybeturningyourassumptionintoaproblemforalargenumberof users. (4)Diskerrorsontherootpartitionareagreaterproblemthanerrorsonanyother partition.Asmallrootfilesystemislesspronetocorruptionastheresultofasystem crash. Thisdocumentascurrentlydraftedrequiresawritablerootfilesystem.However,thisdoesnot necessitateafullylocallystoredroot.Therootpartitiondoesn’thavetobelocallystoredjustto besystemspecific—forexample,itmightbemountedfromanNFSserver. Softwareshouldnevercreateorrequirespecialfilesorsubdirectoriesintherootdirectory.This structureprovidesmorethanenoughflexibilityforanypackage.Anypackagethatdoesoccupya directoryundertherootofthefilesystemsuffersfromsheerarrogance. -8-LinuxFilesystemStructure May3,1994 /:therootdirectory

|

|-binEssentialcommandbinaries |-bootStaticfilesofthebootloader |-devDevicefiles |-etcMachine-localsystemconfiguration |-homeUserhomedirectories

|-libSharedlibraries(libc.so.*,libm.so.*,andld.so)

|-mntMountpointoftemporarypartitions |-procProcessinformationpseudo-filesystem |-rootHomedirectoryforroot |-sbinEssentialsystembinaries |-tmpTemporaryfiles |-usrSecondmajorhierarchy |-varMachine-localvariabledata +-<kernel>Linuxkernelimage Eachdirectorylistedwillbediscussedindetailinaseparatesubsectionbelow./usrand/var eachhavetheirownmajorsectionsofthisdocument. TheLinuxkernelimageshouldbelocatedineither/or/boot.Ifitislocatedin/,we recommendusingthenamevmlinuzwhichhasbeenusedinrecentLinuxkernelsources. Additionalinformationonkernelplacementcanbefoundinthesectionregarding/boot,below. 3.1/bin:Essentialcommandbinaries(forusebyallusers) /bincontainscommandswhichmaybeusedbyboththesystemadministratorandbyusers,but whicharerequiredinsingleusermode.Itmayalsocontaincommandswhichareusedindirectly byscripts. Allroot-onlybinariessuchasdaemons,init,getty,update,etc.shouldbeplacedin/sbinor /usr/sbin,dependingonwhethertheyareessential.Forfurtherdiscussionofthedefinitionof whatisessentialontherootfilesystem,pleasereadsection6,"IssuesandAdditionalRationale". Thereshouldbenosubdirectorieswithin/bin. Commandbinariesthatarenotessentialenoughtoplaceinto/binshouldbeplacedin/usr/bin, instead.Itemsthatareonlyusedbynon-rootusers(mail,chsh,etc.)arenotvitaltosystem operationandshouldnotbeplacedintherootpartition. Requiredfilesfor/bin: •Generalcommands: Thefollowingcommandshavebeenincludedbecausetheyareessential.Afewarepresent becauseoftheirtraditionalplacementin/bin.

{arch,cat,chgrp,chmod,chown,cp,date,dd,df,dmesg,echo,ed,false,
kill,ln,login,ls,mkdir,mknod,more,mount,mv,ps,pwd,rm,rmdir,
sed,setserial,sh,stty,su,sync,true,umount,uname}

If/bin/shisBash,then/bin/shshouldbeasymbolicorhardlinkto/bin/bashsince -9-LinuxFilesystemStructure May3,1994 Bashbehavesdifferentlywhencalledasshorbash.pdksh,whichisoftenthe/bin/shon installdisks,shouldlikewisebearrangedwith/bin/shbeingasymlinkto/bin/ksh.The useofasymboliclinkinthesecasesallowsuserstoeasilyseethat/bin/shisnotatrue Bourneshell. Sincethede-factostandardlocationoftheC-shellis/bin/csh,ifandonlyifaC-shellor equivalent(suchastcsh)isavailableonthesystem,itshouldbeavailablebythename /bin/csh(whichmay,forexample,beasymboliclinkto/usr/bin/tcsh). The[andtestcommandsarebuiltintoBash,pdksh,zsh,andrecentKornshells— essentiallyeveryBourneshellreplacementthereisforLinux.Thesecommandsshouldbe placedinto/usr/bin.(TheymustbeincludedasseparatebinarieswithanyLinuxsystem attemptingtocomplywiththePOSIX.2standard.) /bin/archshouldproducethesameoutputasuname-m,specificallyi386ori486forIntel andIntel-compatiblesystems. •Restorationcommands: Thesecommandshavebeenaddedtomakerestorationofasystempossible(providedthat/ isintact). {tar,gzip,gunzip(linktogzip),zcat(linktogzip)} Ifsystembackupsaremadeusingprogramsotherthangzipandtar,thentheroot partitionshouldcontaintheminimalnecessaryrestorationcomponents.Forinstance,many systemsshouldincludecpioasitisthenextmostcommonlyusedbackuputilityaftertar. Conversely,ifnorestorationfromtherootpartitioniseverexpected,thenthesebinaries maybeomitted(e.g.,aROMchiproot,mounting/usrthroughNFS).Ifrestorationofa systemisplannedthroughthenetwork,thenftportftp(alongwitheverythingnecessary togetaftpconnection)shouldbeavailableontherootpartition. Restorationcommandsmayappearineither/binor/usr/binondifferentLinuxsystems. •Networkingcommands: Thesearetheonlynecessarynetworkingbinariesthatbothrootanduserswillwantorneed toexecuteotherthantheonesin/usr/binor/usr/local/bin.

{domainname,hostname,netstat,ping}

3.2/boot:Staticfilesofthebootloader Thisdirectorycontainseverythingforbootexceptconfigurationfilesandthemapinstaller.In thesimplestsense,/bootisforanythingwhichisusedbeforethekernelexecs/sbin/init.This includessavedmasterbootsectors,sectormapfiles,andanythingelsethatisnotdirectlyedited byhand.Programsnecessarytoarrangeforthebootloadertobeabletobootafile(suchasthe lilomapinstaller)shouldbeplacedin/sbin.Configurationfilesforbootloadersshouldbe placedin/etc. -10-LinuxFilesystemStructure May3,1994 Morespecifically,forLILO: OldlocationNewlocation

/etc/lilo/config.defines/etc/lilo.defines
/etc/lilo/config/etc/lilo.conf
/etc/lilo/disktab/etc/disktab
/etc/lilo/lilo/sbin/lilo
/etc/lilo/boot.NNNN/boot/boot.NNNN
/etc/lilo/part.NNNN/boot/part.NNNN
/etc/lilo/map/boot/map
/etc/lilo/*.b/boot/*.b

*.barethefirstandsecondstagebootloader,plusthechainloaders.QuickInst(ifitis included)shouldbeplacedinto/usr/sbin.(Theactivatecommandisleftoutofthisscheme becauseitsfutureisuncertainatthistime.Ifasystemprovidesit,andthefunctionalityisnot availableinfdisk,itshouldbein/sbin.) Asalreadystatedabove,theLinuxkernelmayeitherbeplacedin/orin/boot.Itis recommendedthatamoreinformativefilenamebeusedifthekernelisplacedin/boot. 3.3/dev:Devicefiles Thisisthedevicedirectory.ItshouldcontainanentryforeverydevicethattheLinuxkernelis configuredtosupport. /devalsocontainsascriptnamedMAKEDEVwhichcancreatedevicesasneeded.Itmayalso containaMAKEDEV.localforanylocal-onlydevices. MAKEDEVshouldhaveprovisionsforcreatinganydevicespecialfilelistedintheLinux major/minornumberslist,notjustthosethataparticulardistributioninstalls. Symboliclinksin/devshouldnotbedistributedwithLinuxsystems,asthelocalsetupwilloften differfromthatonthedistributor’sdevelopmentmachine.Also,ifadistributioninstallscript configuresthesymlinksatinstalltime,thesesymlinkswilloftennotgetupdatediflocalchanges aremadeinhardware.Whenusedresponsiblyatalocallevel,however,theycanbeputtogood use. ThisstandardincorporatesbyreferencetheLinuxDeviceListwhichismaintainedbyRickMiller <rick@ee.uwm.edu>,theLinuxDeviceRegistrar.Alldevicespecialfilesshouldfollowthe standardinthatdocument,whichisavailablebyanonymousftpatsunsite.unc.eduas

/pub/Linux/docs/hardware/DEVICES.

3.4/etc:Machine-localsystemconfiguration Nobinariesshouldgodirectlyinto/etc.Binariesthatmightinthepasthavebeenfoundin/etc shouldbeplacedin/sbinor/usr/sbin.Thisincludessuchfilesasinit,getty,andupdate. Binariessuchashostnamethatareusedbyordinaryusersaswellastherootusershouldnotbe placedin/sbinbutin/bin. -11-LinuxFilesystemStructure May3,1994 /etc:Machine-localsystemconfiguration

|

|-X11ConfigurationfortheXWindowsystem +-skelUserskeletonconfiguration /etc/skelisthelocationforso-called"skeleton"userfilesthataregivenbydefaulttonewusers whenreceivinganaccount.Thisdirectorymaycontainsubdirectoriesfordifferentusergroups

(e.g.,/etc/skel/staffor/etc/skel/users).

/etc/X11istherecommendedlocationforallX11machine-localconfiguration.Thisdirectoryis necessarytoallowlocalcontrolif/usrismountedreadonly.Filesthatshouldbeinthis directoryincludeXconfigandXmodmap.Subdirectoriesof/etc/X11includethoseforwindow managersandxdm. /etc/X11/xdmholdstheconfigurationfilesforxdm.Thesearemostofthefilesnormallyfoundin /usr/lib/X11/xdm;seeSection5,/var/lib/xdm,formoreinformation. Thefollowingsectionisintendedpartlytoilluminatethedescriptionofthecontentsof/etcwith anumberofexamples;itisdefinitelynotanexhaustivelist. Requiredfilesfor/etc: •Generalfiles: ThesefilesareneededonmostLinuxsystems.

{adjtime,csh.login,disktab,fdprm,fstab,gettydefs,group,inittab,
issue,ld.so.conf,lilo.conf,magic,motd,mtab,mtools,passwd,profile,
psdatabase,securetty,shells,syslog.conf,termcap,ttytype}

•Networkingfiles: ThesefilesshouldbeinstalledonmostLinuxsystems.

{exports,ftpusers,gateways,hosts,host.conf,hosts.equiv,hosts.lpd,
inetd.conf,networks,printcap,protocols,resolv.conf,rpc,services}

Therearetwomodelsforsetupofthe"rc"commandscriptswhichareinvokedbyinit(8) atboottime,the/etc/rc.*BSDmodelandthe/etc/rc.d/*SystemVmodel.Either modelmaybeused,oramixtureofthetwo. Theutmpandwtmplogfilesarebothplacedin/var/adm.Neitherisneededuntilthe systemreachesmulti-usermode(when/varwillhavebeenmounted). Systemsthatusetheshadowpasswordsuitewillhaveadditionalconfigurationfilesin/etc

(/etc/shadowandothers)and/usr/sbin(useradd,usermod,andothers).

Systemsthatusegetty_pswillhaveafewadditionalconfigurationfileswhichshouldbe placeddirectlyinthe/etcdirectory.Thusthe/etc/default/getty_psinsomecurrent systemsshouldbeplacedin/etc/getty_ps. -12-LinuxFilesystemStructure May3,1994 3.5/home:Userhomedirectories(optional) /homeisafairlystandardconcept,butitisclearlyasite-specificfilesystem.Thesetupwilldiffer frommachinetomachine.Thissectiondescribesonlyasuggestedplacementforuserhome directories;neverthelesswerecommendthatallLinuxdistributionsusethisasthedefaultlocation forhomedirectories. Onsmallsystems,eachuser’sdirectoryistypicallyoneofthemanysubdirectoriesof/homesuch

as/home/smith,/home/linus,/home/operator,etc.

Onlargesystems(especiallywhenthe/homedirectoriesaresharedamongstmanymachinesusing NFS)itisusefultosubdivideuserhomedirectories.Subdivisionmaybeaccomplishedbyusing

subdirectoriessuchas/home/staff,/home/guests,/home/students,etc.

Differentpeopleprefertoplaceuseraccountsinavarietyofplaces.Therefore,noprogramshould relyonthislocation.Ifyouwanttofindoutauser’shomedirectory,youshouldusethe getpwent(3)libraryfunctionratherthanrelyingon/etc/passwdbecauseuserinformationmay bestoredremotelyusingsystemssuchasNIS. 3.6/lib:Sharedlibraries(neededtorundynamicallylinkedbinaries) The/libdirectorycontainsthosesharedlibraryimagesneededtobootthesystemandrunthe commandsintherootfilesystem. Thisincludes/lib/libc.so.*,/lib/libm.so.*,andtheshareddynamiclinker/lib/ld.so. Sharedlibrariesthatareonlynecessaryforbinariesin/usr(suchasanyXWindowbinaries)do notbelongin/lib.Onlythesharedlibrariesrequiredtorunbinariesin/binand/sbinshould behere.Thelibrarylibm.so.*mayalsobeplacedin/usr/libifitisnotrequiredbyanything

in/binor/sbin.

Forcompatibilityreasons,/lib/cppneedstoexistasareferencetotheCpreprocessorinstalled onthesystem.Theusualplacementofthisbinaryis

/usr/lib/gcc-lib/<target>/<version>/cpp./lib/cppcaneitherpointatthisbinary,orat

anyotherreferencetothisbinarywhichexistsinthefilesystem.(Forexample,/usr/bin/cppis alsooftenused.) 3.7/mnt:Mountpointfortemporarilymountedfilesystems Thisdirectoryisprovidedsothatthesystemadministratormaytemporarilymountfilesystemsas needed.Thecontentofthisdirectoryisalocalissueandshouldnotaffectthemannerinwhich anyprogramisrun. Werecommendagainsttheuseofthisdirectorybyinstallationprograms,andsuggestthata suitabletemporarydirectorynotinusebythesystemshouldbeusedinstead. 3.8/proc:Kernelandprocessinformationvirtualfilesystem Theprocfilesystemisbecomingthede-factostandardLinuxmethodforhandlingprocessand systeminformation,ratherthan/dev/kmemandothersimilarmethods.Westronglyencourage thisforthestorageandretrievalofprocessinformationaswellasotherkernelandmemory -13-LinuxFilesystemStructure May3,1994 information. 3.9/root:Homedirectoryforroot(optional) /istraditionallythehomedirectoryoftherootaccountonUNIXsystems./rootisusedon manyLinuxsystemsandonsomeUNIXsystems.Therootaccount’shomedirectorymaybe determinedbydeveloperorlocalpreference.Obviouspossibilitiesinclude/,/root,and

/home/root.

Ifroot’shomedirectoryisnotstoredontherootpartitionitwillbenecessarytomakecertainit willdefaultto/ifitcannotbelocated. Note:werecommendagainstusingtherootaccountformundanethingssuchasmailandnews, butrathertouseitsolelyforsystemsadministration.Forthisreason,werecommendthat subdirectoriessuchasMailandNewsnotappearintherootaccount’shomedirectory.We recommendthatmailforrootandpostmasterbeforwardedtoamoreappropriateuser. 3.10/sbin:Systembinaries(binariesoncekeptin/etc) Utilitiesusedforsystemadministration(andotherroot-onlycommands)arestoredin/sbin, /usr/sbin,and/usr/local/sbin./sbintypicallycontainsbinariesessentialforbootingthe systeminadditiontothebinariesin/bin.Anythingexecutedafter/usrisknowntobemounted (whentherearenoproblems)shouldbeplacedinto/usr/sbin.Local-onlysystemadministration binariesshouldbeplacedinto/usr/local/sbin. Decidingwhatthingsgoinsbindirectoriesissimple:Ifauserwillneedtorunit,thenitshould gosomewhereelse.Ifitwillonlyberunbysystemadministratorsorasrootfromsystem managementscripts,thenitshouldgoin/sbin(orin/usr/sbinor/usr/local/sbiniftheitem isnotvitaltosystemoperation). Filessuchaschfnwhichusersonlyoccasionallyuseshouldstillbeplacedin/usr/bin.ping, althoughitisabsolutelynecessaryforroot(networkrecoveryanddiagnosis)isoftenusedbyusers andshouldlivein/binforthatreason. Ordinaryusersshouldnothavetoplaceanyofthesbindirectoriesintheirpath. Werecommendthatusershavereadandexecutepermissionforeverythingin/sbinexcept, perhaps,certainsetuidandsetgidprograms.Thedivisionbetween/binand/sbinwasnot createdforsecurityreasonsortopreventusersfromseeingtheoperatingsystem,buttoprovidea goodpartitionbetweenbinariesthateveryoneusesandonesthatareprimarilyusedfor administrationtasks.Thereisnoinherentsecurityadvantageinmaking/sbinoff-limitsfor users. Requiredfilesfor/sbin: •Generalcommands:

{clock,getty,init,update,mkswap,swapon,swapoff,telinit}

-14-LinuxFilesystemStructure May3,1994 •Shutdowncommands:

{halt,reboot,shutdown}

•Filesystemmanagementcommands:

{fdisk,fsck,fsck.*,mkfs,mkfs.*}
*=oneofext,ext2,minix,msdos,xiaandperhapsothers

•Secondextendedfilesystemcommands(optional):

{badblocks,tune2fs,e2fsck,mke2fs}

•Bootloadermapinstaller:

{lilo}

•Networkingcommands:

{arp,ifconfig,ifsetup,route}

Optionalfilesfor/sbin: •Staticbinaries: Staticln(sln)andstaticsync(ssync)areusefulwhenthingsgowrong.Theprimaryuse ofsln(torepairincorrectsymlinksin/libafterapoorlyorchestratedupgrade)isnolonger amajorconcernnowthattheldconfigprogram(usuallylocatedin/usr/sbin)existsand canactasaguidinghandinupgradingthedynamiclibraries.Staticsyncisusefulinsome emergencysituations.Notethattheseneednotbestaticallycompiledversionsofthe standardlnandsync,butmaybe.

{sln,ssync}

•Miscellaneous: Soastocopewiththefactthatsomekeyboardscomeupwithsuchahighrepeatrateasto beunusable,kbdratemaybeinstalledin/sbinonsomesystems.

{kbdrate}

3.11/tmp:Temporaryfiles /tmpisusedfortemporaryfiles,preferablyonafastdevice(amemorybasedfilesystem,for instance). The"persistence"ofthedatathatisstoredin/tmpisdifferentfromthatofdatawhichisstored in/var/tmp./tmpmaybecleanedoutatboottimeoratrelativelyfrequentintervals.Therefore, datastoredin/tmpshouldnotbeexpectedtoremainforanylongperiod. Programsshoulduse/tmpor/var/tmp(whichwasoriginally/usr/tmp)accordingtothe expectedrequirementsofthedata,butshouldnotrelyonanyparticularpersistenceforany -15-LinuxFilesystemStructure May3,1994 temporarystoragedirectories. Systemadministratorsmaychoosetolink/tmptoanotherdirectory,suchas/var/tmp;thiswould beuseful,forexample,toconservespaceontherootpartition.Ifthisisdone,thenthe persistenceoffilesin/var/tmpshouldbeatleastaslongasfor/tmp. /tmpmaybeonaRAMdisk./var/tmpshouldneverbelocatedonaRAMdevice.

LinuxFilesystemStructure May3,1994 4.The/usrHierarchy /usristhesecondmajorsectionofthefilesystem./usrisshareable,read-onlydata.That meansthat/usrshouldbeshareablebetweenvariousmachinesrunningLinuxandshouldnotbe writtento.Anyinformationthatismachine-localorvarieswithtimeisstoredelsewhere. Nolargepackage(suchasTEXandGNUEmacs)shoulduseadirectsubdirectoryof/usr. Instead,thereshouldbeasubdirectorywithin/usr/lib(or/usr/local/libifitwasinstalled completelylocally)forthepurpose. /usr:Secondmajormountpoint(permanent)

|

|-X386XWindowsystemonx86platforms |-binMostusercommands |-dictWordlists |-docMiscellaneousdocumentation |-etcSite-widesystemconfiguration |-gamesGamesand"educational"binaries |-includeHeaderfilesincludedbyCprograms |-infoGNUInfosystem’sprimarydirectory |-libLibraries |-localLocalhierarchy(emptyaftermaininstallation) |-manOnlinemanuals |-sbinNon-vitalsystemadministrationbinaries |-shareArchitecture-independentdata +-srcSourcecode Thefollowingsymboliclinkstodirectoriesshouldbepresent.Thisrequirementisbasedonthe needtopreservecompatibilitywitholdersystemsuntilallimplementationscanbeassumedtouse the/varhierarchy.

/usr/adm->/var/adm
/usr/preserve->/var/preserve
/usr/spool->/var/spool
/usr/tmp->/var/tmp
/var/spool/locks->/var/lock

Onceasystemnolongerrequiresanyoneoftheabovesymboliclinks,itmayberemoved,if desired.Notably,ittakeslittleefforttocompletelyremove/usr/preservesinceonlyexandvi useit. -17-LinuxFilesystemStructure May3,1994 4.1/usr/X386:XWindowsystemonx86platforms ThishierarchyisreservedfortheuseofXFree86X11releases. /usr/X386:XFree86installationdirectory

|
|-bin
|-doc
|-include
|-lib
+-man

TosimplifymattersandmakeXFree86morecompatiblewithX11onothersystems,thefollowing symboliclinksshouldbepresent:

/usr/bin/X11->/usr/X386/bin
/usr/lib/X11->/usr/X386/lib/X11
/usr/include/X11->/usr/X386/include/X11

4.2/usr/bin:Mostusercommands /usr/bin:Binariesthatarenotneededinsingle-usermode.

|

|-mhCommandsfortheMHmailhandlingsystem

+-X11Symlinkto/usr/X386/bin

Thisistheprimarydirectoryofexecutablecommandsonthesystem. Becauseshellscriptinterpreters(invokedwith#!<path>onthefirstlineofashellscript)cannot relyonapath,itisadvantageoustostandardizethelocationofthem.TheBourneshellandCshellinterpretersarealreadyfixedin/bin,butPerl,Python,andTclareoftenfoundinmany

differentplaces./usr/bin/perl,/usr/bin/python,and/usr/bin/tclshouldreferencethe

perl,python,andtclshellinterpreters,respectively.Theymaybesymlinkstothephysical locationoftheshellinterpreters. 4.3/usr/dict:Wordlists Recommendedfilesfor/usr/dict:

{words}

TraditionallythisdirectorycontainsonlytheEnglishwordsfile,whichisusedbylook(1)and variousspellingprograms.wordsmayuseeitherAmericanorBritishspelling.Sitesthatrequire

bothmaylinkwordsto/usr/dict/american-englishor/usr/dict/british-english.

WordlistsforotherlanguagesmaybeaddedusingtheEnglishnameforthatlanguage,e.g., /usr/dict/french,/usr/dict/danish,etc.Theseshould,ifpossible,useanISO8859character setwhichisappropriateforthelanguageinquestion;ifpossibletheLatin1(ISO8859-1)character setshouldbeused(thisisoftennotpossible). Therationalebehindhavingonlywordlistshereisthattheyaretheonlyfilesusedbyallspell -18-LinuxFilesystemStructure May3,1994 checkers.Forexample,ispell(1)usesacomplicatedformatforits"hasheddictionaries"thatis onlyusefultoispellandshouldthusgoin/usr/lib/ispell. 4.4/usr/etc:Site-widesystemconfiguration Storingconfigurationin/usr/etcforthesoftwarefoundin/usr/binand/usr/sbinisa problem.Itmakestheread-onlymountingof/usrthroughCD-ROMorNFSdeliveryvery difficultatbest. Onepossiblesolutionthatweconsideredwastocompletelyeliminate/usr/etcandspecifythat allconfigurationbestoredin/etc.Aproblemwiththisapproachisthatitdoesnotproperly anticipatethepossibilitythatmanysitesmaywanttohavesomeconfigurationfilesthatarenot machine-local. Weeventuallydecidedthat/etcshouldbetheonlydirectorythatisactuallyreferencedby programs(thatis,everythingshouldlookforconfigurationin/etcandnotin/usr/etc).Any configurationfilesthatneedtobesite-wideandarenotneededbefore/usrismounted(orinan emergencysituation)shouldthenbeplacedin/usr/etc.Then,specificfiles(in/etc)onspecific machinesmayormaynotbesymbolicallylinkedtoappropriateconfigurationfileslocatedin /usr/etc.Thisalsomeansthat/usr/etcistechnicallyanoptionaldirectoryinthestrictest sense,butwestillrecommendthatallLinuxsystemsincorporateit. Itisnotrecommendedfor/usr/etctocontainsymboliclinksthatpointtofilesin/etc.Thisis unnecessaryandwouldinterferewithlocalcontrolonmachinesthatsharea/usrdirectory. 4.5/usr/include:Directoryforstandardincludefiles. Thisiswhereallofthesystem’sgeneral-useincludefilesfortheCandC++programming languagesshouldbeplaced.

/usr/include:Includefiles
|
|-X11Symlinkto/usr/X386/include/X11

|-arpaARPAnetdefinedprotocoldefinitions

|-asmSymlinkto/usr/src/linux/include/asm

|-bsdBSDcompatibilityincludefiles |-g++GNUC++includefiles |-gnuGNUincludefiles

|-linuxSymlinkto/usr/src/linux/include/linux

|-netGenericnetwork-relateddefinitions |-netax25+AX25(ARRLAX.25)specificdefinitions |-netinetTCP/IPspecificdefinitions |-netipx+IPX(NovellIPX/SPX)specificdefinitions |-protocolsProtocoldefinitions(mostlyINET-based) |-readlineTheGNUreadlinelibrary |-rpcSunMicrosystemsRPCdefinitions |-rpcsvcSunMicrosystemsRPCservicedefinitions +-sysSystemgenerationincludefiles /usr/include/g++isoptional,butsuggested,untilsuchtimethatitbecomesthedefaultforthe -19-LinuxFilesystemStructure May3,1994 standardLinuxG++libraries.Thepreviouslocationwas/usr/g++-include. ThearpasubdirectorycontainsprotocolheaderdefinitionsfortheARPAnetprotocols,TCP/IP conversionfunctions,definitionsforftp,telnetprototypes,andsimilarmaterial. Thenetsubdirectorycontainsgenericnetwork-relateddefinitions.Itdefinesthesystemkernel interface,protocolfamilydetails,etc. ThenetinetsubdirectorycontainsINET(DARPAInternet,whichisalsoknownasTCP/IP) specificdefinitions. ARRLAX.25isbetterknownaspacketradioandNovellIPX/SPXisbetterknownasNovell NetWare. 4.6/usr/lib:Librariesforprogrammingandpackages /usr/lib:Librariesforprogrammingandpackages

|
|-X11Symboliclinkto/usr/X386/lib/X11

|-emacsStaticsupportfilesfortheGNUEmacseditor

|-gamesStaticdatafilesfor/usr/games

|-groffLibraries/directoriesforGNUgroff |-gcc-libSystemspecificfiles/directoriesforGCC |-kbdKeyboardtranslationtablesandrelateddata |-mhLibrariesfortheMHmailhandlingsystem |-newsCnews/INN

|-smailSmail

|-terminfoDirectoriesforterminfodatabase |-texmfTEX/MF(andLATEX)datalibraries |-uucpCommandsforUUCP +-zoneinfoTimezoneinformationandconfiguration /usr/libincludesobjectlibraries,compilerprogrambinaries,andstaticdataofvariouskinds— bothexecutablecode(forexample,GCC’sinternalbinariesarelocatedunder/usr/lib/gcc-lib) andothertypesofdata. Historically,ithasalsoincludedsomecommandssuchassendmailandmakewhatis. Sincemakewhatisisnotreferencedbyotherprograms,thereisnoproblemwithmovingittoa binarydirectory.Sinceusershavegoodcausetousemakewhatis,/usr/biniswhereitbelongs. Thecatmanbinary(whichreplacesthemakewhatisscriptonmanyLinuxsystems)shouldalsobe placedin/usr/bin. Thesendmailbinaryisreferencedbymanyprogramsbyitshistoricalname,/usr/lib/sendmail. Thisshouldbeasymboliclinktothestandardlocationformailtransferagentswithasendmailcompatiblecommandlineinterface,/usr/sbin/sendmail. SystemsusingSmailshouldplaceSmailin/usr/sbin/smail,and/usr/sbin/sendmailshouldbe asymboliclinktoit. -20-LinuxFilesystemStructure May3,1994 ThisarrangementalsoconformstothenewstandardsendmaillocationasdefinedinSendmail 8.6.xand4.4BSD.Notethatthisplacementdemandsthat/usr/sbinand/usr/sbin/sendmail mustbeexecutablebynormalusers. Anyprogramorpackagewhichcontainsorrequiresdatathatdoesn’tneedtobemodifiedshould storethatdatain/usr/lib(or/usr/local/lib,ifinstalledlocally).Itisrecommendedthata subdirectorybeusedin/usr/libforthispurpose. Gamedatastoredin/usr/lib/gamesshouldbepurelystaticdata.Anymodifiablefiles,suchas scorefiles,gameplaylogs,andsoforth,shouldbeplacedin/var/lib.Ifnecessaryfor compatibilitywitholdBSD-stylegames,asymlinkfrom/usr/games/libto/usr/lib/gamescan beused. Note:Nohost-specificdatafortheXWindowsystemshouldbestoredin/usr/lib/X11(whichis really/usr/X386/lib/X11).Host-specificconfigurationfilessuchasXconfigshouldbestoredin /etc.Thisshouldincludeconfigurationdatasuchassystem.twmrcevenifitisonlymadea symboliclinktoamoreglobalconfigurationfile(perhapsin/usr/etc/X11or

/usr/X386/lib/X11).

4.7/usr/local:Localhierarchy /usr/local:Localhierarchy

|

|-binLocal-onlybinaries |-docLocaldocumentation |-etcConfigurationforlocal-onlybinaries |-gamesLocallyinstalledgames

|-libLibrariesfor/usr/local

|-infoLocalinfopages |-manManpagehierarchyfor/usr/local |-sbinLocal-onlysystemadministration +-srcLocalsourcecode The/usr/localhierarchyisforusebythesystemadministratorwheninstallingsoftwarelocally. Itneedstobesafefrombeingoverwrittenwhenthesystemsoftwareisupdated.Itmaybeused forprogramsanddatathatareshareableamongstagroupofmachines,butnotfoundin/usr. ThisdirectoryshouldalwaysbeemptyafterfirstinstallingLinux.Noexceptionstothisrule shouldbemadeotherthanthelisteddirectorystubs. Locallyinstalledsoftwareshouldbeplacedwithin/usr/localratherthan/usrunlessitisbeing installedtoreplaceorupgradesoftwarein/usr. Notethatsoftwareplacedin/or/usrmaybeoverwrittenbysystemupgrades(thoughwe recommendthatdistributionsdonotoverwritedatain/etcunderthesecircumstances).Forthis reason,localsoftwareshouldnotbeplacedoutsideof/usr/localwithoutgoodreason. -21-LinuxFilesystemStructure May3,1994 4.8/usr/man:Manualpages Thissectiondetailstheorganizationformanualpagesthroughoutthesystem. Manualpagesarestoredin<mandir>/<locale>/man[1-9].Anexplanationof<mandir>and <locale>isgivenbelow. <mandir>/<locale>:Amanualpagehierarchy

|

|-man1Userprograms |-man2Systemcalls |-man3Libraryfunctionsandsubroutines |-man4Devices |-man5Fileformats

|-man6Games

|-man7Miscellaneous |-man8Systemadministration |-man9Kernelinternalvariablesandfunctions +-whatisManualindexfile Theprimary<mandir>ofthesystemis/usr/man./usr/mancontainsmanualinformationfor commandsanddataunderthe/and/usrfilesystems.Obviously,therearenomanualpagesin/ becausetheyarenotrequiredatboottimenoraretheyrequiredinemergencies. Provisionsmustbemadeinthestructureof/usr/mantosupportmanualpageswhicharewritten indifferent(ormultiple)languages.Theseprovisionsmusttakeintoaccountthestorageand referenceofthesemanualpages.Relevantfactorsincludelanguage(includinggeographical-based differences),andcharactercodeset. Thisnamingoflanguagesubdirectoriesof/usr/manisbasedonAppendixEofthePOSIX1003.1 standardwhichdescribesthelocaleidentificationstring—themostwellacceptedmethodto describeaculturalenvironment.The<locale>stringis:

<language>[_<territory>][.<character-set>][,<version>]

The<language>fieldshallbetakenfromISO639(acodefortherepresentationofnamesof languages).Itshallbetwocharacterswideandspecifiedwithlowercaselettersonly. The<territory>fieldshallbethetwo-lettercodeofISO3166(aspecificationofrepresentations ofcountries),ifpossible.(Mostpeoplearefamiliarwiththetwo-lettercode’suseforthecountry codesinemailaddresses.1)Itshallbetwocharacterswideandspecifiedwithuppercaseletters only. The<character-set>fieldshouldrepresentthestandarddescribingthecharacterset.Ifthe <character-set>fieldisjustanumericspecification,thenumberrepresentsthenumberofthe internationalstandarddescribingthecharacterset.Ifthecharactersetspecificationisnot present,theencodingshallbeassumedtobeinASCII.Itisrecommendedthatthisbeanumeric representationifpossible(ISOstandards,especially),notincludeadditionalpunctuationsymbols, 1.

ThemajorexceptiontothisruleistheUnitedKingdom,whichis‘GB’ratherthan‘UK’.Despitethisdiscrepancy, theISO3166codefortheUnitedKingdom,‘GB’,shouldbeusedinthe<territory>fieldforBritishEnglish. -22-LinuxFilesystemStructure May3,1994 andthatanylettersbeinlowercase. Aparameterspecifyinga<version>oftheprofilemaybeplacedafterthe<character-set> field,delimitedbyacomma.Thismaybeusedtodiscriminatebetweendifferentculturalneeds; forinstance,dictionaryorderversusamoresystems-orientedcollatingorder.Thisstandard recommendsnotusingthe<version>field,unlessitisnecessary. Systemswhichuseauniquelanguageandcodesetforallmanualpagesmayomitthe<locale> substringandstoreallmanualpagesin<mandir>.Forexample,systemswhichonlyhaveEnglish manualpagescodedwithASCII,maystoremanualpages(theman[1-9]directories)directlyin /usr/man.(Thatisthetraditionalcircumstanceandarrangement,infact.) Countriesforwhichthereisawellacceptedstandardcharactercodesetmayomitthe <character-set>field,butotherwise,itisrecommendedthatitbeincluded,especiallyfor countrieswithseveral"competing"standards. Variousexamples: LanguageTerritoryCharacterSetDirectory English—ASCII/usr/man/en EnglishUnitedKingdomASCII/usr/man/en_GB EnglishUnitedStatesASCII/usr/man/en_US FrenchCanadaISO8859-1/usr/man/fr_CA FrenchFranceISO8859-1/usr/man/fr_FR GermanGermanyISO646/usr/man/de_DE.646 GermanGermanyISO6937/usr/man/de_DE.6937 GermanGermanyISO8859-1/usr/man/de_DE.88591 GermanSwitzerlandISO646/usr/man/de_CH.646

JapaneseJapanJIS/usr/man/ja_JP.jis
JapaneseJapanSJIS/usr/man/ja_JP.sjis

JapaneseJapanUJIS(orEUC-J)/usr/man/ja_JP.ujis Manualpagesforcommandsanddataunder/usr/localarestoredin/usr/local/man.Manual pagesfortheXWindowsystemarestoredin/usr/X386/man.Itfollowsthatallmanualpage hierarchiesinthesystemshouldhavethesamestructureas/usr/man.Emptydirectoriesmaybe omittedfromamanualpagehierarchy.Forexample,if/usr/local/manhasnomanualpagesin section4(Devices),then/usr/local/man/man4maybeomitted. Thecatpagesections(cat[1-9])containingformattedmanualpageentriesarealsofoundwithin subdirectoriesof<mandir>/<locale>,butarenotrequirednorshouldtheybedistributedinlieu ofnroffsourcemanualpages. TheMHmailhandlingsystemmanualpagesshouldhavemhappendedtoallmanualpage filenames.AllXWindowsystemmanualpagesshouldhaveanxappendedtothefilename. Thepracticeofplacingvariouslanguagemanualpagesinappropriatesubdirectoriesof/usr/man alsoappliestotheothermanualpagehierarchies,suchas/usr/local/manand/usr/X11/man. (ThisportionoftheFSSTNDalsoapplieslaterinsection5.3ontheoptional/var/catman structure.) -23-LinuxFilesystemStructure May3,1994 Adescriptionofeachsectionfollows: •man1:Userprograms Manualpagesthatdescribepubliclyaccessiblecommandsarecontainedinthischapter. Mostprogramdocumentationthatauserwillneedtouseislocatedhere. •man2:Systemcalls Thissectiondescribesallofthesystemcalls(requestsfortheLinuxkerneltoperform operations). •man3:Libraryfunctionsandsubroutines Section3describesprogramlibraryroutinesthatarenotdirectcallstokernelservices.This andchapter2areonlyreallyofinteresttoprogrammers. •man4:Specialfiles Section4describesthespecialfiles,relateddriverfunctions,andnetworkingsupport availableinthesystem.Typically,thisincludesthedevicefilesfoundin/devandthekernel interfacetonetworkingprotocolsupport. •man5:Fileformats Theformatsformanynonintuitivedatafilesaredocumentedinthesection5.Thisincludes variousincludefiles,programoutputfiles,andsystemfiles. •man6:Games Thischapterdocumentsgames,demos,andgenerallytrivialprograms.Differentpeople havevariousnotionsabouthowessentialthisis. •man7:Miscellaneous Manualpagesthataredifficulttoclassifyaredesignatedasbeingsection7.Thetroffand othertextprocessingmacropackagesarefoundhere. •man8:Systemadministration Documentationforprogramsusedbysystemadministratorsforsystemoperationand maintenancearedocumentedhere.Someoftheseprogramsarealsooccasionallyusefulfor normalusers. •man9:Kernelinternalvariablesandfunctions ThisisusedonLinuxsystemstodocumentthekernelsourcecode. 4.9/usr/sbin:Non-essentialstandardsystembinaries Thisdirectorycontainsanynon-essentialbinariesusedexclusivelybythesystemadministrator. Systemadministrationprogramsthatarerequiredforsystemrepair,systemrecovery,mounting /usr,orotheressentialfunctionsshouldbeplacedin/sbininstead. Typically,/usr/sbincontainsnetworkingdaemons,anynon-essentialadministrationtools,and binariesfornon-criticalserverprograms. TheseserverprogramsareusedwhenenteringtheSystemVstatesknownas"runlevel2"(multiuserstate)and"runlevel3"(networkedstate)ortheBSDstateknownas"multi-usermode".At thispointthesystemismakingservicesavailabletousers(e.g.,printersupport)andtoother machines(e.g.,NFSexports). Locallyinstalledsystemadministrationprogramsshouldbeplacedin/usr/local/sbin. -24-LinuxFilesystemStructure May3,1994 4.10/usr/share:Architecture-independentdata Anyspecificationsfor/usr/sharewillbeincludedinasupplementarydrafttothemainFSSTND standard.NotethatitistheconsensusopinionofFSSTNDthat/usr/shareisnotneededonthe majorityofLinuxsystems.Atthistime,confiningourselvesbyprovidinganextensivedefinition ofthisdirectorywouldbeabadidea. Pleaserefertosection6formoredetaileddescriptionof/usr/share. 4.11/usr/src:Sourcecode /usr/src:Sourcecode

|

+-linuxSourcecodeforLinus’kernel Anynon-localsourcecodeshouldbeplacedinthissubdirectory.Theonlysourcecodethat shouldalwaysbeplacedinaspecificlocationisthekernelsource(whenpresentorlinkedinpart tothe/usr/includestructure).Subdirectoriesmaybeusedhereifdesired. Thesourcecodeforthekernelshouldalwaysbeinplaceoratleasttheincludefilesfromthe kernelsource.Thosefilesarelocatedinthesedirectories:

/usr/src/linux/include/asm
/usr/src/linux/include/linux

/usr/includeshouldcontainlinkstothesedirectories,namedasmandlinux.Sincetheyare neededbytheCcompiler,atleastthoseincludefilesshouldalwaysbedistributedwith installationswhichincludeaCcompiler.Theyshouldbedistributedinthe/usr/src/linux directorysotherearenoproblemswhensystemadministratorsupgradetheirkernelversionfor thefirsttime. /usr/src/linuxmayalsobeasymboliclinktoakernelsourcecodetree. -25-LinuxFilesystemStructure May3,1994 5.The/varHierarchy /var:Machine-localvariabledata

|

|-admSystemloggingandaccountingfiles |-catmanLocally-formattedmanualpages |-libApplicationstateinformation |-localVariabledataofsoftwarefrom/usr/local |-lockLockfiles |-namedDNSfiles,networkingonly |-nisNetworkInformationService(NIS)databasefiles |-preserveSavedtextaftercrashorhang-upfromexorvi |-runFilesrelevanttorunningprocesses |-spoolDirectoriesforqueuedworktobeperformedlater +-tmpTemporaryfiles,usedtokeep/tmpsmall /varcontainsvariabledatafiles.Thisincludesspooldirectoriesandfiles,administrativeand loggingdata,andtransientandtemporaryfiles. /varisspecifiedhereinordertomakeitpossibletomount/usrread-only.Everythingthatonce wentinto/usrthatiswrittentoduringsystemoperation(asopposedtoinstallationandsoftware maintenance)shouldbein/var. If/varcannotbemadeaseparatepartition,itisoftenpreferabletomove/varoutoftheroot partitionandintothe/usrpartition.(Thisissometimesdonetoreducethesizeoftheroot partitionorwhenspacerunslowintherootpartition.)However,/varshouldnotbelinkedto /usrbecausethismakesseparationof/usrand/varmoredifficultandislikelytocreatea namingconflict.Instead,link/varto/usr/var. 5.1/var/adm:Systemloggingandaccountingfiles Allsystemloggingshouldbewrittentothissubdirectoryandnotto/var/log.utmp,wtmp,and lastlogshouldbestoredhere. /var/admisalsotheappropriatelocationforalldistributionpackagingsupport.Untilthereisa commonLinuxpackagingformat,packagedatashouldbestoredindistributionspecific subdirectoriesofthisdirectory. 5.2/var/catman:Locally-formattedmanualpages(optional) Thisdirectoryprovidesastandardlocationforsitesthatprovidearead-only/usrpartition,but wishtoallowcachingoflocally-formattedmanpages.Sitesthatmount/usraswritable(e.g., single-userinstallations)maychoosenottouse/var/catmanandwriteformattedmanpagesinto thecat[1-9]directoriesin/usrdirectly.Werecommendthatmostsitesuseoneofthefollowing optionsinstead: •Preformatallmanualpagesin/usrwiththecatmanprogram. •Allownocachingofformattedmanpages,andrequirenrofftoberuneachtimeaman pageisbroughtup. -26-LinuxFilesystemStructure May3,1994 •Allowlocalcachingofformattedmanpagesin/var/catman. Thestructureof/var/catmanneedstoreflectboththefactofmultiplemanpagehierarchiesand thepossibilityofmultiplelanguagesupport.Givenaformattedmanpagethatwouldnormally appearin/usr/<path1>,thecachedformattedversionshouldgoin/var/catman/<path2>,where <path2>is<path1>withoutthemancomponent.Thus,/usr/man/man1/ls.1isformattedinto

/var/catman/cat1/ls.1,and/usr/local/man/<locale>/man3/XtClass.3into
/var/catman/local/<locale>/cat3/XtClass.3.

Manpageswrittento/var/catman/cat[1-9]mayeventuallybetransferredto

/usr/<path>/cat[1-9]orexpired;likewiseformattedmanpagesin/usr/<path>/cat[1-9]may

beexpirediftheyarenotaccessedforaperiodoftime. Note:currentversionsofthemanprogramdonotsupportthisproposedstandard.Untilsuch supportisavailable,sitesmustchoosebetweenpreformattingcatpagesin/usr(ormounting /usraswritable),andsymlinkingthevariouscat[1-9]directoriestotheappropriate subdirectoryof/var/catman. 5.3/var/lib:Applicationstateinformation /var/lib:Applicationstateinformation

|

|-emacsStatedirectoryforEmacs |-newsVariablefilesforCnews/INN +-xdmXdisplaymanagerauthenticationfilesanderrorlogs TheGNUEmacsstatedirectory,thelocationofarchitecture-independentdatafilesthatEmacs modifieswhilerunning,shouldbe/var/lib.Presently,Emacsonlylocatesitslockfiledirectory underthestatedirectory(in<statedir>/emacs/lock),butitmaymakemoreextensiveuseof thestatedirectoryinthefuture.Notably,itonlyrequirestheadditionofasingleoptiontothe Emacsconfigureprogramtomakethischange(beforecompilation). /var/lib/newsshouldbeusedtostoreallthevariabledataassociatedwithnewsserverssuchas CnewsandINN,includingthehistoryfile,activefile,andsoforth. /var/lib/xdmcontainsthevariabledatafromxdm,whichconsistsofthexdm-errorsfilesand anyxdmauthorityfiles.xdmbinariessuchasthechoosershouldstillbeplacedinthehistorical

locationin/usr/X386/lib/X11/xdm.Thexdm-pidfileshouldbeplacedin/var/lib/xdmdespite

theexistenceof/var/run.Theremainingfilesshouldbeplacedin/etc/X11/xdm. Aswellasthesubdirectorieslistedabove,anyvariabledatarelatingtothegamesfoundin /usr/gamesshouldbeplacedhere./var/libshouldholdthevariabledatapreviouslyfoundin /usr/lib/games;constantdata,suchashelptext,leveldescriptions,andsoon,shouldremainin

/usr/lib/games.

5.4/var/local:Variabledataofsoftwarefrom/usr/local Thisdirectorycontainsallvariabledatawhichisrelatedtosoftwarefoundin/usr/local. Naturally,theimplementationofthisdirectoryisleftuptothesiteadministrator.However, informationwhichcanbecategorizedintoanother/vardirectoryshouldnotbeplacedin -27-LinuxFilesystemStructure May3,1994 /var/local.Forexample,alllockfilesstillgointo/var/lock. 5.5/var/lock:Lockfiles Lockfilesshouldbestoredwithinthe/var/lockdirectorystructure. Topreservetheabilitytomount/usrread-only,nolockfilesshouldbeplacedonthe/usr partition. Devicelockfiles,suchastheserialdevicelockfileswhicharecurrentlyfoundineither

/usr/spool/locksor/usr/spool/uucp,shouldnowbestoredin/var/lock.Thenaming

conventionwhichshouldbeusedisLCK..followedbythebasenameofthedevice.Forexample, tolock/dev/cua0thefileLCK..cua0wouldbecreated. TheformatusedforLinuxdevicelockfilesshouldbetheHDBUUCPlockfileformat.TheHDB formatistostoretheprocessIDasatenbyteASCIIdecimalnumber,withatrailingnewline. Forexample,ifprocess1230holdsalockfile,itwouldcontaintheelevencharacters:space,space, space,space,space,space,one,two,three,zero,andnewline. Then,anythingwishingtouse/dev/cua0canobservethelockfileandactaccordingly. 5.6/var/named:DNSfiles Thisdirectorycontainsallthenameserver’sworkingfiles.Staticconfigurationfilesshouldbe placedin/etc. 5.7/var/nis:NetworkInformationService(NIS)databasefiles TheNetworkInformationService(NIS)wasformerlyknownastheSunYellowPages(YP).The functionalityanddirectoryplacementofthetwoisthesame,butthename"YellowPages"isa registeredtrademarkintheUnitedKingdom,belongingtoBritishTelecommunicationsplc,and maynotbeusedwithoutpermission. 5.8/var/preserve:Savedtextaftercrashorhang-upfromexorvi Thisdirectoryholdssavedfilesgeneratedbyanunexpectedterminationofex,vi,oroneofits clones. 5.9/var/run:Run-timevariablefiles PID(processid)files,previouslystoredin/etc,shouldnowbeplacedin/var/run.Thenaming conventionwhichshouldbeusedis<program-name>.pid.Forexample,crondwoulduse

/var/run/crond.pid.

TheinternalformatofPIDfilesisthesameasalways.ThefileshouldconsistoftheprocessIDin ASCII-encodeddecimal,followedbyanewlinecharacter.Forexample,ifcrondwasprocess number25,/var/run/crond.pidwouldcontainthreecharacters:two,five,andnewline. ProgramsthatreadPIDfilesshouldbesomewhatflexibleinwhattheyaccept;i.e.,theyshould ignoreextrawhitespace,leadingzeroes,oradditionallinesinthePIDfile.However,programs whichcreatePIDfilesshouldusethesimplespecificationlocatedintheaboveparagraph. -28-LinuxFilesystemStructure May3,1994 ProgramsthatmaintainUnix-domainsocketsshouldplacetheminthisdirectory. 5.10/var/spool:Spooldirectories /var/spoolistraditionallyusedformachine-localdatabeingspooledtoorfromUNIX subsystems.Forexample,printjobsarespooledherefordeliverytothelineprinterdaemon,outboundmailisspooledfordeliverytoremotesystems,andUUCPfilesarespooledfortransmission toUUCPneighbors.In-boundmailandnewsarespooledherefordeliverytousers,andatand cronjobsarespooledfordelayedexecutionbythecrondaemon. /var/spool:Spooldirectories

|
|-atatjobs
|-croncronjobs

|-lpdPrinterspooldirectory |-mailDirectoryforusermailboxes |-mqueueOutgoingmailqueue |-newsNewsspooldirectory |-rwhoRwhodfiles |-smailSpooldirectoriesforsmail +-uucpSpooldirectoryforUUCP UUCPlockfilesshouldbeplacedin/var/lock.Seetheabovesectionon/var/lock. 5.10.1/var/spool/lpd /var/spool/lpd:Printerspooldirectory

|

|-<printer>Spoolsforaspecificprinter +-<printer>/lockLockfileforaspecificprinter Thelockfileforlpd,lpd.lock,shouldbeplacedin/var/spool/lpd.Thelockfileforeach printershouldbeplacedinthespooldirectoryforthatspecificprinter. 5.11/var/tmp:temporaryfiles,usedtokeep/tmpsmall Filesin/var/tmparestoredforanunspecifiedduration(pleaserememberthatsystemtemporary directoriesarenotguaranteedtoholddataforanyparticularduration). Datastoredin/var/tmpistypicallycleanedout"inasite-specificmanner",butusuallyatless frequentintervalsthan/tmp.Moreinformationontemporarydirectoriesisinthesectionofthe standarddevotedto/tmp(above). Thereshouldbeasymboliclinkfrom/usr/tmpto/var/tmp,forcompatibilityreasons. -29-LinuxFilesystemStructure May3,1994 6.IssuesandAdditionalRationale Thissectiondiscussesseveralareasthatmayrequirefurtherexplanation. 6.1WhatisEssential? Theansweris:essentialtoclean,create,prepare,check,findandmountotherfilesystems (possiblyonremotemachines).Thereareotherdefinitions,butthisisageneraldefinitionthat mostpeoplewillatleastincorporateintotheirown. 6.2Networking Networkingpresentedaninterestingdilemma.Somepeoplewantedtoseparatenetworking binariesandconfigurationfromotherbinariesandconfiguration.However,wedisagree.Wefeel thatnetworkingisnota"package",butanintegralpartofmostUNIX(andUNIX-like)machines. Becauseofthisnetworkingshouldnotbeplacedintoasingledirectory,butsystematicallyplaced intheappropriatedirectories. •/bin:anythingauserwillwanttousethatisalsoconsideredvital

{hostname,netstat,ping}

•/sbin:anythingonlyrootneedsandisconsideredvital

{arp,ifconfig,ifsetup,route}

•/usr/bin:anybinariesauserwillwanttouse,andwhicharenotvital

{finger,rcp,rlogin,telnet,etc.}

•/usr/sbin:anyadministratoronlybinariesthatarenotvital

{ftpd,inetd,lpd,telnetd,etc.}

Whilethismayseemconfusingatfirst(anditdoestakeamomenttodigest),itdoesmakesense. Ifyoucanonlymountrootforsomereasonandyouneedaccesstonetworkingtorepairyour system,youdon’tneedthefilestobeoffin/usr/etc(astheyoftenare).Filesthatareneededto mount/usrinnormal(andemergency)situationsareplacedontherootsubtreeandanyothers areplacedin/usrinordertokeepthesizeoftherootfilesystemsmall. Configurationfilesfornetworkingbelongin/etc. 6.3Architecture-independentStructures Thedirectory/usr/sharetypicallycontainsarchitecture-independentfilessuchasman-pages, timezone,terminfoinformation,etc.Asofthistime,therearenodifferentarchitecturesfor Linux,butwiththepassageoftimeweshouldseeLinuxincludeotherarchitecturesandother UNIX-likesystems. Onenote:noprogramshouldeverreferenceanythingin/usr/share.Forinstance,amanualpage programshouldneverdirectlylookin/usr/share/man/man1/ls.1,butitshouldreferto /usr/man/man1/ls.1atalltimes.Anythingin/usr/sharewillbe"pointedto"bytheuseof symlinksfromotherareasinthefilesystem,suchas/usr/man,/usr/lib/<something>,etc. Thespecificationsfor/usr/sharearestillbeingworkedon. -30-LinuxFilesystemStructure May3,1994 6.4SymbolicLinks Thereareawiderangeofusesforsymboliclinksineveryfilesystem.Whilesymlinksarenot encouragedfordefaultsetup(foundafterinstallingLinux)inastandardsuchasthis,theyare oftenusedwithgoodpurposeondifferentsystems.Thepointisthatsymlinksshouldbethereto keepeverythingwhereeveryoneelseexpectsfindit. Bepreparedtoacceptthatcertaindirectories,eventhosecontainedontherootdirectory,arestill goingtobesymlinks.Forinstance,onsomesystems/homewillnotbeontheroot,butsymlinked toa/vardirectory,ortosomewhereelse./homecouldalsohaveitsownphysicalpartition,of course,andbemountedonitsown. Similarly,because/usrmightbeonacentralfileservermountedviaNFS,/usr/localcouldbe symlinkedto/var/local.Thischangecanbejustifiedbyrecallingthemainreasonforhaving /var:toseparatedirectoriesoffilesthatvarywithtimeandbetweendifferentsystemsand machinesfromthosethatmaybesharedandread-only. Sometimessystemswillalsolink/tmpto/var/<something>iftherootpartitionbecomestoo small(orstartsouttoosmall).Therearemoreexamplesof"good"usesofsymboliclinks,but theentireissueboilsdowntotwothings:packagesshouldbeabletofindthingswheretheyexpect them(withinreason)andsymboliclinkscanbeusedtosolvetheprobleminmanycases. However,problemsalsocanarisefromusingtoomanysymboliclinks.Theseproblemsinclude over-relianceonsymboliclinkstosolveproblems,confusionresultingfromoveruseofsymbolic links,andtheaestheticpreferencesofdifferentpeople. 6.5Staticallylinkedbinaries Linuxiscurrentlyrunningonawidevarietyofsystems,somesingleuserwithsmalldisks,someas serversinlargenetworkedenvironments.Becauseofthisvariety,thisstandardsetsnorule regardingwhatbinariesarestaticordynamicwiththefollowingtwoexceptions.Bothlnand syncshouldexistin/bin;anystaticallylinkedversionsmaybeplacedin/sbin,orreplacethose

in/bin.

LargeLinuxsystemsmaywishtoincludeotherstaticallylinkedbinaries(sh,init,mkfs,fsck,

tunefs,mount,umount,swapon,swapoff,getty,login,andothers).Developersand/orsystem

administratorsarefreetostatically/dynamicallylinktheseandotherbinariesastheyseefit,as longasthelocationofthebinariesdoesn’tchange. Networkedsystems(especiallyonesthatdon’thavefloppydrives),maywanttolinkifconfig, route,hostname,andothernetworkingutilitiesstaticallyaswell.Thisisusuallynotneeded. -31-LinuxFilesystemStructure May3,1994 TheFSSTNDmailinglist TheFSSTNDmailinglistislocatedat<linux-fsstnd@ucsd.edu>.Thislistwasoriginallylocated onthe<linux-activists@Niksula.hut.fi>"Mail-Net"astheFSSTNDchannel.(Tosubscribetothe listsendmailto<listserv@ucsd.edu>withbody"ADDlinux-fsstnd".) ThankstoNetworkOperationsattheUniversityofCaliforniaatSanDiegowhoallowedustouse theirexcellentmailinglistserver. Asnotedintheintroduction,pleasedonotsendmailtothemailinglistwithoutfirstcontacting theFSSTNDcoordinatororalistedcontributor. Acknowledgments CreditforthistextshouldbegiventotheFSSTNDactivists,developers,systemadministrators, anduserswhoseinputwasessentialtothisstandard.Ialsowishtothankeachofthe contributorswhohelpedmetowrite,compile,andcomposethis,aconsensusstandard. IalsowishtogiverealcredittothoseLinuxdeveloperswhohaveseenthatgivingLinuxa commonfilesystemlayoutissomethingthatwillfurtherthedevelopmentoftheLinuxoperating system.IalsowishtonotethebraveryandperseveranceofthoseLinuxdeveloperswhostarted followingthisstandardbeforeitwascompleted. Originalcontributors DrewEckhardt<drew@kinglear.cs.colorado.edu> IanJackson<ijackson@nyx.cs.du.edu> IanMcCloghrie<ian@ucsd.edu> DanielQuinlan<quinlan@bucknell.edu> MikeSangrey<mike@sojurn.lns.pa.us> DavidH.Silber<dhs@glowworm.firefly.com> TheodoreTs’o<tytso@athena.mit.edu> StephenTweedie<sct@dcs.ed.ac.uk> Additionalcontributors BrandonS.Allbery<bsa@kf8nh.wariat.org> RikFaith<faith@cs.unc.edu> StephenHarris<hsw1@papa.attmail.com> FredN.vanKempen<waltje@uwalt.nl.mugnet.org> JohnA.Martin<jmartin@csc.com> ChrisMetcalf<metcalf@lcs.mit.edu> IanMurdock<imurdock@gnu.ai.mit.edu> DavidC.Niemi<niemidc@oasis.gtegsc.com> -32-CONTENTS 1.

General ................................................................................................................................2 1.1 Scope ...........................................................................................................................2 1.2 SpecificProblems ........................................................................................................3 1.3 Objectives ...................................................................................................................4 1.4 HistoryandProgress ...................................................................................................4 1.5 ConformancewiththisDocument ...............................................................................5 2.

TheFilesystem ....................................................................................................................6 3.

TheRootDirectory .............................................................................................................8 3.1 /bin:Essentialcommandbinaries(forusebyallusers)

............................................9 3.2 /boot:Staticfilesofthebootloader ........................................................................10 3.3 /dev:Devicefiles ......................................................................................................11 3.4 /etc:Machine-localsystemconfiguration .................................................................11 3.5 /home:Userhomedirectories(optional)

..................................................................13 3.6 /lib:Sharedlibraries(neededtorundynamicallylinkedbinaries)

..........................13 3.7 /mnt:Mountpointfortemporarilymountedfilesystems .........................................13 3.8 /proc:Kernelandprocessinformationvirtualfilesystem ........................................13 3.9 /root:Homedirectoryforroot(optional)

................................................................14 3.10 /sbin:Systembinaries(binariesoncekeptin/etc)

..................................................14 3.11 /tmp:Temporaryfiles ..............................................................................................15 4.

The/usrHierarchy ............................................................................................................17 4.1 /usr/X386:XWindowsystemonx86platforms ......................................................17 4.2 /usr/bin:Mostusercommands ................................................................................18 4.3 /usr/dict:Wordlists ................................................................................................18 4.4 /usr/etc:Site-widesystemconfiguration ..................................................................19 4.5 /usr/include:Directoryforstandardincludefiles.

...................................................19 4.6 /usr/lib:Librariesforprogrammingandpackages ...................................................20 4.7 /usr/local:Localhierarchy .......................................................................................21 4.8 /usr/man:Manualpages ..........................................................................................22 4.9 /usr/sbin:Non-essentialstandardsystembinaries ...................................................24 4.10 /usr/share:Architecture-independentdata ..............................................................25 4.11 /usr/src:Sourcecode ...............................................................................................25 5.

The/varHierarchy ............................................................................................................26 5.1 /var/adm:Systemloggingandaccountingfiles .......................................................26 5.2 /var/catman:Locally-formattedmanualpages(optional)

.......................................26 5.3 /var/lib:Applicationstateinformation ....................................................................27 5.4 /var/local:Variabledataofsoftwarefrom/usr/local ..............................................27 5.5 /var/lock:Lockfiles .................................................................................................28 5.6 /var/named:DNSfiles .............................................................................................28 5.7 /var/nis:NetworkInformationService(NIS)databasefiles ....................................28 5.8 /var/preserve:Savedtextaftercrashorhang-upfromexorvi .............................28 5.9 /var/run:Run-timevariablefiles .............................................................................28 5.10 /var/spool:Spooldirectories ....................................................................................29 5.11 /var/tmp:temporaryfiles,usedtokeep/tmpsmall ...............................................29 i 6.

IssuesandAdditionalRationale ........................................................................................30 6.1 WhatisEssential?

.....................................................................................................30 6.2 Networking ................................................................................................................30 6.3 Architecture-independentStructures .........................................................................30 6.4 SymbolicLinks ..........................................................................................................31 6.5 Staticallylinkedbinaries ...........................................................................................31