Filesystem Hierarchy Standard - Reference Poster / Cheatsheet [Dark mode in details]
from callcc@lemmy.world to linux@lemmy.ml on 11 Dec 2023 14:23
https://lemmy.world/post/9437525

Hey, I’ve recently designed a Poster about the FHS since I often forget where I should place or find things. Do you have any feedback how to make it better?

I updated the poster: whimsical.com/fhs-L6iL5t8kBtCFzAQywZyP4X use the link to see online.

Dark mode

Old version

#linux

threaded - newest

worldofbirths@lemmy.world on 11 Dec 2023 14:37 next collapse

Looks great!

mankeulv@lemmy.latrans.cloud on 11 Dec 2023 14:43 next collapse

Nicely done! Do you perchance have any hi res version?

eager_eagle@lemmy.world on 11 Dec 2023 14:59 next collapse

perchance

callcc@lemmy.world on 11 Dec 2023 15:29 collapse

Thanks! Unfortunately I’ve used closed source whimsical.com for this and don’t have a paid subscription. They only offer low-res for those accounts since recently :(

Admax@lemmy.world on 11 Dec 2023 16:18 next collapse

Maybe some AI upscaling could do the trick ?

uis@lemmy.world on 11 Dec 2023 23:24 collapse

Maybe try to do inkscape?

KISSmyOS@lemmy.world on 11 Dec 2023 14:43 next collapse

Where should I mount my additional internal HDD’s?
/media doesn’t fit cause they aren’t removable
/mnt doesn’t fit cause they aren’t mounted temporarily
Currently I have them mounted as /home/user/data and /home/user/backup.
Any reason not to do it like this?

seaQueue@lemmy.world on 11 Dec 2023 14:50 next collapse

I just mount mine into /mnt and bind mount subdirectories from them into wherever I need the space.

Edit: if you want a more theoretically correct location according to the FHS you could mount drives somewhere under /run and bind their contents from there. I’ve done that before as well.

zhenbo_endle@lemmy.ca on 11 Dec 2023 14:57 next collapse

I’m also mounting them into /home/user/data while I don’t think hard-coding the user name in the mountpoint is a good idea. Besides, it needs the assumption that I’m the only “human-user” of this computer.

I may also mount them at /opt/data, but I’m not sure if it’s a good idea

callcc@lemmy.world on 11 Dec 2023 15:28 collapse

From my humble knowledge I would suggest /var/opt/XXX. It’s the variable part of the /opt hierarchy.

eager_eagle@lemmy.world on 11 Dec 2023 14:58 next collapse

tbh I don’t think it matters, so wherever you feel like doing it. I just leave it where the distro or file manager defaults to: in Ubuntu-based distros that’s /media/$USER/mount-name. For mounts shared across users you could drop the $USER.

Since FHS doesn’t specify where “non-removable media” should go, I don’t think it makes sense to adopt this recommendation as /media should be removable, but rather, “in case the media IS removable, then mount it to /media/”.

520@kbin.social on 11 Dec 2023 15:03 next collapse

If it's just personal files and backups, there's absolutely nothing wrong with what you're doing.

If you had, say, active system config files there, it would make things... complicated to say the least.

Contort3860@links.hackliberty.org on 11 Dec 2023 15:05 next collapse

Not sure if this is proper procedure since I searched around and didn’t find much, but I’ve got an internal drive just for games mounted at /home/games. Haven’t had any issues so far.

BronzedBonobo@midwest.social on 11 Dec 2023 15:14 next collapse

I’m coming more from a server perspective but, fundamentally, all HDDs are “temporary”. Eventually that data might be in a bigger/faster/functioning replacement - so it’s best to treat the drive as something which can always be replaced.

Continuing that, you might mount to /mnt and then symlink that where you really want it, say …/games. That layer of abstraction allows you to replace the drive without much effect on install. Also allows for expansion via something like mergerfs (*no idea if that’s a good idea for your use cases)

callcc@lemmy.world on 11 Dec 2023 15:26 collapse

/mnt is explicitly meant to be used as temporary mountpoint for admins. That’s not a good place.

BronzedBonobo@midwest.social on 11 Dec 2023 23:45 collapse

I’m still learning myself, but I think in a good number of uses cases it qualifies. There are two parts of that explicit definition which seem important, “temporary” and “non-installation”. “Temporary” is the most ambiguous. An array of JBoD storing media files, which can be unplugged really at any time without affecting any system, meets that definition. Game installs or the operating system, less so. I totally get my specific usage may not lend to generic advice. In the interest of me learning, here’s where I started (which advises /mnt): perfectmediaserver.com/02-tech-stack/mergerfs/

TheEntity@kbin.social on 11 Dec 2023 15:36 next collapse

If they are internal and permanent (read: unlikely to be removed on a daily basis), I'd just mount them based on their purpose and not them being separate HDDs physically. If they are meant for logs, mount them at /var/log. If they are meant for your movies, /home/user/data is more than fine. In general FHS describes the directory hierarchy, not which parts of it are mountpoints and which are physically on the same media. Technically you're fine having each and every directory on a separate HDD.

pixelscript@lemmy.ml on 11 Dec 2023 17:10 next collapse

I originally had mine mounted on /, to make them easy to type. But that set one of my highly opinionated friends wretching, so I re-mounted them to /media/<user>/ to placate him and symlinked them to my home directory instead.

It’s frustrating how often Linux systems, when approached with a “where is the canonical location for <X>?” question, have an answer ancient use cases practically no one has anymore, but no satisfying answer for extremely common use cases like permanently mounted backup drives, where to put web server hosted files, or even where to install applications that don’t come from package managers (/opt/? /usr/bin/? /home/<USER>/.local/?).

KISSmyOS@lemmy.world on 11 Dec 2023 17:21 collapse

Just put all of that in subfolders of /fuck_the_FHS/

devfuuu@lemmy.world on 11 Dec 2023 23:21 collapse

Usb devices are nowadays when connected mounted somewhere in /run/%user

[deleted] on 11 Dec 2023 14:51 next collapse

.

callcc@lemmy.world on 11 Dec 2023 16:33 collapse

Done!

bionicjoey@lemmy.ca on 11 Dec 2023 14:59 next collapse

Related: man hier

eager_eagle@lemmy.world on 11 Dec 2023 15:19 next collapse

it bothers me a little the entry is not called fhs: man fhs

callcc@lemmy.world on 11 Dec 2023 16:35 collapse

Added to new version. Thanks for the suggestion.

callyral@pawb.social on 11 Dec 2023 15:39 next collapse

how is /usr/local local and not system-wide? i though it was for programs you compiled yourself?

TheEntity@kbin.social on 11 Dec 2023 16:43 next collapse

"Local" in this context means local to this whole machine. From the perspective of a single user, it's system-wide. But then from the perspective of a sysadmin managing dozens of such systems, it's local.

callyral@pawb.social on 11 Dec 2023 16:58 collapse

thanks for the explanation!

callcc@lemmy.world on 11 Dec 2023 16:45 collapse

Many FHS things don’t make much sense for single-user (human user) systems on modern hardware. /usr/local does though. It’s for you (as admin) to install software that doesn’t come with the os.

Crow@lemmy.world on 11 Dec 2023 16:04 next collapse

So why does my system mount my drives to /run/user/1000…?

callcc@lemmy.world on 11 Dec 2023 16:31 collapse

1000 might by your user’s user-id

pixelscript@lemmy.ml on 11 Dec 2023 16:51 collapse

1000 is the default ID given to the first-created user on Debian-based systems.

May or may not be the case with other distros. Haven’t checked.

jbk@discuss.tchncs.de on 11 Dec 2023 17:34 collapse

It’s the same for red hat distros afaik

Cysioland@lemmygrad.ml on 11 Dec 2023 22:48 collapse

AFAIR IDs of 1000 and above indicate human users, while IDs below 1000 indicate service accounts like www-data

Admax@lemmy.world on 11 Dec 2023 16:22 next collapse

Damn that’s some great work ! When I started linux I wish I had found such ressources, I was really curious what each of these directories were for.

Would you mind if your material was reused (with credit) for education purposes ?

hansl@lemmy.world on 11 Dec 2023 16:26 next collapse

The FHS was started in 1994 and is free to use. It should be used now by all major Linux systems and most Unix too.

The only credit is to the Linux Foundation.

faerbit@feddit.de on 11 Dec 2023 17:10 next collapse

But $vendor, which supplies $application, doesn’t give a flying fuck about this. I’ve seen binaries in /etc/opt/$application or something like that.

hansl@lemmy.world on 11 Dec 2023 17:29 collapse

Tell them. Many people don’t know about FHS. Seriously, just the person I was answering to was giving credit to some rando who copy pasted an image from the Linux foundation.

I’ve been educating people on this all my professional life. I try to make a change with the people around me, but I’ve also filed big to some FOSS projects that got it wrong. Some did the change, some were unwilling. But it’s unknown if even those did follow the right convention in their next project.

callcc@lemmy.world on 11 Dec 2023 20:29 collapse

I spent a few hours making it myself. Of course based on the standard document.

joeldebruijn@lemmy.ml on 12 Dec 2023 07:00 collapse

Material visualising or describing FHS can be credited seperatly.

callcc@lemmy.world on 11 Dec 2023 16:30 collapse

I’d be more than happy if this was used. Do whatever you want with it as long as you abide by the CC BY-SA-4.0 license. This means you can share freely and modify as long as you keep the authorship information and share with same license.

jaybone@lemmy.world on 11 Dec 2023 16:45 next collapse

What do you mean by locally vs site wide? For /usr/local that’s usually stuff installed from outside of the distributions normal packaging mechanism. E.g. if you build something from source using “make”, the “make install” would install it there by default (though that is also configurable.)

Also not sure we want to say /mnt is necessarily temporary. Any mount pionts there could easily be added to fstab.

callcc@lemmy.world on 11 Dec 2023 16:50 next collapse

The FHS says the thing about /mnt. It’s not normally meant to have subdirectories or be mounted to by default.

dan@upvote.au on 12 Dec 2023 21:12 collapse

The origin is that /usr may be network mounted or otherwise shared across multiple systems, whereas /usr/local is local to a particular PC. That definition is not as relevant with today’s single-user machines, and now it mostly means what you said (/usr is managed by system package manager whereas /usr/local is manually managed).

jaybone@lemmy.world on 11 Dec 2023 16:47 next collapse

And /net is usually autofs mounted.

callcc@lemmy.world on 11 Dec 2023 17:27 collapse

That’s NFS shares? I might add that later although it’s not very common or standard I guess. Thx

jaybone@lemmy.world on 11 Dec 2023 18:26 collapse

Yeah, nfs exports that can be mounted by HOSTNAME or ip address automatically with autofs. Sorry if that’s not standard, like my other comment about /mnt. I’ve never actually looked at the spec. I was just giving feedback based on what I’ve seen in the industry. So might not be spec compliant but a lot of it is common practice I’ve seen (for better or worse.)

netwren@lemmy.world on 11 Dec 2023 17:05 next collapse

I don’t understand the ambiguity of where to put your projects.

I’ve typically always put things under /opt/ TIL /etc/opt was where the config should go.

callcc@lemmy.world on 11 Dec 2023 17:24 collapse

Depends on the scope of your project. But if they are services for example or you want them to be run by different users on the system, you could either use /opt or /usr/local. There is some discussion about which is better or how to choose: eg. linuxjournal.com/…/pointcounterpoint-opt-vs-usrlo… . The FHS is mostly relevant when packaging your software though.

netwren@lemmy.world on 11 Dec 2023 17:39 collapse

Less relevant with Docker or FlatPaks though right?

callcc@lemmy.world on 11 Dec 2023 17:43 collapse

I’m not into those since they just shift the complexity. People should learn how to package things and just do it. Ok, documentation on making dpkgs is pretty tough to understand and confusing.

But yeah, I guess with docker it’s complete anarchy ( the bad kind of)

QuazarOmega@lemy.lol on 11 Dec 2023 19:15 collapse

But yeah, I guess with docker it’s complete anarchy ( the bad kind of)

Not really, usually stuff will be all self contained (no pun intended), container volumes inside docker’s own directory and mounts of folders that will most often all reside under the same repository, then you don’t have to worry about breaking stuff by touching the root, even better if you do that with Podman.

Flatpak is similar in the way that it also has its own standards and apps are pretty much obligated to follow them. Now the fact that data lives under .var/app/ completely disregarding the XDG spec, while both things are part of Freedesktop… Well that’s just ironic lol

callcc@lemmy.world on 11 Dec 2023 20:28 collapse

But who knows what’s inside?

netwren@lemmy.world on 11 Dec 2023 21:05 collapse

Not at all true. Go inspect the Dockerfile. If done correctly you should be able to inspect the full container build.

callcc@lemmy.world on 11 Dec 2023 21:47 collapse

Of course you can, but few people care and do it. There is a saying about docker: “Docker images are like smoothies, you immediately know if you like it but you don’t know what’s inside”. The idea being that there is no good quality control and transparency. People just install random blobs, like in the old days where you would install a cracked game from eMule.

If you care about security, docker is not what you want, they are not reproducible nor transparent nor is it possible to easily update broken shared libraries (eg openssl).

But then again people have different requirements. Some just wanna have things running quickly without the hassle. That’s where docker shines. But it leads us to a world where we hide ugly stuff under the carpet instead of fixing things.

netwren@lemmy.world on 12 Dec 2023 01:21 collapse

Agreed but can’t the same be said about pre-compiled binaries?

At least with a Dockerfile I can download the repo and make them image for myself.

Sure you could’ve downloaded the repo and compiled the binary for yourself but you still had to have all of the libraries setup correctly. It’s more about a codified build process that’s reproducible vs a “supposedly” working documentation on a git repo of make scripts.

callcc@lemmy.world on 12 Dec 2023 09:28 collapse

There is a lot of work being done on reproducible builds in the guix project and other distros. The idea being that you can be sure that a binary package is bit for bit the same, whoever builds it and on whatever system. This would be the first time you have complete traceability of what goes into your binaries.

On guix, you can for example install substitutes of packages which you could also build manually. Since the build environment and the dependencies are very tightly controlled, you have mathematical proof that the substitute is equivalent to the package built by the maintainer. You can thus be sure that no evil third party injected malware into the substitute binary, unless ot was done at source code level and the package maintainer has put it there (by accident).

[deleted] on 11 Dec 2023 20:42 next collapse

.

Helix@feddit.de on 11 Dec 2023 22:16 next collapse

ikr? NixOS is particularly bad

2xsaiko@discuss.tchncs.de on 11 Dec 2023 23:13 collapse

That’s a deliberate decision

Cysioland@lemmygrad.ml on 11 Dec 2023 22:45 next collapse

I profess my ACAB creed by having directories like /ssd, /hdd, /backups

Chobbes@lemmy.world on 12 Dec 2023 02:34 collapse

You leave NixOS alone!!

ferralcat@monyet.cc on 11 Dec 2023 21:35 next collapse

I’m surprised to hear /home is non standard.

callcc@lemmy.world on 11 Dec 2023 21:49 collapse

I guess the reason it’s not in FHS is that FHS is concerned about system wide things whereas /home is the opposite. It’s the user’s realm.

There is XDG for /home/$user though.

Rustmilian@lemmy.world on 11 Dec 2023 23:03 collapse

Are you planning on doing one for XDG?

callcc@lemmy.world on 12 Dec 2023 07:12 collapse

I’ll have a look but probably not.

Helix@feddit.de on 11 Dec 2023 22:14 next collapse

Nice, but how do I zoom on mobile?

Rustmilian@lemmy.world on 11 Dec 2023 23:04 next collapse

I really like this, but can I have a black background version please?

callcc@lemmy.world on 12 Dec 2023 09:30 next collapse

You could invert the colors in GIMP or similar.

Rustmilian@lemmy.world on 12 Dec 2023 09:51 collapse

That wouldn’t look as good tho. I want the black text to be white and the white background to be black not invert everything.

callcc@lemmy.world on 12 Dec 2023 09:56 collapse

Added a black background version.

Rustmilian@lemmy.world on 12 Dec 2023 10:04 collapse

Not bad, but not quite what I had in mind as you see the blue carrot, lol. Would you perhaps share your project files?

callcc@lemmy.world on 12 Dec 2023 10:55 collapse

I unfortunately did it in whimsical.com which is great but also closed if you don’t pay. whimsical.com/fhs-L6iL5t8kBtCFzAQywZyP4X is the best I can do.

dan@upvote.au on 12 Dec 2023 21:06 collapse

You could create a Github repo for it and store it as an SVG file.

Samueru@lemmy.ml on 11 Dec 2023 23:20 next collapse

We need something like this for home, I hate that programs like steam and firefox place themselves directly into home instead of ~/.config and ~/.llocal.

I even move my personal themes to /usr/share/themes because not everything works with ~/.local/share/themes and needs a ~/themes directory instead.

KISSmyOS@lemmy.world on 11 Dec 2023 23:39 next collapse

My personal pet peeve is that Firefox profiles are in ~/.mozilla/firefox and Thunderbird profiles are in ~/.thunderbird.
If your flagship product creates a folder named after your company, why not use it for all software by your company???

dan@upvote.au on 12 Dec 2023 21:05 collapse

Thunderbird isn’t really developed by Mozilla any more. It’s owned by a subsidiary of Mozilla and is mostly community-run.

callcc@lemmy.world on 12 Dec 2023 07:11 collapse

…freedesktop.org/…/basedir-spec-latest.html

Samueru@lemmy.ml on 12 Dec 2023 18:47 collapse

Thanks, I just went down this rabbit hole and discovered xdg ninja and managed to clean most of my home, I even found a useful script that launches steam on a fake home directory on .local.

callcc@lemmy.world on 12 Dec 2023 19:20 collapse

Uhh, very nice. I didn’t know about xdg-ninja.

cerulean_blue@lemmy.ml on 12 Dec 2023 00:39 next collapse

Super useful, thanks. Actually made a lot of things click in my head about how Linux works.

When did /home get deprecated? Is /usr/local the replacement?

Sorry for the n00b question (I’m not a noob, but I have been off Linux for a few years), figured the answer may be useful to other users too

vole@lemmy.world on 12 Dec 2023 02:04 collapse

/home is not deprecated, it’s optional but common. Here is the section from FHS: refspecs.linuxfoundation.org/…/ch03s08.html

dino@discuss.tchncs.de on 12 Dec 2023 08:01 collapse

then the legend should be fixed its confusing, as is the whole idea of FHS is outdated and a chore for new users to get into (i still don’t fully understand it)

  • difference between /media and /mnt
  • wtf is /run? some glorified /temp?
  • /usr/sbin “non vital system binaries” … aha ok, whatever don’t tell me you understand the difference between 6 (SIX !) differen bin/sbin folders
  • could continue forever…
callcc@lemmy.world on 12 Dec 2023 09:51 next collapse

The legend is a bit broken. Will fix it maybe.

As for the rest, yes, the FHS can be confusing. It’s from a time where mostly professional admins would deal with it and requirements were pretty different from today’s end-user systems. If you want to understand more, I urge you to read the spec. It’s highly readable! refspecs.linuxfoundation.org/FHS_3.0/fhs.html

AMDIsOurLord@lemmy.ml on 12 Dec 2023 10:15 collapse

/mnt is for more permanent stuff. /run is for shit like a USB drive some user has connected. It’s the place that most distro automount your attached storage by default (/run/$USER/$DEVICE/)

ultra@feddit.ro on 12 Dec 2023 07:45 next collapse

Laughs in Nix

dannym@lemmy.escapebigtech.info on 12 Dec 2023 13:51 collapse

well nix still uses the same structure, the only difference is that files are symlinked to files in subfolders of the /nix/store folder.

For example you may find that /etc/hosts is just a symlink to /nix/store/69420aaabbbcccdddfffggghhhiii420-hosts

ultra@feddit.ro on 12 Dec 2023 15:47 collapse

Not everything is in its FHS location, unless you use steam-run. Binaries arwn’t in /bin, for example

dannym@lemmy.escapebigtech.info on 12 Dec 2023 16:51 collapse

I mean fair enough, some files are in /run/current-system/sw/

pipows@lemmy.today on 12 Dec 2023 08:33 next collapse

This is a very useful, very well done chart, congratulations.

But what a mess is FHS. Easily the worst thing of linux design for me

callcc@lemmy.world on 12 Dec 2023 10:54 collapse

The better you understand it the less it seems bad.

urfavlaura@lemmy.ml on 12 Dec 2023 08:59 next collapse

laughs in guix

Adanisi@lemmy.zip on 12 Dec 2023 10:24 next collapse

FHS? Who needs that?

dino@discuss.tchncs.de on 12 Dec 2023 12:11 collapse

does guix go the same was as nixos in that regard? where can I find info regarding FHS in guix?

callcc@lemmy.world on 12 Dec 2023 13:39 next collapse

Afaik guix is very similar to nixos in that respect. The store where applications are installed is called /gnu there.

urfavlaura@lemmy.ml on 12 Dec 2023 22:45 collapse

yeah it uses /gnu instead of /nix

MaxPower@feddit.de on 12 Dec 2023 12:12 next collapse

Great but what I’m missing is the information that “usr” does not stand for “user”, like many people think or even say. If it would the name could actually be “user” and not “usr”.

The chart actually does not say what exactly it stands for. It’s “user resources” AFAIK.

It’s worth clearing this up in my opinion.

callcc@lemmy.world on 12 Dec 2023 13:27 next collapse

Thanks for the input. Things are complicated: askubuntu.com/a/135679 . Apparently it originally meant “user” but then slowly was used for system stuff. So people invented backcronyms.

SpaceCadet@feddit.nl on 13 Dec 2023 01:19 collapse

That’s just retconning/backronyming it.

/usr does historically stand for user. It’s where the user home directories were on old Unix versions.

dan@upvote.au on 12 Dec 2023 21:13 next collapse

I’ve never seen /etc/opt used. Usually if an app is in /opt, the entire app is there, including its config which is frequently at /opt/appname/etc/.

Hawke@lemmy.world on 13 Dec 2023 23:49 next collapse

Quest One Identity does.

seaQueue@lemmy.world on 14 Dec 2023 06:42 collapse

/opt is kinda legacy at this point. That used to be the location where you’d install software manually in the past but I haven’t seen it used for some time, it was more common in the 00’s.

dan@upvote.au on 14 Dec 2023 17:34 collapse

I still put all my standalone apps in there (meaning apps that are often statically compiled and expect the executable, logs, and config to be in the same directory), as well as apps that have their own docker-compose.yml file. Should I be putting them somewhere else? I know /srv exists but I’ve never used it and I don’t think Debian creates it by default.

seaQueue@lemmy.world on 17 Dec 2023 20:38 collapse

That seems like a fine use for /opt

prYsm@lemmy.world on 12 Dec 2023 23:24 collapse

What would a use case be for

>/usr/bin

versus

/usr/local/bin

SpaceCadet@feddit.nl on 13 Dec 2023 01:14 collapse

Binaries in the former are installed by the OS/package manager, binaries in the latter are installed manually by the user, for example by compiling from source and running make install

prYsm@lemmy.world on 13 Dec 2023 03:07 collapse

Great. Now I gotta refactor some scripts.