Understanding the differences between /usr/games, /opt, and /usr/share

I’m making a personal .deb package for a Minecraft Server and was wondering which folder to put it in when installing. This lead me to wonder what exactly are the edge cases for going into one folder vs the other. Do all games go in /usr/games not matter what? Can game scripts go in /usr/bin? Do all programs that work on all architectures (i.e. Java), go in /usr/share? What does it exactly mean to not follow the normal file structure that causes a program to end up in /opt? I feel like it is a little confusing to know where to put something even with FHS standardizing things because sometimes programs fall under multiple standards. If any of your answers are distro specific please let me know and give the answer for Debian as that is where I am working on for now.

Consult man heir for the explanation of the layouts.

Personally, I stick custom custom binaries in /opt because it’s much easier to manage and only the Minecraft user runs the Minecraft binaries.

2 Likes

I had kinda already looked at that before. I’m wondering for the future if there’s a more definitive way to tell if I should put it in /opt or not. Also, if it is going to go into /opt where do my server management scripts go? /usr/bin? Finally, what Debian package category should I put it under if it doesn’t go under games?

Opt is for specific crap for specific users.

Usr is universal stuff.

So if you have a specific service to be run by a specific user it would traditionally go under /opt whereas the scripts could go to mgmt users in usr or opt.

Or you could just place symlinks in usr and they actual binaries go under opt.

Just sticking crap under /home is also a thing.

Tbh I’m not sure what Debian does these days because I’m a redhat guy.

1 Like

Alright thanks! Just making sure I understand correctly since I’m running the server with a separate minecraft user then it would go under /opt but I could also symlink to /usr/bin for convience? Is /opt/bin a thing as well? Or should I make my own hierarchy under /opt

If you symlink to /usr/local/bin it will be accessible in anyone’s PATH by default.

I cant speak for debian but many archlinux packages built from AUR are being installed into /opt/package-name
And then they are somehow being added into the PATH (symlink from /bin? ¯\_(ツ)_/¯ )

I don’t really understand why do you want to make a .deb for a minecraft server (automation?) but digging into this twisted logic is unlikely the thing you want.
Afaik even the distributions themselves have no idea where to put stuff, I think on debian /bin is a symlink to /usr/bin, and so are other directories.

If anyone in the future wants to use this thread as a reference on how to package your application for linux:

Use either one of those methods:

appimage
flatpack
snap
docker

or just statically compiled binary

For Debian, even if it is for a Game server, it goes under the games category.

I run Debian and ArchLinu systems. For things like FireFox-Nightly, Discord, and some Game Launchers, I put them in /opt/<application_name>. IF it is something that needs to be used by all uses, I put the scripts and symlinks to the binaries in /usr/local/share.

I create a group for the different items in /opt and then add the users that need access to that group. Even though a use can see the scripts and symlinks to /opt, if they are not part of the group, they cannot run the software.

For stuff like this I just take the arch wiki’s recommendations, so in this case I’d look at: https://wiki.archlinux.org/index.php/Arch_package_guidelines#Directories