TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understanding the linux filesystem (/etc, /var, /bin, /opt etc.)

153 pointsby alexholehousealmost 12 years ago

16 comments

sciurusalmost 12 years ago
I think the Filesystem Hierarchy Standard is a better resource than this. Version 2.3 can be browsed at <a href="http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html" rel="nofollow">http:&#x2F;&#x2F;refspecs.linuxfoundation.org&#x2F;FHS_2.3&#x2F;fhs-2.3.html</a>. Development of version 3.0 (the first update since 2004) began in 2011; you can see a draft at <a href="http://www.linuxbase.org/betaspecs/fhs/fhs/index.html" rel="nofollow">http:&#x2F;&#x2F;www.linuxbase.org&#x2F;betaspecs&#x2F;fhs&#x2F;fhs&#x2F;index.html</a>
评论 #5944266 未加载
chalstalmost 12 years ago
I put up an explanation of the difference between &#x2F;bin, &#x2F;usr&#x2F;bin, &#x2F;usr&#x2F;local&#x2F;bin, and ~&#x2F;bin, as part of an argument why the &quot;robustness&quot; of using #!&#x2F;usr&#x2F;bin&#x2F;env $binname vs. hardcoding #!&#x2F;path&#x2F;to&#x2F;binname is not a good thing:<p>&gt; The reason that depending on PATH is not considered good practice is that the script can make no assumptions about the content of the PATH environment variable, breaking the &quot;sequential dependency model&quot; of binaries where<p>1. &#x2F;bin contains the executables needed at boot time;<p>2. &#x2F;usr&#x2F;bin contains the other executables used by the OS installation;<p>3. &#x2F;usr&#x2F;local&#x2F;bin contains executables installed by the system administrator that are not part of the base OS.<p>4. ~&#x2F;bin contains the user&#x27;s own executables.<p>&gt; Each level should not assume the existence of binaries later in the sequence, which are more &quot;application&quot; but may rely on binaries earlier, which are more &quot;fundament&quot;. And the PATH variable tends to run from applicationy to fundamental, which is the opposite direction to the natural dependency above.<p>&gt; To illustrate the problem, ask yourself what happens if a script in ~&#x2F;bin invokes an script in &#x2F;usr&#x2F;local&#x2F;bin that invokes Ruby? Should that script depend on the OS installed version at &#x2F;usr&#x2F;bin&#x2F;ruby, or on the personal copy the user happens to have at ~&#x2F;bin&#x2F;ruby? PATH searching gives the unpredictable semantics associated with the latter (maybe ~&#x2F;bin&#x2F;ruby is a broken symbolic link), while baking in the path to #! gives the former.<p>On the Unix&amp;Linux SX - <a href="http://unix.stackexchange.com/a/11917/5197" rel="nofollow">http:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;11917&#x2F;5197</a>
评论 #5945478 未加载
评论 #5945026 未加载
评论 #5945643 未加载
评论 #5945738 未加载
hendryalmost 12 years ago
I prefer the simpler filesystem proposal from <a href="http://sta.li/filesystem" rel="nofollow">http:&#x2F;&#x2F;sta.li&#x2F;filesystem</a><p>The FHS has been poorly done for years. For e.g. where is the canonical place for a Web vhost root? &#x2F;srv&#x2F;www? &#x2F;srv&#x2F;web? &#x2F;var&#x2F;www?
评论 #5944594 未加载
评论 #5944202 未加载
评论 #5945894 未加载
评论 #5944109 未加载
评论 #5944138 未加载
评论 #5944325 未加载
IvyMikealmost 12 years ago
Not enough people know this, but when you say &quot;etc&quot; out loud in reference to the directory, it is supposed to sound like &quot;etsy&quot;.<p>I expect there will be people who reply to this comment to argue it should be &quot;E-T-C&quot; or &quot;Et Cetera&quot;. You can ignore those people; they probably say &quot;exclamation mark&quot; instead of &quot;bang&quot;.
评论 #5945415 未加载
评论 #5944750 未加载
评论 #5946012 未加载
评论 #5947916 未加载
评论 #5944728 未加载
评论 #5944792 未加载
talloaktreesalmost 12 years ago
I wrote a utility called &#x27;dirhelp&#x27; that can give you info on any directory: <a href="https://github.com/jrenner/linux-directory-help" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jrenner&#x2F;linux-directory-help</a> It&#x27;s written in Go, binaries are available in the repo
评论 #5944765 未加载
评论 #5944285 未加载
评论 #5944099 未加载
评论 #5944381 未加载
contingenciesalmost 12 years ago
<i>&#x2F;srv</i> baby! Since I discovered that had semi-official support (even though it often doesn&#x27;t exist), I&#x27;ve rarely written elsewhere. Makes far more sense than <i>&#x2F;var&#x2F;www&#x2F;</i> and <i>&#x2F;var&#x2F;lib&#x2F;...</i> paths for different daemons to me.
TerraHertzalmost 12 years ago
Some related articles:<p>20120128 <a href="http://lists.busybox.net/pipermail/busybox/2010-December/074114.html" rel="nofollow">http:&#x2F;&#x2F;lists.busybox.net&#x2F;pipermail&#x2F;busybox&#x2F;2010-December&#x2F;074...</a> Understanding the bin, sbin, usr&#x2F;bin, usr&#x2F;sbin split<p>Ohhh THATS why! Taking the meaning of &#x27;legacy&#x27; to new extremes. This very detail, is one of the prime reasons I refuse to use Linux. I have always thought the categorization of folder usage was insane. Now I know WHY it&#x27;s insane.<p>20030430 <a href="http://www.osnews.com/story/3431" rel="nofollow">http:&#x2F;&#x2F;www.osnews.com&#x2F;story&#x2F;3431</a> <a href="http://www.osnews.com/story/3431/If_I_Had_My_Own_Distro/page2/" rel="nofollow">http:&#x2F;&#x2F;www.osnews.com&#x2F;story&#x2F;3431&#x2F;If_I_Had_My_Own_Distro&#x2F;page...</a> <a href="http://www.osnews.com/story/3431/If_I_Had_My_Own_Distro/page3/" rel="nofollow">http:&#x2F;&#x2F;www.osnews.com&#x2F;story&#x2F;3431&#x2F;If_I_Had_My_Own_Distro&#x2F;page...</a> If I Had My Own Distro (Linux)
quackerhackeralmost 12 years ago
<i>&#x2F;usr&#x2F;games</i><p>One of my pet peeves when I work on clusters before I even mess with the fstab or ufw is always deleting this folder.
评论 #5944455 未加载
评论 #5944244 未加载
bbanycalmost 12 years ago
Fedora has made some major changes to the hierarchy recently (merging &#x2F;bin and &#x2F;lib into &#x2F;usr, introducing &#x2F;run) that will be present in RHEL 7.<p>&#x2F;run has been widely adopted, but the &#x2F;usr merge is a bit more controversial. I expect this will become another factor in the growing bifurcation of Linux into Red Hat-style distros and Ubuntu-style distros (see also systemd vs. upstart, Wayland vs. Mir, etc.) with a few &quot;traditionalist&quot; distributions like Slackware on the sidelines. As a Debian user, I expect that the next few years will be...interesting.
chacham15almost 12 years ago
I remember reading an article that discussed why there were so many folders that seemed to have the same purpose (e.g. &#x2F;bin,&#x2F;sbin,&#x2F;usr&#x2F;bin) and the reason was that hard drives were so small that they needed to make sure that the essentials were available on boot. Seeing as how this isnt an issue anymore, why do we persist this same structure? E.g. to me the Mac filesystem seems to make much more sense and for the large part has eliminated all of this redundancy. Why isnt Linux in general following suit?
评论 #5944799 未加载
nathellalmost 12 years ago
While ubiquitous, this is not strictly necessary for a Linux system. For an example of a distro that makes a radical departure from FHS, see GoboLinux (sadly seems to be not updated anymore).
Aissenalmost 12 years ago
Unfortunately this is obsolete in many modern distros, including Fedora and Archlinux, because of the &#x2F;usr merge: <a href="http://fedoraproject.org/wiki/Features/UsrMove" rel="nofollow">http:&#x2F;&#x2F;fedoraproject.org&#x2F;wiki&#x2F;Features&#x2F;UsrMove</a><p>Also it doesn&#x27;t take &#x2F;run into account (for which many distros had a hack before settling on &#x2F;run).
FreakyTalmost 12 years ago
I never understood why this hasn&#x27;t been modernized. The three-letter nearly-meaningless directory names seem so obsolete.
评论 #5944343 未加载
评论 #5944174 未加载
评论 #5944100 未加载
评论 #5944241 未加载
cabalamatalmost 12 years ago
What do people think if the way Gobolinux does it? It seems a more sensible (and understandable filesystem hierarchy to me, but I wonder if there are problems with the idea).<p>Gobolinux: <a href="http://www.gobolinux.org/" rel="nofollow">http:&#x2F;&#x2F;www.gobolinux.org&#x2F;</a>
评论 #5947241 未加载
dmouratialmost 12 years ago
Amazing how few people I&#x27;ve worked with have any concept of FHS.
merlincoreyalmost 12 years ago
In FreeBSD, we have `man hier`<p><pre><code> HIER(7) FreeBSD Miscellaneous Information Manual HIER(7) NAME hier — layout of file systems</code></pre>