FilesystemHierarchyStandard—Draft2 FilesystemHierarchyStandardGroup editedbyDanielQuinlan ABSTRACT [ed:Replacethiswithanupdatedabstract] TheopenanddistributedprocessinwhichtheLinuxoperatingsystemhas developedfostersrapidgrowthoftheoperatingsystem,applications,andintegrated distributions.Yet,thereexistsaneedforstandardizationoftheLinuxfilesystem structure.Thisdocumentaimstospecifystandardlocationsoffilesanddirectoriesin Linuxsystems.Astandardfilesystemstructureallowsusers,developers,and distributorstoobtainsystemcomponentsfromvarioussourcesthatwillworktogether assmoothlyasiftheyhadbeendevelopedunderacentralizeddevelopmentprocess.It alsoeasessystemadministration,developmentofsecondandthirdpartypackages,and thewritingofimplementationindependentdocumentation. November4,1995 FilesystemHierarchyStandard November2,1995 Linuxisnotatrademark,andhasnoconnectiontoUNIX. UNIXisatrademarkoftheX/OpenCompany,Ltd. HP-UXisatrademarkofHewlett-Packard. NovellandNovellNetWarearetrademarksofNovell. SunOS,SunMicrosystems,SunNIS,SunRPC,andNFSaretrademarksofSunMicrosystems, Inc. SystemVandSVR4aretrademarksofAT&T. XWindowSystemisatrademarkofXConsortium,Inc. Allothercopyrightsareownedbytheirowners,unlessspecificallynotedotherwise.Useofaterm inthisdocumentshouldnotberegardedasaffectingthevalidityofanytrademarkorservice mark. Copyright◯c1994,1995DanielQuinlan Permissionisgrantedtomakeanddistributeverbatimcopiesofthisstandardprovidedthe copyrightandthispermissionnoticearepreservedonallcopies. Permissionisgrantedtocopyanddistributemodifiedversionsofthisstandardunderthe conditionsforverbatimcopying,providedalsothatthetitlepageislabeledasmodifiedincluding areferencetotheoriginalstandard,providedthatinformationonretrievingtheoriginalstandard isincluded,andprovidedthattheentireresultingderivedworkisdistributedunderthetermsofa permissionnoticeidenticaltothisone. -i-FilesystemHierarchyStandard November2,1995 1.Introduction 1.1StatusoftheStandard Thisproposedstandardiscurrentlybeingdistributedforreviewandcomment. Commentsonthisdraftarewelcomefromanyinterestedparty.Suggestionsforchangesin documentsshouldbeintheformofaproposedchangeoftext,togetherwithappropriate supportingcomments. Theguidelinesinthisdraftaresubjecttochange.Useofinformationcontainedinthisdocument isatyourownrisk. 1.2OrganizationoftheStandard Thisstandardisdividedinto6sections: 1.General,includingastatementofscope,problems,objectives,andconformance requirements. 2.TheFilesystem:astatementofsomeguidingprinciples. 3.TheRootDirectory. 4.The/usrHierarchy. 5.The/varHierarchy. 6.IssuesandAdditionalRationale. 1.3TypographicalConventions Courierfontisusedforthenamesoffilesanddirectories. Componentsoffilenamesthatvaryarerepresentedbyadescriptionofthecontentsenclosedin "<"and">"characters,<thus>.Electronicmailaddressesarealsoenclosedin"<"and">"but areshownintheusualtypeface. Optionalcomponentsoffilenamesareenclosedin"["and"]"charactersandmaybecombined withthe"<"and">"convention.Forexample,ifafileexistedwhichcouldbeeitherbefound eitherwithorwithoutanextension,itmightberepresentedby<filename>[.<extension>]. Variablesubstringsofdirectorynamesandfilenamesareindicatedby"*". -ii-FilesystemHierarchyStandard November2,1995 2.General 2.1Scope ThisdocumentspecifiesastandardfilesystemhierarchyforFHSfilesystemsbyspecifyingthe locationoffilesanddirectories,andthecontentsofsomesystemfiles. Thisstandardhasbeendesignedtobeusedbysystemintegrators,packagedevelopers,and systemadministratorstoconstructandmaintainaFHScompliantfilesystem.Itisprimarily intendedtobeareferenceandisnotatutorialonhowtomanageaconformantfilesystem hierarchy. Thesearesomeofthefundamentalproblemsthatoriginallymotivatedthisstandardizationeffort: •Therewasnosinglewell-acceptedLinuxdirectorystructure.Instead,thereweremany differentones,eachincompatiblewithoneanother. •Themostwidelyusedfilesystemhierarchieswerenotwell-structuredanddiffered gratuitouslyfrommoremoderndirectorystructure"standards"(suchasSystemV,BSD, SunOS,andothers). •ThefilesystemwasunfamiliaranddiscomfortingtoexperiencedUNIXusersand administratorswhohaveexperienceonmoremainstreamUNIXsystems. •ThelackofregularitywasalsoconfusingfornewcomerstoLinux,especiallythosecoming fromanon-UNIXbackground. •AnyincompatibilitiesbetweenprimaryLinuxdistributionsandothersoftwarepackageswere typicallysolvedbymethodsofalessthanappealingnature. •Overall,symboliclinkswereusedmuchtoooftenwithinthefilesystemtofixproblems. (However,therearetimeswhensymboliclinksneedtobeusedtoensurebackward compatibilityortoallowspecificsystemstohaveanindividualfilesystemstructure.) Differencesinopinionariseinanystandardizationeffort.Theneedforconsensusandcommon practicewithintheLinuxcommunityshouldovershadowthesedifferences. ThisfilesystemstandardwasprimarilydevelopedwithintheFHSmailinglistandpreviously,the FSSTNDchanneloftheLinux-activistsmailinglist.Inputandcommentswerereceivedfroma greatnumberofLinuxdevelopers,notedLinuxprogrammers,systemadministrators,andusers. Thosevolunteerswhohavecontributedextensivelytothisstandardarelistedattheendofthis document.Thisstandardrepresentstheconsensusviewofthoseandothercontributors. Thisstandardseekstoaddresstheseproblemsbydescribingawell-designedfilesystemstructure thatwehopetheLinuxcommunitywillvoluntarilyfollow.Althoughthisstandardismore comprehensiveandcompletethananyotherpreviousattemptatstandardization,itwillprobably neverbetrulyfinished.TheneedsoftheLinuxcommunitywillcontinuallychangeinrelationto emergingtechnology.Itisalsopossiblethatbettersolutionstotheproblemsweaddresswillbe discoveredorthatoursolutionswillnolongerbethebestpossiblesolutions.Forthesereasons, theFHSgroupplanstoreleasesupplementarydraftsinadditiontoperiodicupdatestothis document. CommentsrelatedtothisstandardarewelcomedbytheFHSgroup.Anycommentsor suggestionsforchangesshouldbedirectedtotheFHScoordinator,orifyouprefer,anyofthe listedcontributors.TypographicalorgrammaticalcommentsshouldbedirectedtotheFHS -1-FilesystemHierarchyStandard November2,1995 coordinator. ThereisalsoaFAQ,maintainedbyIanMcCloghrie,whichanswerssomeofthemorecommonly askedquestionsaboutthisstandard.IfyouwanttoimplementtheFHSorifyouhavesome questions,pleasereadtheFHSFAQfirst.ThisisavailableviaanonymousFTPattsx-11.mit.edu

in/pub/linux/docs/linux-standards/fsstnd/FSSTND-FAQ.

PleasedonotsendmailtothemailinglistwithoutfirstcontactingtheFHScoordinatororalisted contributor.Impropermessageswillnotbewell-receivedonthemailinglist. Questionsabouthowtointerpretitemsinthisdocumentmayoccasionallyarise.Ifyouhaveneed foraclarification,pleasecontacttheFHScoordinator.Sincethisstandardrepresentsthe consensusofmanyparticipants,itisimportanttomakecertainthatanyinterpretationalso representstheircollectiveopinion.Forthisreasonitmaynotbepossibletoprovideanimmediate responseunlesstheinquiryhasbeenthesubjectofpreviousdiscussion. TheFHScoordinatorisDanielQuinlan<Daniel.Quinlan@linux.org>. 2.2SpecificProblems Naturally,whilestandardizingtheLinuxfilesystemstructure,thereweresomespecificproblems thatwesoughttocorrect.Herearesomeofthemostobviousandmajorones: •Theprimarybinarydirectories,/binand/usr/bin,donothavewell-defineddivisions betweenthem.Asaresult,thedistributionofthebinariesbetweenthesetwodirectories variesgreatlybetweentheLinuxdistributions. •Includingbothbinariesandconfigurationfilesin/etcmakesthisdirectorymoreconfusing andmoredifficulttomaintain,bothforinexperiencedusersandforsystemadministrators (especiallythosewithlargesystems). •Thedivisionbetweenwhatisasite-wideconfigurationfileandwhatisamachine-local configurationfileisdifficulttoestablish. •Manycommonimplementationsof/usrcannotbemountedread-onlybecausetheycontain variablefilesanddirectoriesthatneedtobewrittento. •Inanetworkedenvironmentitisdesirabletoservesoftwaretoworkstationsviaanetworkbasedfilesystem.Suchfilesystemsmayneedtobemountedread-onlysothataccidentsor maliceononeworkstationcannotdamagethefilesontheserver.Thisrequiresidentification andseparationoffilesthatamachinemustwritetoandoffilesthatarespecifictoasingle machine. •CommonLinuxfilesystemstructuresweregenerallynotwell-suitedtonetworked installationswhichmayrequireread-onlycomponentswithinthefilesystem(primarilyinthe /usrhierarchy)orinvolvedisklessworkstations. Whilethesearesomeofthemajorproblemsweaddressed,therewerenumerousadditional problemsthatneededtobesolved.Thisstandardattemptstoaddressmanyofthoseother problems,buttheremaybesomethingthatwasoverlooked.Ifyouwishtobringsomethingto ourattention,pleasenotetherearesomethingsthathavebeendiscussedatlength,butwerenot includedinthisstandard. -2-FilesystemHierarchyStandard November2,1995 2.3Objectives Intryingtosolvetheproblemsabove,severalobjectiveswereidentifiedthatneededtobe achievedinadditiontothemoretechnicalmatters.Thesegoalscomprisethecorrectionof outstandingproblemsaswellasthevalidationofthisstandard. •Solvetheproblemslistedabovewhilelimitingtransitionaldifficultieswhilemovingaway fromtheformerde-factostandards. •Gainapprovalofdistributors,developers,andotherimportantpeopleintheLinux community,aswellasencouragingthemtogiveustheirsuggestions. •ProvideastandardthatthewholeLinuxcommunitywillchoosetofollowbecauseitsolves theproblemsaboveandprovidesthemostsensiblestructureforthefilesystemsofLinux installations. Someoftheseobjectiveshavealreadybeenfullyorpartiallymetduetothelimiteddistributionof anadvancedrafttoanydeveloperwhorequestedone. 2.4HistoryandProgress TheoriginalmessagethatmotivatedthisefforttorestructuretheLinuxfilesystemwaswrittenby OlafKirch<okir@monad.swb.de>onAugust2,1993,totheNORMALchanneloftheLinux activistsmailinglist. Soonthereafter,itwasdecidedthatthebestpossiblewaytoaccomplishthenecessary restructuringoftheLinuxfilesystemwouldbetocreateamailinglistforthepurposeof developingaconsensusstandard. Afteracomprehensivediscussion,withsurprisinglyfewflames,apreliminarydraftwaswritten. Withthehelpofseveraldedicatedpeople,thedraftwasfinishedandtheresultingdraftsubmitted totheFSSTNDchannelformorediscussion.Thefirstdraftwassubmittedtothechannelon September18,1993,byDanielQuinlan. AsthediscussioncontinuedandearlydraftsofFHSrecommendationsweredevelopedfurther, contactswereestablishedwithaccessibleLinuxdistributorswhothenofferedtheirinputand supporttooureffort.ManyLinuxdevelopersagreedthatthisstandardizationeffortwas worthwhileandsupportedit. 2.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. -3-FilesystemHierarchyStandard November2,1995 Animplementationisfullycompatiblewiththisstandardifeveryfileordirectorywhichit containscanbefoundbylookinginthelocationspecifiedhereandwillbefoundwiththecontents asspecifiedhere,evenifthatisnottheprimaryorphysicallocationofthefileordirectoryin question.Theimplementationmust,whenitattemptstofindanyfilesordirectorieswhichare notpartofit,dosointhelocationspecifiedinthisstandard,thoughitmayalsoattempttofind itinother(non-standard)locations. Animplementationispartiallycompliantorcompatibleifitcomplieswithoriscompatiblewitha significantsubsetofthisdocument.Partialcomplianceorcompatibilityisonlyintendedtoapply todistributionsandnottoseparateprograms.Thephrase"asignificantsubset"isadmittedly subjective,andinborderlinecases,theconcernedpartyshouldcontacttheFHScoordinator.Itis anticipatedthatsomevariationwillbetoleratedinborderlinecases. InordertoqualifyaspartiallyFHScompliantorpartiallyFHScompatibleanimplementation mustprovidealistofallplacesatwhichitandtheFHSdocumentdifferinadditiontoabrief explanationofthereasoningforthisdifference.Thislistshallbeprovidedwiththe implementationinquestion,andalsomadeavailabletotheFHSmailinglistortheFHS coordinator. Theterms"must","should","contains","is"andsoforthshouldbereadasrequirementsfor complianceorcompatibility. Notethatanimplementationdoesnotneedtocontainallthefilesanddirectoriesspecifiedinthis standardtobecompliantorcompatible.Itismerelynecessaryforthosefilesthatitdoescontain tobelocatedappropriately.Forexample,iftheext2filesystemisnotsupportedbyadistribution, theext2toolsneednotbeincluded,eventhoughtheyarementionedexplicitlyinthesectionon

/sbin.

Furthermore,certainportionsofthisdocumentareoptional.Inthiscasethiswillbestated explicitly,orindicatedwiththeuseofoneormoreof"may","recommend",or"suggest".Items markedasoptionalhavenobearingonthecomplianceorconformanceofanimplementation;they aresuggestionsmeanttoencouragecommonpractice,butmaybelocatedanywhereatthe implementor’schoice. -4-FilesystemHierarchyStandard November2,1995 3.TheFilesystem TheUNIXfilesystemischaracterizedby: •Ahierarchicalstructure •Consistenttreatmentoffiledata •Protectionoffiledata ThisstandardontheLinuxfilesystemfollowsthesamebasicprinciplesthatmostUNIX filesystemsfollow.Notethatthisstandarddoesnotattempttoagreeineverypossiblerespect withanyparticularUNIXsystem’simplementation.However,manyaspectsofthisstandardare basedonideasfoundinUNIXandotherUNIX-likesystems. Thisisaftercarefulconsiderationofotherfactors,including: •CommonandsoundpracticesintheLinuxcommunity •Theimplementationofotherfilesystemstructures •Applicablestandards Itispossibletodefinetwoorthogonalcategorizationsoffiles:shareablevs.unshareableand variablevs.static. Shareabledataisthatwhichcanbesharedbetweenseveraldifferentmachines;unshareableisthat whichmustbelocaltoaparticularmachine.Forexample,userhomedirectoriesareshareable data,butdevicelockfilesarenot. Staticdataincludesbinaries,libraries,documentation,andanythingthatdoesnotchangewithout systemadministratorintervention;variabledataisanythingelsethatdoeschangewithoutsystem administratorintervention. Throughoutthisdocument,andinanywell-plannedfilesystem,anunderstandingofthesebasic principleswillhelpguidethestructureandlenditadditionalconsistency. Thedistinctionbetweenshareableandunshareabledataisneededforseveralreasons: •Inanetworkedenvironment(i.e.,morethanonehostatasite),thereisagooddealofdata thatcanbesharedbetweendifferentmachinestosavespaceandeasethetaskof maintenance. •Inanetworkedenvironment,certainfilescontaininformationspecifictoasinglemachine. Thereforethesefilesystemscannotbeshared(withouttakingspecialmeasures). •Thede-factoimplementationofthefilesystemdidnotallowthe/usrhierarchytobe mountedread-onlybecauseitcontainedfilesanddirectoriesthatneedtobewrittento often.Thisisafactorthatmustbeaddressedwhenpartsof/usraresharedonanetwork ormountedread-onlybecauseofotherconsiderationssuchassecurity. The"shareable"distinctioncanbeusedtosupport,forexample: •A/usrpartition(orcomponentsof/usr)mounted(read-only)throughthenetwork(using NFS). -5-FilesystemHierarchyStandard November2,1995 •A/usrpartition(orcomponentsof/usr)mountedfromread-onlymedia.ACD-ROMcan beconsideredaread-onlyfilesystemsharedwithotherLinuxsystems,usingthemailsystem asanetwork. The"static"versus"variable"distinctionaffectsthefilesystemin2majorways: •Since/containsbothvariableandstaticdata,itneedstobemountedread-write. •Sincethetraditional/usrcontainsbothvariableandstaticdata,andsincewemaywantto mountitread-only(seeabove),itisnecessarytoprovideamethodtohave/usrmounted read-only.Thisisdonethroughthecreationofa/varhierarchythatismountedread-write (orisapartofanotherread-writepartition,suchas/),takingovermuchofthe/usr partition’straditionalfunctionality. Summarizingchartwithexamples: shareableunshareable static/usr/etc /home/boot variable/var/mail/var/run /var/spool/news/var/lock FilesystemHierarchyStandard November2,1995 4.TheRootDirectory Thissectiondescribestherootdirectorystructure.Thecontentsoftherootfilesystemshouldbe adequatetoboot,restore,recover,and/orrepairthesystem: •Tobootasystem,enoughmustbepresenttomount/usrandothernon-essentialpartsof thefilesystem.Thisincludesutilities,configuration,bootloaderinformation,andother essentialstart-updata. •Toenablerecoveryand/orrepairofasystem,thoseutilitiesneededbyanexperienced maintainertodiagnoseandreconstructadamagedsystemshouldbepresentontheroot filesystem. •Torestoreasystem,thoseutilitiesneededtorestorefromsystembackups(onfloppy,tape, etc.)shouldbepresentontherootfilesystem. Theprimaryconcernusedtobalancetheseconsiderations,whichfavorplacingmanythingsonthe rootfilesystem,isthegoalofkeepingrootassmallasreasonablypossible.Forseveralreasons,it isdesirabletokeeptherootfilesystemsmall: •Itisoftenmountedfromverysmallmedia.Forexample,manyLinuxusersinstalland recoversystemsbymountingrootoffaRAMdisk,whichiscopiedfromasingle1.44Mor 1.2Mfloppydisk. •Therootfilesystemhasmanysystem-specificconfigurationfilesinit.Possibleexamples includeakernelthatisspecifictothesystem,adifferenthostname,etc.Thismeansthat therootfilesystemisn’talwaysshareablebetweennetworkedsystems.Keepingitsmallon networkedsystemsminimizestheamountofspacelostonserverstounshareablefiles.It alsoallowsworkstationswithsmallerlocalharddrives. •Whileyoumayhavetherootfilesystemonalargepartition,andmaybeabletofillitto yourheart’scontent,therewillbepeoplewithsmallerpartitions.Ifyouhavemorefiles installed,youmayfindincompatibilitieswithothersystemsusingrootfilesystemsonsmaller partitions.Ifyouareadeveloperthenyoumaybeturningyourassumptionintoaproblem foralargenumberofusers. •Diskerrorsthatcorruptdataontherootfilesystemareagreaterproblemthanerrorson anyotherpartition.Asmallrootfilesystemislesspronetocorruptionastheresultofa systemcrash. Softwareshouldnevercreateorrequirespecialfilesorsubdirectoriesintherootdirectory.The Linuxfilesystemstructureprovidesmorethanenoughflexibilityforanypackage.Anypackage thatdoesoccupyadirectoryundertherootofthefilesystemsuffersfromsheerarrogance. -7-FilesystemHierarchyStandard November2,1995 /—therootdirectory

bin

Essentialcommandbinaries

boot

Staticfilesofthebootloader

dev

Devicefiles

etc

Machine-localsystemconfiguration

home

Userhomedirectories

lib

Sharedlibraries

mnt

Mountpointoftemporarypartitions

proc

Processinformationpseudo-filesystem

root

Homedirectoryfortherootuser

sbin

Essentialsystembinaries

tmp

Temporaryfiles

usr

Secondaryhierarchy

var

Variabledata Eachdirectorylistedaboveisspecifiedindetailinseparatesubsectionsbelow./usrand/var eachhaveacompletesectioninthisdocumentduetothecomplexityofthosedirectories. Theoperatingsystemkernelimageshouldbelocatedineither/or/boot.Additional informationonkernelplacementcanbefoundinthesectionregarding/boot,below. OnLinuxsystems,ifthekernelislocatedin/,werecommendusingthenamevmlinuxor vmlinuzwhichhavebeenusedinrecentLinuxkernelsourcepackages. 4.1/bin:Essentialusercommandbinaries(forusebyallusers) /bincontainscommandsthatmaybeusedbyboththesystemadministratorandbyusers,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.)arenotessentialenoughto beplacedintotherootpartition. Requiredfilesfor/bin: •Generalcommands: Thefollowingcommandshavebeenincludedbecausetheyareessential.Afewarepresent becauseoftheirtraditionalplacementin/bin.

{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}

-8-FilesystemHierarchyStandard November2,1995 If/bin/shisBash,then/bin/shshouldbeasymbolicorhardlinkto/bin/bashsince Bashbehavesdifferentlywhencalledasshorbash.pdksh,whichmaybethe/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./bin/cshmaybeasymboliclinkto/bin/tcshor/usr/bin/tcsh.

The[andtestcommandsarebuiltintoBash,pdksh,zsh,andrecentKornshells— essentiallyeveryBourneshellreplacementthereisforLinux.Thesecommandsshouldbe placedinto/usr/bin.(TheymustbeincludedasseparatebinarieswithanyLinuxsystem attemptingtocomplywiththePOSIX.2standard.) •Restorationcommands: Thesecommandshavebeenaddedtomakerestorationofasystempossible(providedthat/ isintact). {tar,gzip,gunzip(linktogzip),zcat(linktogzip)} Ifsystembackupsaremadeusingprogramsotherthangzipandtar,thentheroot partitionshouldcontaintheminimalnecessaryrestorationcomponents.Forinstance,many systemsshouldincludecpioasitisthenextmostcommonlyusedbackuputilityaftertar. Conversely,ifnorestorationfromtherootpartitioniseverexpected,thenthesebinaries maybeomitted(i.e.,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}

4.2/boot:Staticfilesofthebootloader Thisdirectorycontainseverythingrequiredforthebootprocessexceptconfigurationfilesandthe mapinstaller.Inthesimplestsense,/bootisforanythingwhichisusedbeforethekernelexecs /sbin/init.Thisincludessavedmasterbootsectors,sectormapfiles,andanythingelsethatis notdirectlyeditedbyhand.Programsnecessarytoarrangeforthebootloadertobeabletoboot afileshouldbeplacedin/sbin.Configurationfilesforbootloadersshouldbeplacedin/etc. TheLinuxkernelshouldeitherbelocatedin/orin/boot. Note:Onsomei386machines,itmaybenecessaryfor/boottobelocatedonaseparatepartition belowcylinder1024ofthebootdeviceduetohardwareconstraints. -9-FilesystemHierarchyStandard November2,1995 4.3/dev:Devicefiles The/devdirectoryisthelocationofspecialordevicefiles. Ifitispossiblethatdevicesin/devwillneedtobemanuallycreated,/devshallcontaina commandnamedMAKEDEV,whichcancreatedevicesasneeded.Itmayalsocontaina MAKEDEV.localforanylocaldevices. Ifrequired,MAKEDEVshouldhaveprovisionsforcreatinganydevicethatmaybefoundonthe system,notjustthosethataparticularimplementationinstalls. Symboliclinksin/devshouldnotbedistributedwithLinuxsystemsexceptasprovidedinthe Linuxdevicelist.Thisisbecauselocalsetupswilloftendifferfromthatonthedistributor’s developmentmachine.Also,ifadistributioninstallscriptconfiguresthesymboliclinksatinstall time,thesesymlinkswilloftennotgetupdatediflocalchangesaremadeinhardware.Whenused responsiblyatalocallevel,however,theycanbeputtogooduse. ThisstandardincorporatesbyreferencetheLinuxDeviceListwhichismaintainedbyH.Peter Anvin<Peter.Anvin@linux.org>,theLinuxDeviceRegistrar.Alldevicespecialfilesshould followthestandardinthatdocument,whichisavailableviaanonymousftpatftp.yggdrasil.comin

/pub/device-list.

4.4/etc:Machine-localsystemconfiguration /etccontainsconfigurationfilesanddirectories,whicharelocaltothecurrentsystem. Nobinariesshouldgodirectlyinto/etc.Binariesthatmightinthepasthavebeenfoundin/etc shouldbeplacedin/sbinor/usr/sbin.Thisincludessuchfilesasinit,getty,andupdate. Binariessuchashostnamethatareusedbyordinaryusersaswellastherootusershouldnotbe placedin/sbinbutin/bin. /etc—Machine-localsystemconfiguration

X11

ConfigurationfortheXWindowSystem /etc/X11istherecommendedlocationforallX11machine-localconfiguration.Thisdirectoryis necessarytoallowlocalcontrolif/usrismountedreadonly.Filesthatshouldbeinthis directoryincludeXconfig(and/orXF86Config)andXmodmap. Subdirectoriesof/etc/X11mayincludethoseforxdmandforanyotherprograms(somewindow managers,forexample)thatneedthem.Werecommendthatwindowmanagerswithonlyone configurationfilewhichisadefault.*wmrcfileshouldnameitsystem.*wmrc(unlessthereisa widely-acceptedalternativename)andnotuseasubdirectory.Anywindowmanager subdirectoriesshouldbeidenticallynamedtotheactualwindowmanagerbinary. /etc/X11/xdmholdstheconfigurationfilesforxdm.Thesearemostofthefilesnormallyfoundin /usr/lib/X11/xdm;seeSection6,/var/state/xdm,formoreinformation. Thefollowingsectionisintendedpartlytoilluminatethedescriptionofthecontentsof/etcwith anumberofexamples;itisdefinitelynotanexhaustivelist. -10-FilesystemHierarchyStandard November2,1995 Requiredfilesfor/etc: •Generalfiles: ThesefilesareneededonmostLinuxsystems.

{adjtime,csh.login,disktab,fdprm,fstab,gettydefs,group,inittab,
issue,ld.so.conf,lilo.conf,motd,mtab,mtools,passwd,profile,
psdatabase,securetty,shells,syslog.conf,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. Systemsthatusetheshadowpasswordsuitewillhaveadditionalconfigurationfilesin/etc

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

4.5/home:Userhomedirectories(optional) /homeisafairlystandardconcept,butitisclearlyasite-specificfilesystem.Thesetupwilldiffer frommachinetomachine.Thissectiondescribesonlyasuggestedplacementforuserhome directories;neverthelesswerecommendthatallLinuxdistributionsusethisasthedefaultlocation forhomedirectories. Onsmallsystems,eachuser’sdirectoryistypicallyoneofthemanysubdirectoriesof/homesuch

as/home/smith,/home/torvalds,/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. 4.6/lib:Essentialsharedlibrariesandkernelmodules The/libdirectorycontainsthosesharedlibraryimagesneededtobootthesystemandrunthe commandsintherootfilesystem. -11-FilesystemHierarchyStandard November2,1995 /lib—essentialsharedlibrariesandkernelmodules

modules

Loadablekernelmodules Thisincludes/lib/libc.so.*,/lib/libm.so.*,theshareddynamiclinker/lib/ld.so,and othersharedlibrariesrequiredbybinariesin/binand/sbin. 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.) Thespecificationfor/lib/modulesisforthcoming. 4.7/mnt:Mountpointfortemporarilymountedfilesystems Thisdirectoryisprovidedsothatthesystemadministratormaytemporarilymountfilesystemsas needed.Thecontentofthisdirectoryisalocalissueandshouldnotaffectthemannerinwhich anyprogramisrun. Werecommendagainsttheuseofthisdirectorybyinstallationprograms,andsuggestthata suitabletemporarydirectorynotinusebythesystemshouldbeusedinstead. 4.8/proc:Kernelandprocessinformationvirtualfilesystem Theprocfilesystemisbecomingthede-factostandardLinuxmethodforhandlingprocessand systeminformation,ratherthan/dev/kmemandothersimilarmethods.Westronglyencourage thisforthestorageandretrievalofprocessinformationaswellasotherkernelandmemory information. 4.9/root:Homedirectoryfortherootuser(optional) /istraditionallythehomedirectoryoftherootaccountonUNIXsystems./rootisusedon manyLinuxsystemsandonsomeUNIXsystems.Therootaccount’shomedirectorymaybe determinedbydeveloperorlocalpreference.Obviouspossibilitiesinclude/,/root,and

/home/root.

Ifroot’shomedirectoryisnotstoredontherootpartitionitwillbenecessarytomakecertainit willdefaultto/ifitcannotbelocated. Note:werecommendagainstusingtherootaccountformundanethingssuchasmailandnews, butrathertouseitsolelyforsystemadministration.Forthisreason,werecommendthat subdirectoriessuchasMailandNewsnotappearintherootaccount’shomedirectory.We recommendthatmailforrootandpostmasterbeforwardedtoamoreappropriateuser. -12-FilesystemHierarchyStandard November2,1995 4.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}

•Shutdowncommands:

{fastboot,fasthalt,halt,reboot,shutdown}

(Oranycombinationoftheabove,solongasshutdownisincluded.) •Filesystemmanagementcommands:

{fdisk,fsck,fsck.*,mkfs,mkfs.*}

*=oneormoreofext,ext2,minix,msdos,xiaandperhapsothers •Secondextendedfilesystemcommands(optional):

{badblocks,dumpe2fs,e2fsck,mke2fs,mklost+found,tune2fs}

•Boot-loadermapinstaller:

{lilo}

-13-FilesystemHierarchyStandard November2,1995 •Networkingcommands:

{ifconfig,route}

Optionalfilesfor/sbin: •Staticbinaries:

{ldconfig,sln,ssync}

Staticln(sln)andstaticsync(ssync)areusefulwhenthingsgowrong.Theprimaryuse ofsln(torepairincorrectsymlinksin/libafterapoorlyorchestratedupgrade)isnolonger amajorconcernnowthattheldconfigprogram(usuallylocatedin/usr/sbin)existsand canactasaguidinghandinupgradingthedynamiclibraries.Staticsyncisusefulinsome emergencysituations.Notethattheseneednotbestaticallycompiledversionsofthe standardlnandsync,butmaybe. Theldconfigbinaryisoptionalfor/sbinsinceasitemaychoosetorunldconfigatboot time,ratherthanonlywhenupgradingthesharedlibraries.(It’snotclearwhetherornotit isadvantageoustorunldconfigoneachboot.)Evenso,somepeoplelikeldconfig aroundforthefollowing(alltoocommon)situation: (1)I’vejustremoved/lib/<file>. (2)Ican’tfindoutthenameofthelibrarybecauselsisdynamicallylinked,I’musing ashellthatdoesn’thavelsbuilt-in,andIdon’tknowaboutusing"echo*"asa replacement. (3)Ihaveastaticsln,butIdon’tknowwhattocallthelink. •Miscellaneous:

{ctrlaltdel,kbdrate}

Soastocopewiththefactthatsomekeyboardscomeupwithsuchahighrepeatrateasto beunusable,kbdratemaybeinstalledin/sbinonsomesystems. SincethedefaultactioninthekernelfortheCtrl-Alt-Delkeycombinationisaninstanthard reboot,itisgenerallyadvisabletodisablethebehaviorbeforemountingtherootfilesystem inread-writemode.SomeinitsuitesareabletodisableCtrl-Alt-Del,butothersmay requirethectrlaltdelprogram,whichmaybeinstalledin/sbinonthosesystems. 4.11/tmp:Temporaryfiles The/tmpdirectoryshallbemadeavailableforprogramsthatrequiretemporaryfiles. Althoughdatastoredin/tmpmaybedeletedinasite-specificmanner,itisrecommendedthat filesanddirectorieslocatedin/tmpbedeletedwheneverthesystemisbooted. Programsshallnotassumethatanyfilesordirectoriesin/tmparepreservedbetweeninvocations oftheprogram. -14-FilesystemHierarchyStandard November2,1995 BEGINRATIONALE IEEEstandardP1003.2(POSIX,part2)makesrequirementsthataresimilartotheabovesection. FHSaddedtherecommendationthat/tmpbecleanedatboottimeonthebasisofhistorical precedentandcommonpractice,butdidnotmakeitarequirementbecausesystemadministration isnotwithinthescopeofthisstandard. ENDRATIONALE FilesystemHierarchyStandard November2,1995 5.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.AnexceptionismadefortheXWindowSystembecauseof considerableprecedentandwidely-acceptedpractice. /usr—SecondaryHierarchy

X11R6

XWindowSystem,version11release6

X386

XWindowSystem,version11release5onx86platforms

bin

Mostusercommands

games

Gamesandeducationalbinaries

include

HeaderfilesincludedbyCprograms

lib

Libraries

local

Localhierarchy(emptyaftermaininstallation)

sbin

Non-vitalsystemadministrationbinaries

share

Architecture-independentdata

src

Sourcecode Thefollowingsymboliclinkstodirectoriesmaybepresent.Thispossibilityisbasedontheneedto preservecompatibilitywitholdersystemsuntilallimplementationscanbeassumedtousethe /varhierarchy.

/var/spool/usr/tmp->/var/tmp/usr/spool/locks->/var/lock
/usr/adm->/var/log
/usr/preserve->/var/state/elvis
/usr/spool->/var/spool
/usr/tmp->/var/tmp
/usr/spool/locks->/var/lock

Onceasystemnolongerrequiresanyoneoftheabovesymboliclinks,thelinkmayberemoved,if desired.Notably,ittakeslittleefforttocompletelyremove/usr/preservesinceonlyelvisuses it. -16-FilesystemHierarchyStandard November2,1995 5.1/usr/X11R6:XWindowSystem,Version11Release6 ThishierarchyisreservedfortheXWindowSystem,version11release 6,andrelatedfiles. /usr/X11R6—XWindowSystem(version11release6)

bin
doc
include
lib
man

TosimplifymattersandmakeXFree86morecompatiblewiththeXWindowSystemonother systems,thefollowingsymboliclinksshouldbepresent:

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

Ingeneral,softwareshouldnotbeinstalledormanagedviatheabovesymboliclinks.Theyare intendedforutilizationbyusersonly.ThedifficultyisrelatedtothereleaseversionoftheX WindowSystem—intransitionalperiods,itisimpossibletoknowwhatreleaseofX11isinuse. Forthesamereason,thereshouldnotbeasymboliclinkfrom/usr/X11pointingtothecurrentX WindowSystemhierarchy. 5.2/usr/X386:XWindowSystem,Version11Release5,onx86 platforms Thishierarchyisgenerallyidenticalto/usr/X11R6,exceptthatthe/usrsymboliclinksshouldbe absentif/usr/X11R6isinstalled. 5.3/usr/bin:Mostusercommands Thisistheprimarydirectoryofexecutablecommandsonthesystem. /usr/bin—Binariesthatarenotneededinsingle-usermode

mh

CommandsfortheMHmailhandlingsystem

X11

Symlinkto/usr/X11R6/bin

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. -17-FilesystemHierarchyStandard November2,1995 5.4/usr/include:Directoryforstandardincludefiles. Thisiswhereallofthesystem’sgeneral-useincludefilesfortheC andC++programminglanguagesshouldbeplaced. /usr/include—Includefiles

X11

Symlinkto/usr/X11R6/include/X11
arpa

ARPAnetdefinedprotocoldefinitions

asm

Symlinkto/usr/src/linux/include/asm-<arch>
bsd

BSDcompatibilityincludefiles

g++

GNUC++includefiles

gnu

GNUincludefiles

linux

Symlinkto/usr/src/linux/include/linux
net

Genericnetwork-relateddefinitions

netax25

+AX25(ARRLAX.25)specificdefinitions

netinet

TCP/IPspecificdefinitions

netipx

+IPX(NovellIPX/SPX)specificdefinitions

protocols

Protocoldefinitions(mostlyINET-based)

readline

TheGNUreadlinelibrary

rpc

SunMicrosystemsRPCdefinitions

rpcsvc

SunMicrosystemsRPCservicedefinitions

sys

Systemgenerationincludefiles ThearpasubdirectorycontainsprotocolheaderdefinitionsfortheARPAnetprotocols,TCP/IP conversionfunctions,definitionsforftp,telnetprototypes,andsimilarmaterial. Thenetsubdirectorycontainsgenericnetwork-relateddefinitions.Itdefinesthesystemkernel interface,protocolfamilydetails,etc. ThenetinetsubdirectorycontainsINET(DARPAInternet,whichisalsoknownasTCP/IP) specificdefinitions. ARRLAX.25isbetterknownaspacketradio.TheNovellIPX/SPXprotocolsarepartofthe NovellNetWarefileservices. 5.5/usr/lib:Librariesforprogramming /usr/libisintendedforobjectfilesandlibraries. Historically,/usr/libhasalsoincludedcompilerprogrambinariesandstaticdataofvarious kinds—bothexecutablecode(forexample,GCC’sinternalbinariesmaybelocatedunder /usr/lib/gcc-lib)andothertypesofdata. Miscellaneousapplication-specificstaticfilesandsubdirectoriesshouldbeplacedin/usr/share, andapplication-specificbinariesin/usr/libexec(forinternalbinaries),/usr/bin(foruser commands),or/usr/sbin(forsystemcommands).However,distributorsmayplaceapplicationspecificstaticdataandbinariesinsubdirectoriesof/usr/libinstead,attheirdiscretion.Such application-specificdirectoriesmightinclude,forexample,emacs,gcc-lib,mf,news,smail,

texmf,oruucp.

-18-FilesystemHierarchyStandard November2,1995 Someexecutablecommandssuchasmakewhatisandsendmailhavealsobeentraditionallyplaced in/usr/lib.makewhatisisaninternalbinaryandshouldbeplacedinabinarydirectory;users accessonlycatman.Newersendmailbinariesarenowplacedbydefaultin/usr/sbin;asymbolic linkshouldremainfrom/usr/lib.Additionally,systemsusingSmailshouldplaceSmailin

/usr/sbin/smail,and/usr/sbin/sendmailshouldbeasymboliclinktoit.

Asymboliclink/usr/lib/X11pointingtothelib/X11directoryofthedefaultXdistributionis requiredifXisinstalled.Note:Nohost-specificdatafortheXWindowSystemshouldbestored in/usr/lib/X11.Host-specificconfigurationfilessuchasXconfigorXF86Configshouldbe storedin/etc/X11.Thisshouldincludeconfigurationdatasuchassystem.twmrcevenifitis onlymadeasymboliclinktoamoreglobalconfigurationfile(probablyin/usr/X11R6/lib/X11). 5.6/usr/libexec:Internalbinaries /usr/libexecisintendedtoholdinternalbinaries,i.e.,binariesthatarenotrunfromthe commandline.Typicalexamplesincludeinternetdaemonsstartedbyinetd;initbinaries,such asgetty;compilerbinaries,suchascc1;andanyothercomponentexecutablethatdoeslittleor nothingwhenrunfromthecommandline. Notethatwhile,forBSDsystems,ld.somaybeplacedhere,it(alongwithld-linux.so)must beplacedin/libunderLinuxtoaccommodatedynamicallylinkedprogramsin/binand/sbin. Subdirectoriesmaybecreatedunder/usr/libexecasdesiredbyapplications.Examplesinclude uucp(forUUCPinternalbinaries)andlpr(forprinterdaemonfilterprograms). Nospecificprogramsmustbeplacedhere,butitisrecommendedthatanybinariesin/usr/lib and/usr/sbinthatmeetthecriterionabovebemovedtothisdirectory. BEGINRATIONALE TheconceptofalibexecdirectorywasintroducedintheNet/2distributionoftheBSD operatingsystem.Itwascreatedtoremoveexecutablesthatweren’tintentedtobeexecuted directlybyusers,fromthestandardexecutionpath. AsimilarconcepthasbeenusedinotherUNIXoperatingsystems,suchasOSF/1,whichnames thisdirectory/usr/lbin.Thename/usr/lbinwasnotchosenbecauseitwasfirstusedforlocal binaries(ratherthaninternalbinaries)inSystemIII.Wealsofeltthat/usr/lbinwouldbemore easilymistakenforadirectorythatwasmeanttobeplacedinauser’sexecutionpath. ENDRATIONALE -19-FilesystemHierarchyStandard November2,1995 5.7/usr/local:Localhierarchy The/usr/localhierarchyisforusebythesystemadministrator wheninstallingsoftwarelocally.Itneedstobesafefrombeing overwrittenwhenthesystemsoftwareisupdated.Itmaybeusedfor programsanddatathatareshareableamongstagroupofmachines,but notfoundin/usr. /usr/local—Localhierarchy

bin

Local-onlybinaries

doc

Localdocumentation

etc

Configurationforlocal-onlybinaries

games

Locallyinstalledgames

lib

Librariesfor/usr/local

info

Localinfopages

man

Manpagehierarchyfor/usr/local

share

Localarchitechure-independenthierarchy

src

Localsourcecode ThisdirectoryshouldalwaysbeemptyafterfirstinstallingLinux.Noexceptionstothisrule shouldbemadeotherthanthelisteddirectorystubs. Locallyinstalledsoftwareshouldbeplacedwithin/usr/localratherthan/usrunlessitisbeing installedtoreplaceorupgradesoftwarein/usr. Notethatsoftwareplacedin/or/usrmaybeoverwrittenbysystemupgrades(thoughwe recommendthatdistributionsdonotoverwritedatain/etcunderthesecircumstances).Forthis reason,localsoftwareshouldnotbeplacedoutsideof/usr/localwithoutgoodreason. 5.8/usr/sbin:Non-essentialstandardsystembinaries Thisdirectorycontainsanynon-essentialbinariesusedexclusivelybythesystemadministrator. Systemadministrationprogramsthatarerequiredforsystemrepair,systemrecovery,mounting /usr,orotheressentialfunctionsshouldbeplacedin/sbininstead. Typically,/usr/sbincontainsnetworkingdaemons,anynon-essentialadministrationtools,and binariesfornon-criticalserverprograms.Thisincludesinternetdaemonscalledbyinetd(named in.*)likein.telnetdandin.fingerdandrpc-baseddaemons(namedrpc.*)likerpc.nfsdand

rpc.mountd.

TheseserverprogramsareusedwhenenteringtheSystemVstatesknownas"runlevel2"(multiuserstate)and"runlevel3"(networkedstate)ortheBSDstateknownas"multi-usermode".At thispointthesystemismakingservicesavailabletousers(e.g.,printersupport)andtoother machines(e.g.,NFSexports). Locallyinstalledsystemadministrationprogramsshouldbeplacedin/usr/local/sbin. -20-FilesystemHierarchyStandard November2,1995 5.9/usr/share:Architecture-independentdata /usr/share—Architecture-independentdata

dict

Wordlists

doc

Miscellaneousdocumentation

games

Staticdatafilesfor/usr/games

info

GNUInfosystem’sprimarydirectory

locale

Localeinformation

man

Onlinemanuals

nls

Nativelanguagesupport

misc

Miscellaneousarchitecture-independentdata

terminfo

Directoriesforterminfodatabase

tmac

troffmacrosnotdistributedwithgroff

zoneinfo

Timezoneinformationandconfiguration The/usr/sharehierarchyisforallread-onlyarchitectureindependentdatafiles.Muchofthis dataoriginallylivedin/usr(man,doc)or/usr/lib(dict,terminfo,zoneinfo).Thishierarchy isintendedtobeshareableamongallarchitectureplatformsofagivenOS;thus,forexample,a sitewithi386,Alpha,andPPCplatformsmightmaintainasingle/usr/sharedirectorythatis centrally-mounted.Note,however,that/usr/shareisgenerallynotintendedtobesharedby differentOSesorbydifferentreleasesofthesameOS. Anyprogramorpackagewhichcontainsorrequiresdatathatdoesn’tneedtobemodifiedshould storethatdatain/usr/share(or/usr/local/share,ifinstalledlocally).Itisrecommended thatasubdirectorybeusedin/usr/shareforthispurpose. NotethatLinuxcurrentlyusesDBM-formatdatabasefiles.Whilethesearenotarchitecture-independent,theyareallowedin/usr/shareasashort-termmeasurependingananticipated switchtotheDB2.0format.TheDBdatabaseusesanarchitectureindependentformat,andthe 2.0releaseshouldbeavailableinfallof1995. Gamedatastoredin/usr/lib/gamesshouldbepurelystaticdata.Anymodifiablefiles,suchas scorefiles,gameplaylogs,andsoforth,shouldbeplacedin/var/games. Itisrecommendedthatapplication-specific,architecture-independentdirectoriesbeplacedhere. Suchdirectoriesincludegroff,perl,ghostscript,texmf,andkbd(Linux)orsyscons(BSD). Theymay,however,beplacedin/usr/libforbackwardscompatibility,atthedistributor’s discretion.Similarly,a/usr/lib/gameshierarchymaybeusedinadditiontothe /usr/share/gameshierarchyifthedistributorwishestoplacesomegamedatathere. 5.9.1/usr/share/dict:Wordlists Recommendedfilesfor/usr/share/dict:

{words}

TraditionallythisdirectorycontainsonlytheEnglishwordsfile,whichisusedbylook(1)and variousspellingprograms.wordsmayuseeitherAmericanorBritishspelling.Sitesthatrequire -21-FilesystemHierarchyStandard November2,1995

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

WordlistsforotherlanguagesmaybeaddedusingtheEnglishnameforthatlanguage,e.g.,

/usr/share/dict/french,/usr/share/dict/danish,etc.Theseshould,ifpossible,useanISO

8859charactersetwhichisappropriateforthelanguageinquestion;ifpossibletheLatin1(ISO 8859-1)charactersetshouldbeused(thisisoftennotpossible). Otherwordlists,suchastheweb2"dictionary"shouldbeincludedhere,ifpresent. BEGINRATIONALE Thereasonthatonlywordlistsarelocatedhereisthattheyaretheonlyfilescommontoallspell checkers. ENDRATIONALE 5.9.2/usr/share/man:Manualpages Thissectiondetailstheorganizationformanualpagesthroughoutthesystem,including

/usr/share/man.
Manualpagesarestoredin<mandir>/<locale>/man[1-9]/<arch>.
Anexplanationof<mandir>,<locale>,and<arch>

isgivenbelow. <mandir>/<locale>—Amanualpagehierarchy

man1

Userprograms

man2

Systemcalls

man3

Libraryfunctionsandsubroutines

man4

Devices

man5

Fileformats

man6

Games

man7

Miscellaneous

man8

Systemadministration

man9

Kernelinternalvariablesandfunctions Theprimary<mandir>ofthesystemis/usr/share/man./usr/share/mancontainsmanual informationforcommandsanddataunderthe/and/usrfilesystems.Obviously,thereareno manualpagesin/becausetheyarenotrequiredatboottimenoraretheyrequiredin emergencies. Provisionsmustbemadeinthestructureof/usr/share/mantosupportmanualpageswhichare writtenindifferent(ormultiple)languages.Theseprovisionsmusttakeintoaccountthestorage andreferenceofthesemanualpages.Relevantfactorsincludelanguage(includinggeographicalbaseddifferences),andcharactercodeset. Thisnamingoflanguagesubdirectoriesof/usr/share/manisbasedonAppendixEofthePOSIX 1003.1standardwhichdescribesthelocaleidentificationstring—themostwell-acceptedmethod todescribeaculturalenvironment.The<locale>stringis: -22-FilesystemHierarchyStandard November2,1995

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

The<language>fieldshallbetakenfromISO639(acodefortherepresentationofnamesof languages).Itshallbetwocharacterswideandspecifiedwithlowercaselettersonly. The<territory>fieldshallbethetwo-lettercodeofISO3166(aspecificationofrepresentations ofcountries),ifpossible.(Mostpeoplearefamiliarwiththetwo-lettercodesusedforthecountry codesinemailaddresses.1)Itshallbetwocharacterswideandspecifiedwithuppercaseletters only. The<character-set>fieldshouldrepresentthestandarddescribingthecharacterset.Ifthe <character-set>fieldisjustanumericspecification,thenumberrepresentsthenumberofthe internationalstandarddescribingthecharacterset.Itisrecommendedthatthisbeanumeric representationifpossible(ISOstandards,especially),notincludeadditionalpunctuationsymbols, 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/share/man.(Thatisthetraditionalcircumstanceandarrangement,infact.) Countriesforwhichthereisawell-acceptedstandardcharactercodesetmayomitthe <character-set>field,butitisstronglyrecommendedthatitbeincluded,especiallyfor countrieswithseveral"competing"standards. Variousexamples: LanguageTerritoryCharacterSetDirectory

English—ASCII/usr/share/man/en

EnglishUnitedKingdomASCII/usr/share/man/en_GB EnglishUnitedStatesASCII/usr/share/man/en_US FrenchCanadaISO8859-1/usr/share/man/fr_CA FrenchFranceISO8859-1/usr/share/man/fr_FR

GermanGermanyISO646/usr/share/man/de_DE.646
GermanGermanyISO6937/usr/share/man/de_DE.6937
GermanGermanyISO8859-1/usr/share/man/de_DE.88591
GermanSwitzerlandISO646/usr/share/man/de_CH.646
JapaneseJapanJIS/usr/share/man/ja_JP.jis
JapaneseJapanSJIS/usr/share/man/ja_JP.sjis

JapaneseJapanUJIS(orEUC-J)/usr/share/man/ja_JP.ujis Similarly,provisionmustbemadeformanualpageswhicharearchitecture-dependent,suchas 1.

AmajorexceptiontothisruleistheUnitedKingdom,whichis‘GB’intheISO3166,but‘UK’formostemail addresses. -23-FilesystemHierarchyStandard November2,1995 device-driverdocumentationorlow-levelsystemadministrationcommands.Theseshouldbe placedunderan<arch>directoryintheappropriateman[1-9]directory;forexample,amanpage forthei386ctrlaltdel(8)commandmightbeplacedin

/usr/share/man/<locale>/man8/i386/ctlaltdel.8.

Manualpagesforcommandsanddataunder/usr/localarestoredin/usr/local/man.Manual pagesfortheXWindowSystemarestoredin/usr/X11R6/man.Itfollowsthatallmanualpage hierarchiesinthesystemshouldhavethesamestructureas/usr/share/man.Emptydirectories maybeomittedfromamanualpagehierarchy.Forexample,if/usr/local/manhasnomanual pagesinsection4(Devices),then/usr/local/man/man4maybeomitted. Thecatpagesections(cat[1-9])containingformattedmanualpageentriesarealsofoundwithin subdirectoriesof<mandir>/<locale>,butarenotrequirednorshouldtheybedistributedinlieu ofnroffsourcemanualpages. TheMHmailhandlingsystemmanualpagesshouldhavemhappendedtoallmanualpage filenames.AllXWindowSystemmanualpagesshouldhaveanxappendedtothefilename. Thepracticeofplacingvariouslanguagemanualpagesinappropriatesubdirectoriesof /usr/share/manalsoappliestotheothermanualpagehierarchies,suchas/usr/local/manand /usr/X11R6/man.(Thisportionofthestandardalsoapplieslaterinthesectionontheoptional

/var/spool/manstructure.)

Adescriptionofeachsectionfollows: •man1:Userprograms Manualpagesthatdescribepubliclyaccessiblecommandsarecontainedinthischapter. Mostprogramdocumentationthatauserwillneedtouseislocatedhere. •man2:Systemcalls Thissectiondescribesallofthesystemcalls(requestsforthekerneltoperformoperations). •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 -24-FilesystemHierarchyStandard November2,1995 maintenancearedocumentedhere.Someoftheseprogramsarealsooccasionallyusefulfor normalusers. •man9:Kernelinternalvariablesandfunctions Thisisusedonsystemsthatdocumentthekernelsourcecode. 5.9.3/usr/share/misc:Miscellaneousarchitecture-independentdata Thisdirectorycontainsmiscellaneousarchitecture-independentfileswhichdon’trequireaseparate subdirectoryunder/usr/share.Itisarequireddirectoryunder/usr/share. Thefollowingfiles,ifpresent,shouldbelocatedunder/usr/share/misc:

{ascii,magic,termcap,termcap.db}

Other(application-specific)filesmayappearhere,butadistributormayplacethemin/usr/lib attheirdiscretion.Somesuchfilesinclude:

{airport,birthtoken,eqnchar,getopt,gprof.callg,gprof.flat,inter.phone,
ipfw.samp.filters,ipfw.samp.scripts,keycap.pcvt,mail.help,mail.tildehelp,
man.template,map3270,mdoc.template,more.help,na.phone,nslookup.help,
operator,scsi_modes,sendmail.hf,style,units.lib,vgrindefs,vgrindefs.db,
zipcodes}

5.10/usr/src:Sourcecode /usr/src—Sourcecode

linux

SourcecodeforLinuxkernel Anynon-localsourcecodeshouldbeplacedinthissubdirectory.Theonlysourcecodethat shouldalwaysbeplacedinaspecificlocationisthekernelsource(whenpresentorlinkedinpart tothe/usr/includestructure).Subdirectoriesmaybeusedhereifdesired. Thesourcecodeforthekernelshouldalwaysbeinplaceoratleasttheincludefilesfromthe kernelsource.Thosefilesarelocatedinthesedirectories:

/usr/src/linux/include/asm-<arch>
/usr/src/linux/include/linux

/usr/includeshouldcontainlinkstothesedirectories,namedasmandlinux.Sincetheyare neededbytheCcompiler,atleastthoseincludefilesshouldalwaysbedistributedwith installationswhichincludeaCcompiler.Theyshouldbedistributedinthe/usr/src/linux directorysotherearenoproblemswhensystemadministratorsupgradetheirkernelversionfor thefirsttime. /usr/src/linuxmayalsobeasymboliclinktoakernelsourcecodetree. -25-FilesystemHierarchyStandard November2,1995 6.The/varHierarchy /var—Variabledata

account

Processaccountinglogs(ifsupported)

crash

Systemcrashdumps(ifsupported)

cron

cronandatjobs

games

Variablegamedata

lock

Lockfiles

log

Logfilesanddirectories

mail

Usermailboxfiles

run

Filesrelevanttorunningprocesses

spool

Applicationspooldata

state

Variablestateinformation

tmp

Temporaryfilespreservedbetweensystemreboots

yp

NetworkInformationService(NIS)databasefiles /varcontainsvariabledatafiles.Thisincludesspooldirectoriesandfiles,administrativeand loggingdata,andtransientandtemporaryfiles. Someportionsof/vararenotshareablebetweendifferentsystems.Forinstance,/var/log,

/var/lock,and/var/run.Otherportionsareshareable,notably/var/mail,/var/spool/man,
/var/spool/fonts,and/var/spool/news.

/varisspecifiedhereinordertomakeitpossibletomount/usrread-only.Everythingthatonce wentinto/usrthatiswrittentoduringsystemoperation(asopposedtoinstallationandsoftware maintenance)mustbein/var. If/varcannotbemadeaseparatepartition,itisoftenpreferabletomove/varoutoftheroot partitionandintothe/usrpartition.(Thisissometimesdonetoreducethesizeoftheroot partitionorwhenspacerunslowintherootpartition.)However,/varshouldnotbelinkedto /usrbecausethismakesseparationof/usrand/varmoredifficultandislikelytocreatea namingconflict.Instead,link/varto/usr/var. Applicationsshouldgenerallynotadddirectoriestothetoplevelof/var.Suchdirectoriesshould onlybeaddediftheyhavesomesystem-wideimplication,andinconsultationwiththeFHS mailinglist. Thelock,log,run,spool,state,andtmpdirectoriesmustbeincludedandusedinall distributions;theaccount,crash,cron,games,mail,andypdirectoriesmustbeincludedand usedifthecorrespondingapplicationsorfeaturesareprovidedinthedistribution. Severaldirectoriesare‘reserved’inthesensethattheyshouldnotbeusedarbitrarilybysomenew application,sincetheywouldconflictwithhistoricaland/orlocalpractice.Theyare:

/var/backups
/var/local
/var/msgs
/var/preserve

-26-FilesystemHierarchyStandard November2,1995 6.1/var/account:Processaccountinglogs(ifsupported) Thisdirectoryholdsthecurrentactiveprocessaccountinglogandthecompositeprocessusage data(asusedbylastcommandsa).Asofthedateofthisreleaseofthestandard,process accountingwasnotsupportedunderLinux. 6.2/var/crash:Systemcrashdumps(ifsupported) Thisdirectoryholdssystemcrashdumps.Asofthedateofthisreleaseofthestandard,system crashdumpswerenotsupportedunderLinux. 6.3/var/cron:cronandatjobs Thisdirectorycontainsthevariabledataforthecronandatprocesses. BEGINRATIONALE PreviousLinuxreleases,aswellasmostcommercialvendors,use/var/spoolforcron.Giventhe definitionof/var/spool,itwasjudgedreasonabletomovecronelsewhereinthe/varhierarchy. PrecedentfromBSDUNIXsuggestedusing/var/cronratherthan/var/state/cron. Combiningcronandatinthishierarchyassumesthatafreecronthatincludesatfunctionality willbeimplementedinthefuture. ENDRATIONALE 6.4/var/games:Variablegamedata Anyvariabledatarelatingtogames,suchasthosein/usr/games,shouldbeplacedhere. /var/gamesshouldholdthevariabledatapreviouslyfoundin/usr;staticdata,suchashelptext, leveldescriptions,andsoon,shouldremainelsewhere,suchas/usr/lib/games. BEGINRATIONALE /var/gameshasbeengivenahierarchyofitsown,ratherthanleavingitmergedinwiththeold /var/libasinrelease1.2.Theseparationallowslocalcontrolofbackupstrategies,permissions, anddiskusage,aswellasallowinginter-machinesharingandreducingclutterin/var/state. Additionally,/var/gamesisthepathtraditionallyusedbyBSD. ENDRATIONALE 6.5/var/lock:Lockfiles Lockfilesshouldbestoredwithinthe/var/lockdirectorystructure. Devicelockfiles,suchastheserialdevicelockfilesthatwereoriginallyfoundineither

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

conventionwhichmustbeusedisLCK..followedbythebasenameofthedevice.Forexample,to lock/dev/cua0thefileLCK..cua0wouldbecreated. TheformatusedfordevicelockfilesmustbetheHDBUUCPlockfileformat.TheHDBformat istostoretheprocessidentifier(PID)asatenbyteASCIIdecimalnumber,withatrailing newline.Forexample,ifprocess1230holdsalockfile,itwouldcontaintheelevencharacters: space,space,space,space,space,space,one,two,three,zero,andnewline. -27-FilesystemHierarchyStandard November2,1995 Then,anythingwishingtouse/dev/cua0canreadthelockfileandactaccordingly(alllocksin /var/lockshouldbeworld-readable). 6.6/var/log:Logfilesanddirectories Thedirectorycontainsmiscellaneouslogfiles.Mostlogsshouldbewrittentothisdirectoryoran appropriatesubdirectory. lastlogrecordoflastloginofeachuser messagessystemmessagesfromsyslogd wtmprecordofallloginsandlogouts 6.7/var/run:Run-timevariablefiles Thisdirectorycontainssysteminformationfilesdescribingthesystemsinceitwasbooted.Files inthisdirectoryshouldbecleared(removedortruncatedasappropriate)atthebeginningofthe bootprocess. Processidentifier(PID)files,whichwereoriginallyplacedin/etc,shouldbeplacedin/var/run. ThenamingconventionforPIDfilesis<program-name>.pid.Forexample,thecrondPIDfileis

named/var/run/crond.pid.

TheinternalformatofPIDfilesremainsunchanged.Thefileshouldconsistoftheprocess identifierinASCII-encodeddecimal,followedbyanewlinecharacter.Forexample,ifcrondwas processnumber25,/var/run/crond.pidwouldcontainthreecharacters:two,five,andnewline. ProgramsthatreadPIDfilesshouldbesomewhatflexibleinwhattheyaccept;i.e.,theyshould ignoreextrawhitespace,leadingzeroes,absenceofthetrailingnewline,oradditionallinesinthe PIDfile.ProgramsthatcreatePIDfilesshouldusethesimplespecificationlocatedintheabove paragraph. Theutmpfile,whichstoresinformationaboutwhoiscurrentlyusingthesystem,islocatedinthis directory. ProgramsthatmaintaintransientUNIX-domainsocketsshouldplacetheminthisdirectory. 6.8/var/spool:Applicationspooldata /var/spool—Spooldirectories

fonts

Locally-generatedfonts

lpd

Printerspooldirectory

man

Locally-formattedmanualpages

mqueue

Outgoingmailqueue

news

Newsspooldirectory

rwho

Rwhodfiles

smail

Spooldirectoriesforsmail

uucp

SpooldirectoryforUUCP -28-FilesystemHierarchyStandard November2,1995 /var/spoolisintendedfor‘spooled’datafromapplications.Suchdataremainsvalidevenifthe applicationthatcreateditabortsandrestarts.Sometimeafterbeingcreated,thedatais automaticallyremoved,inanapplication-specificmanner;thisistypicallywhensomeeventoccurs (e.g.,lpdprintsthefile,orsendmailsendsit)oratimelimitexpires(e.g.anewsarticleora formattedmanpageisexpired).Datain/var/spoolisgenerallyofinteresttotheuserinandof itself,unlikedatain/var/state,whichisgenerallyofinterestonlyindirectly. UUCPlockfilesmustbeplacedin/var/lock.Seetheabovesectionon/var/lock. 6.8.1/var/spool/fonts:Locally-generatedfonts/var/spool/fontsshouldbe usedtostoreanydynamically-createdfonts.Inparticular,/var/spool/fonts/pkwillstoreallof thefontswhichareautomaticallygeneratedbyMakeTeXPK.

Thereshouldbealinkfrom/usr/lib/texmf/fonts/tmpto/var/spool/fonts.Thislinkallows

userstousesinglepath/usr/lib/texmf/fonts/tfmwhenmakingchangestotheirTEXFONTS environmentvariable.(ThisisthedefaultpathforKarlBerry’sTEXtools,distributedfrom ftp.cs.umb.edu:/pub/tex.2IfanotherTEXdistributionisused,alinkfromtheappropriatefont directoryto/var/spool/fontsshouldbemade.) TheMakeTeXPKthatisdistributedwithdvipskwillplace.pkfilesin

fonts/pk/<device>/<fontname>(e.g.,fonts/pk/CanonCX/cmr10.300pk).The.pkfilescanbe

periodicallypurgedfromthe/var/spool/fontstree,orcanbemovedintothe/usr/lib/texmf tree.Ifautomatic.mfor.tfmgeneratorsareused,theyshouldplacetheirdatainthemfortfm subdirectoriesof/var/spool/fonts. Otherdynamicallycreatedfontsmayalsobeplacedinthistree,underappropriately-named subdirectoriesof/var/spool/fonts. 6.8.2/var/spool/lpd:Line-printerdaemonprintqueues /var/spool/lpd—Printerspooldirectory

<printer>

Spoolsforaspecificprinter(optional) Thelockfileforlpd,lpd.lock,shouldbeplacedin/var/spool/lpd.Itissuggestedthatthe lockfileforeachprinterbeplacedinthespooldirectoryforthatspecificprinterandnamedlock. 6.8.3/var/spool/man:Locally-formattedmanualpages(optional) Thisdirectoryprovidesastandardlocationforsitesthatprovidearead-only/usrpartition,but wishtoallowcachingoflocally-formattedmanpages.Sitesthatmount/usraswritable(e.g., single-userinstallations)maychoosenottouse/var/spool/manandmaywriteformattedman pagesintothecat[1-9]directoriesin/usrdirectly.Werecommendthatmostsitesuseoneof thefollowingoptionsinstead: 2.

ThereasonthatKarlBerry’stoolsarementionedisthattheyarethede-factostandardforUNIXinstallationsof TEX.ThesetoolsarewidelyusedinthefreeUNIXcommunity. -29-FilesystemHierarchyStandard November2,1995 •Preformatallmanualpagesalongsidetheunformattedversions. •Allownocachingofformattedmanpages,andrequireformattingtobedoneeachtimea manpageisbroughtup. •Allowlocalcachingofformattedmanpagesin/var/spool/man. Thestructureof/var/spool/manneedstoreflectboththefactofmultiplemanpagehierarchies andthepossibilityofmultiplelanguagesupport. Givenanunformattedmanualpagethatnormallyappearsin /usr/<path>/man/<locale>/man[1-9],thecachedformattedversionshouldgoin

/var/spool/man/<path>/<locale>/cat[1-9].(Notethatthe<locale>componentmaybe

missing.)Foramanualpagethatnormallyappearsoutside/usr,in /<path>/man/<locale>/man[1-9],thecachedformattedversionshouldgoin

/var/spool/man/<path>/<locale>/cat[1-9].The<path>componentisabsentinthecaseof
/usr/share/manand/var/spool/man.
Forexample,/usr/share/man/man1/ls.1isformattedinto/var/spool/man/cat1/ls.1,and
/usr/X11R6/man/<locale>/man3/XtClass.3xinto
/var/spool/man/X11R6/<locale>/cat3/XtClass.3x.

Manpageswrittento/var/spool/man/cat[1-9]mayeventuallybetransferredto

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

beexpirediftheyarenotaccessedforaperiodoftime. Ifpreformattedmanualpagescomewithasystemonread-onlymedia(aCD-ROM,forinstance), theyshallbeinstalledinto/usr/<path>/cat[1-9]./var/spool/manisreservedasawritable cacheforformattedmanualpages. BEGINRATIONALE Release1.2ofthestandardspecified/var/catmanforthishierarchy.Thepathhasbeenchanged to/var/spooltobetterreflectthedynamicnatureoftheformattedmanpages.Thedirectory namehasbeenchangedtomantoallowforenhancingthehierarchytoincludepost-processed formatsotherthan"cat",suchasPostScript,HTML,orDVI. ENDRATIONALE 6.8.4/var/spool/rwho:Rwhodfiles Thisdirectoryholdstherwhodinformationforothersystemsonthelocalnet. BEGINRATIONALE PreviousBSDreleasesused/var/rwhoforthisdata;givenitsclosefittothedefinitionof ‘spooled’data,anditshistoricalprecedentin/var/spoolonothersystems,amovewasdeemed appropriate. ENDRATIONALE -30-FilesystemHierarchyStandard November2,1995 6.9/var/state:Variablestateinformation /var/state—Variablestateinformation

elvis

Savedfilesaftercrashorhang-upfromelvis

emacs

StatedirectoryforEmacs

misc

Miscellaneousstatedata

nvi

Savedfilesaftercrashorhang-upfromnvi

xdm

Xdisplaymanagervariabledata

<name>

Packagingsupportfiles Thishierarchyholdsstateinformationpertainingtoanapplicationorthesystem.State informationisdatathatprogramsmodifywhiletheyrun,andthatpertainstoonespecific machine.Usersshouldneverneedtomodifyfilesin/var/statetoconfigureapackage’s operation. Stateinformationisgenerallyusedtopreservetheconditionofanapplication(oragroupofinterrelatedapplications)betweeninvocationsandbetweendifferentinstancesofthesameapplication. Stateinformationshouldgenerallyremainvalidafterareboot,shouldnotbeloggingoutput,and shouldnotbespooleddata. Anapplication(oragroupofinter-relatedapplications)shoulduseasubdirectoryof/var/state foritsdata.Thereisonerequiredsubdirectory,/var/state/misc,whichisintendedforstate filesthatdon’tneedasubdirectory;theothersubdirectoriesshouldonlybepresentifthe applicationinquestionisincludedinthedistribution. /var/state/<name>isthelocationthatshouldbeusedforalldistributionpackagingsupport. Differentdistributionsmayutilizedifferentnames,ofcourse. BEGINRATIONALE Previousreleasesofthestandardusedthename/var/lib.However,/usr/libisincreasingly usedsolelyforobjectfilesorarchivesofthem;thisistrueofthecurrentBSDUNIXvariantsas wellascurrentGNUpackages.Accordingly,thename/var/libseemedinappropriate. BSDusedthename/var/dbforasimilardirectory.Thisnameseemedoverlyconstricting,asit impliedadirectorystructureintendedprimarilyfordatabase(.db)files. ENDRATIONALE 6.9.1/var/state/elvis:Savedfilesaftercrashorhang-upfromelvis Thisdirectorycontainssavedfilesgeneratedbyanyunexpectedterminationofelvis. BEGINRATIONALE PreviousLinuxreleases,aswellasallcommercialvendors,use/var/preserveforvioritsclones. However,theoriginalviusesadifferentformatforitssavefilesthanelvis.Giventhis,it seemedreasonabletomoveelvissavefilestoamoreappropriatedirectory. -31-FilesystemHierarchyStandard November2,1995 ENDRATIONALE 6.9.2/var/state/emacs:StatedirectoryforEmacs TheGNUEmacsstatedirectory,thelocationofarchitecture-independentdatafilesthatEmacs modifieswhilerunning,shouldbe/var/state.Presently,Emacsonlylocatesitslockfile directoryunderthestatedirectory(in<statedir>/emacs/lock),butitmaymakemoreextensive useofthestatedirectoryinthefuture. 6.9.3/var/state/misc:Miscellaneousvariabledata Thisdirectorycontainsvariabledatanotplacedinasubdirectoryin/var/state.Anattempt shouldbemadetouserelativelyuniquenamesinthisdirectorytoavoidnamespaceconflicts. Notethatfilespreviouslystoredin/var/dbinpreviousBSDreleasesaremovedhere.These includelocate.databaseandmountdtab,andthekernelsymboldatabase(s). 6.9.4/var/state/nvi:Savedfilesaftercrashorhang-upfromnvi Thisdirectorycontainssavedfilesgeneratedbyanyunexpectedterminationofnvi. BEGINRATIONALE PreviousBSDreleasesused/var/tmp/vi.recoverfornvi’srecoveryfiles.Itwasdeemed inappropriatetouse/var/tmpforanapplicationsubdirectory,particularlyoneintendedtocarry longer-termstate.Thispromptedthemoveto/var/state. ENDRATIONALE 6.9.5/var/state/xdm:Xdisplaymanagervariabledata/var/state/xdm containsthevariabledatafromxdm,whichconsistsofthexdm-errorsfilesandanyxdmauthority files.xdmbinaries(suchasthechooser)shouldnotbeplacedin/var.Thexdm-pidfileshould beplacedin/var/state/xdmdespitetheexistenceof/var/run.Theremainingfilesshouldbe

placedin/etc/X11/xdm.

6.10/var/tmp:Temporaryfilespreservedbetweensystemreboots The/var/tmpdirectoryismadeavailableforprogramsthatrequiretemporaryfilesordirectories thatarepreservedbetweensystemreboots.Therefore,datastoredin/var/tmpismorepersistent thandatain/tmp. Filesanddirectorieslocatedin/var/tmpmustnotbedeletedwhenthesystemisbooted. Althoughdatastoredin/var/tmpistypicallydeletedinasite-specificmanner,itisrecommended thatdeletionsoccuratalessfrequentintervalthan/tmp. 6.11/var/yp:NetworkInformationService(NIS)databasefiles VariabledatafortheNetworkInformationService(NIS),formerlyknownastheSunYellowPages (YP),shallbeplacedinthisdirectory. -32-FilesystemHierarchyStandard November2,1995 BEGINRATIONALE /var/ypisthestandarddirectoryforNIS(YP)dataandisalmostexclusivelyusedinNIS documentationandsystems. NISshouldnotbeconfusedwithSunNIS+,whichusesadifferentdirectory,/var/nis. ENDRATIONALE FilesystemHierarchyStandard November2,1995 7.IssuesandAdditionalRationale Thissectiondiscussesseveralareasthatmayrequirefurtherexplanation. 7.1WhatisEssential? Theansweris:essentialtoclean,create,prepare,check,findandmountotherfilesystems (possiblyonremotemachines).Thereareotherdefinitions,butthisisageneraldefinitionthat mostpeoplewillatleastincorporateintotheirown. 7.2Networking Networkingpresentedaninterestingdilemma.Somepeoplewantedtoseparatenetworking binariesandconfigurationfromotherbinariesandconfiguration.However,wedisagree.Wefeel thatnetworkingisnota"package",butanintegralpartofmostUNIX(andUNIX-like)machines. Becauseofthisnetworkingshouldnotbeplacedintoasingledirectory,butsystematicallyplaced intheappropriatedirectories. •/bin:anythingauserwillwanttousethatisalsoconsideredvital

{hostname,netstat,ping}

•/sbin:anythingonlyrootneedsandisconsideredvital

{ifconfig,route}

•/usr/bin:anybinariesauserwillwanttouse,andwhicharenotvital

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

•/usr/sbin:anyadministratoronlybinariesthatarenotvital

{in.ftpd,inetd,lpd,portmap,etc.}

Whilethismayseemconfusingatfirst(anditdoestakeamomenttodigest),itdoesmakesense. Ifyoucanonlymountrootforsomereasonandyouneedaccesstonetworkingtorepairyour systemoffin/usr/etc(astheyoftenareinsomeoperatingsystems).Filesthatareneededto mount/usrinnormal(andemergency)situationsareplacedontherootsubtreeandanyothers areplacedin/usrinordertokeepthesizeoftherootfilesystemsmall. Configurationfilesfornetworkingbelongin/etc. 7.3SymbolicLinks 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,forexample,/var/local.Thischangecanbejustifiedbyrecallingthemainreason forhaving/var:toseparatedirectoriesoffilesthatvarywithtimeandbetweendifferentsystems andmachinesfromthosethatmaybesharedandread-only. -34-FilesystemHierarchyStandard November2,1995 Sometimessystemswillalsolink/tmpto/var/<something>iftherootpartitionbecomestoo small(orstartsouttoosmall).Therearemoreexamplesof"good"usesofsymboliclinks,but theentireissueboilsdowntotwothings:packagesshouldbeabletofindthingswheretheyexpect them(withinreason)andsymboliclinkscanbeusedtosolvetheprobleminmanycases. However,problemsalsocanarisefromusingtoomanysymboliclinks.Theseproblemsinclude over-relianceonsymboliclinkstosolveproblems,confusionresultingfromoveruseofsymbolic links,andtheaestheticpreferencesofdifferentpeople. 7.4Staticallylinkedbinaries 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.

FilesystemHierarchyStandard November2,1995 TheFHSmailinglist TheFHSmailinglistislocatedat<linux-fsstnd@ucsd.edu>.Thislistwasoriginallylocatedon the<linux-activists@Niksula.hut.fi>"Mail-Net"astheFSSTNDchannel.(Tosubscribetothe listsendmailto<listserv@ucsd.edu>withbody"ADDlinux-fsstnd".) ThankstoNetworkOperationsattheUniversityofCaliforniaatSanDiegowhoallowedustouse theirexcellentmailinglistserver. Asnotedintheintroduction,pleasedonotsendmailtothemailinglistwithoutfirstcontacting theFHScoordinatororalistedcontributor. Acknowledgments CreditforthistextshouldbegiventotheFHSactivists,developers,systemadministrators,and userswhoseinputwasessentialtothisstandard.Ialsowishtothankeachofthecontributors whohelpedmetowrite,compile,andcomposethis,aconsensusstandard. IalsowishtogiverealcredittothoseLinuxdeveloperswhohaveseenthatgivingLinuxa commonfilesystemlayoutissomethingthatwillfurtherthedevelopmentoftheLinuxoperating system.IalsowishtonotethebraveryandperseveranceofthoseLinuxdeveloperswhostarted followingthisstandardbeforeitwascompleted. Originalcontributors DrewEckhardt<drew@colorado.edu> IanJackson<ijackson@cus.cam.ac.uk> IanMcCloghrie<ian@ucsd.edu> DanielQuinlan<Daniel.Quinlan@linux.org> 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<sweh@spuddy.mew.co.uk> FredN.vanKempen<waltje@infomagic.com> JohnA.Martin<jmartin@cpcug.org> ChrisMetcalf<metcalf@lcs.mit.edu> IanMurdock<imurdock@debian.org> DavidC.Niemi<niemidc@clark.net> -36-CONTENTS 1.

Introduction ........................................................................................................................2 1.1 StatusoftheStandard ................................................................................................2 1.2 OrganizationoftheStandard ......................................................................................2 1.3 TypographicalConventions .........................................................................................2 2.

General ................................................................................................................................1 2.1 Scope ...........................................................................................................................1 2.2 SpecificProblems ........................................................................................................2 2.3 Objectives ...................................................................................................................3 2.4 HistoryandProgress ...................................................................................................3 2.5 ConformancewiththisDocument ...............................................................................3 3.

TheFilesystem ....................................................................................................................5 4.

TheRootDirectory .............................................................................................................7 4.1 /bin:Essentialusercommandbinaries(forusebyallusers)

.....................................8 4.2 /boot:Staticfilesofthebootloader ..........................................................................9 4.3 /dev:Devicefiles ......................................................................................................10 4.4 /etc:Machine-localsystemconfiguration .................................................................10 4.5 /home:Userhomedirectories(optional)

..................................................................11 4.6 /lib:Essentialsharedlibrariesandkernelmodules ..................................................11 4.7 /mnt:Mountpointfortemporarilymountedfilesystems .........................................12 4.8 /proc:Kernelandprocessinformationvirtualfilesystem ........................................12 4.9 /root:Homedirectoryfortherootuser(optional)

..................................................12 4.10 /sbin:Systembinaries(binariesoncekeptin/etc)

..................................................13 4.11 /tmp:Temporaryfiles ..............................................................................................14 5.

The/usrHierarchy ............................................................................................................16 5.1 /usr/X11R6:XWindowSystem,Version11Release6 ............................................16 5.2 /usr/X386:XWindowSystem,Version11Release5,onx86platforms .................17 5.3 /usr/bin:Mostusercommands ................................................................................17 5.4 /usr/include:Directoryforstandardincludefiles.

...................................................17 5.5 /usr/lib:Librariesforprogramming .........................................................................18 5.6 /usr/libexec:Internalbinaries ..................................................................................19 5.7 /usr/local:Localhierarchy .......................................................................................19 5.8 /usr/sbin:Non-essentialstandardsystembinaries ...................................................20 5.9 /usr/share:Architecture-independentdata ..............................................................20 5.10 /usr/src:Sourcecode ...............................................................................................25 6.

The/varHierarchy ............................................................................................................26 6.1 /var/account:Processaccountinglogs(ifsupported)

..............................................27 6.2 /var/crash:Systemcrashdumps(ifsupported)

.......................................................27 6.3 /var/cron:cronandatjobs ......................................................................................27 6.4 /var/games:Variablegamedata ..............................................................................27 6.5 /var/lock:Lockfiles .................................................................................................27 6.6 /var/log:Logfilesanddirectories ............................................................................28 6.7 /var/run:Run-timevariablefiles .............................................................................28 6.8 /var/spool:Applicationspooldata ..........................................................................28 i 6.9 /var/state:Variablestateinformation .....................................................................30 6.10 /var/tmp:Temporaryfilespreservedbetweensystemreboots ................................32 6.11 /var/yp:NetworkInformationService(NIS)databasefiles .....................................32 7.

IssuesandAdditionalRationale ........................................................................................34 7.1 WhatisEssential?

.....................................................................................................34 7.2 Networking ................................................................................................................34 7.3 SymbolicLinks ..........................................................................................................34 7.4 Staticallylinkedbinaries ...........................................................................................35