GoboLinux: A distro that redefines the entire filesystem hierarchy
Many readers of HN won&#x27;t need this explanation of the Unix&#x2F;Linux&#x2F;MacOS filesystem hierarchy, but for those that find it confusing here is a very brief summary. See Wikipedia for a more in depth discussion [1].<p>When Unix was invented, the concept of hierarchical filesystems wasn&#x27;t new, notably Multics had a hierarchical filesystem, but there were conflicting visions. At the time, most other operating systems divided the filesystems between a number of top-level containers containing files, but no nested containers. IBM&#x27;s contemporary time-sharing system, VM&#x2F;370, supplied users with a set of top-level &quot;virtual&quot; drives each containing any number of files. There were no recursively nested directories.<p>The designers of Unix wanted a simple Operating System suitable for software development so they tended to implement an idea and then use it as much as practical in the OS design. Rather than have top-level containers like drives that contain folders that contain files, Unix just had directories and files (both implemented with the same on device structures called inodes). This combination of simple ideas fully generalized can be seen throughout Unix: multiple pathnames can point (link) to the same inode providing a form of aliasing for filenames, the api for files is generalized to include access to (possibly raw) devices so devices show up in the filesystem hierarchy, etc.<p>[&#x2F;]<p>The top level directory has the name &#x2F;, unlike other systems all filesystem pathnames start at this single point.<p>[&#x2F;etc]<p>System configuration is found here. Most of these files are simple text files that may be edited by system administrators. In the past administrators might directly edit &#x2F;etc&#x2F;passwd to remove a user. Now, things are more complex, but there is still a backwards compatible &#x2F;etc&#x2F;passwd file (containing encrypted passwords, etc.).<p>[&#x2F;bin and &#x2F;sbin]<p>Unix, from the beginning was, like it&#x27;s inspiration Multics, a multi-user system. Reconfiguring the system, for example to add a printer or drive, normally required running in single user mode at a privileged level. For this reason the programs needed by administrators running single user were segregated and placed in &#x2F;bin. The rest of the system could be left offline, useful when working on the rest of the system.<p>As Unix grew, more and more utilities were added to &#x2F;bin until it made sense to segregate it into those utilities needed when even a normal user might find themselves in single user mode vs a system administrator doing something dangerous. The super-user type programs now go in &#x2F;sbin while the essential, but far less dangerous utilities go in &#x2F;bin. Ordinary file copy is &#x2F;bin&#x2F;cp while the reboot command is &#x2F;sbin&#x2F;reboot. Some of the division look arbitrary to me, like &#x2F;sbin&#x2F;ping instead of &#x2F;bin&#x2F;ping, but there is probably logic behind it.<p>[&#x2F;usr and &#x2F;var]<p>Once booted up normally in multi-user mode, &#x2F;usr contains system read-only content (for example, programs and libraries) and &#x2F;var contains system content that is variable (like log files).<p>The &#x2F;usr directory is large and subsequently divided into a number of second level directories.<p>[&#x2F;usr&#x2F;bin]<p>This is where the rest of the Unix &quot;binaries&quot; (i.e. programs) reside. So while ls (the list directory command) is &#x2F;bin&#x2F;ls the c compiler resides in &#x2F;usr&#x2F;bin and is &#x2F;usr&#x2F;bin&#x2F;gcc.<p>[&#x2F;usr&#x2F;sbin]<p>Like the division between &#x2F;bin and &#x2F;sbin more administrative commands not necessary for single user mode (see &#x2F;sbin) are placed in &#x2F;usr&#x2F;sbin. For example, the command &#x2F;usr&#x2F;sbin&#x2F;setquota used to set disk quotas on users is in &#x2F;usr&#x2F;sbin and not in &#x2F;usr&#x2F;bin.<p>[&#x2F;usr&#x2F;lib]<p>This is where Unix supplied software development libraries go.<p>[&#x2F;usr&#x2F;include]<p>This is where Unix supplied (predominantly C and C++) include files are placed.<p>[&#x2F;usr&#x2F;share]<p>System documentation, the man pages, and spelling dictionaries are examples of the files found in &#x2F;usr&#x2F;share. They are read-only files used by the system under normal (multi-user) operation.<p>By now &#x2F;usr&#x2F;share is full of further subdivisions since many programs and systems need a place to put their read-only information. For example there is a &#x2F;usr&#x2F;share&#x2F;cups for the Common Unix Printing System to store information about printers, etc.<p>[&#x2F;usr&#x2F;local]<p>System administrators may add additional local data and programs to their system. It make sense that these would be segregated from the rest of the files under &#x2F;usr that come with Unix. The contents of &#x2F;usr&#x2F;local are local to the machine and are further subdivided into programs in &#x2F;usr&#x2F;local&#x2F;bin and read-only data for these programs in &#x2F;usr&#x2F;local&#x2F;share.<p>[&#x2F;usr&#x2F;X11...]<p>Once, one of the biggest subsystems in Unix was it&#x27;s support for the graphical user interface known as the X window system. There were development libraries and include files, commands, man pages, and other executables. Rather than swamping the neat file hierarchy with these new files they were placed under a single subdirectory of &#x2F;usr. You will probably not need to look at this very often.<p>[&#x2F;home]<p>Users home directories are placed here; mine is &#x2F;home&#x2F;todd. Often &#x2F;home is on a different physical partition so that it can be unmounted and a new version of the operating system can be installed without touching &#x2F;home.<p>[&#x2F;tmp]<p>Temporary files, for example that don&#x27;t need to be backed up, are placed here.<p>[&#x2F;mnt]<p>I&#x27;ve mentioned mounting and unmounting. Unix systems support a number of different filesystem formats, and devices can contain multiple filesystems (for example on distinct partitions). These filesystem become accessible once they are mounted into the hierarchy. Users need to temporarily (and now automatically) mount USB drives somewhere so that their files can be accessed via a pathname. In the past, users would just pick a directory to mount over. Now, it&#x27;s traditional for temporary mounts to be placed in &#x2F;mnt.<p>[&#x2F;dev]<p>In Unix, low level access to devices is done through device drivers that support a number of file interfaces. Because they appear as special files they can be found under this directory. This is a convenience for programs because it makes naming and access to devices very similar to naming for ordinary files.<p>[Finding out more information about Unix and its hierarchy]<p>The Unix manual pages are a great resource. Originally, the manual was a physical book (I&#x27;ve still got a couple) divided into sections. Section 1 were the commands one might type on the command line. Now it is much easier to simply use the man command to access the exact same content. Use a terminal and enter &quot;man ls&quot;, for example, to get all the information on the ls command to list directory contents. (You will be surprised at the number of options.)<p>When you aren&#x27;t sure of the command&#x27;s name try the command &quot;apropos&quot; followed by a word you&#x27;d like to find the man page for. Passwords are an important subject so &quot;apropos password&quot; on my system lists 47 different manual pages for information on passwords. I see one listed as &quot;passwd(1)&quot;. The (1) means it&#x27;s section one so its about a command named &quot;passwd&quot;, the command for changing your password.<p>Here are the sections:<p>(1) Commands<p>(2) System calls<p>(3) Library functions<p>(4) Special files like device files<p>(5) File formats<p>(6) Recreations like games<p>(7) Misc info<p>(8) System admin and daemons<p>If I was looking for the format of the password file I would enter the section number 5 as the first argument to the man command: &quot;man 5 passwd&quot;. This would show me the documentation for the password file, &#x2F;etc&#x2F;passwd.<p>Filesystem hierarchy manual page: &quot;man 7 hier&quot; or, since it is in only one section: &quot;man hier&quot;. To find the name, &quot;hier&quot;, of this man page one could have used the command &quot;apropos filesystem&quot;.<p>I hope this helps; it&#x27;s probably too long.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Filesystem_Hierarchy_Standard" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Filesystem_Hierarchy_Standard</a>