Where to put daemon files?

Sceptical Jule

I wrote a couple daemons communicating over Unix domain sockets (raw sockets) and now I want to find the most suitable location for them on the production server. Where to put which files?

Here's what I got so far (feel free to suggest better locations):

  • Daemon binaries/executables: no clue... /usr/sbin/<subdir>/? /usr/bin/<subdir>/? Somewhere else?
  • Sockets: /var/run/<subdir>/ (no idea why but I wouldn't feel comfortable with /tmp/)
  • Log files: /var/log/<subdir>/
  • Configuration files: /etc/<subdir>/

The target OS is Ubuntu server 16.04+.

Philip Couling

There are many fine resources on the standards, including https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html

I would suggest:

  • Sockets: /run/<subdir>/. That's because /var/run is just a sym-link to /run these days on Ubuntu. /run is the newer standard place for such things.
  • Log files: /var/log/<subdir>/ Correct. Although a single log doesn't actually need a directory. Don't forget to add an /etc/logrotate.d entry as well
  • Configuration files: /etc/<subdir>/ Correct. Again a single config file doesn't need a directory but it doesn't hurt.

The binaries:

These are tricky; there's a whole bunch of places they can exist. Generally bin is for user commands, sbin is for server daemons. Some people say sbin is for binaries executed only by root. See here: https://askubuntu.com/questions/308045/differences-between-bin-sbin-usr-bin-usr-sbin-usr-local-bin-usr-local

  • Do NOT use /bin or /sbin. Reserve these for binaries required to boot your system.
  • Do use /usr/bin and /usr/sbin. Most things on unbuntu live here although there are exceptions. If you are properly packaging your software (into a .dpkg or similar) then definitely use /usr/bin and /usr/sbin.
  • If you don't intend to package it properly and just want to manually copy it as a sys admin then /usr/local/bin and /usr/local/sbin are more appropriate. But this generally shouldn't be used if you are going to distribute your code to other people.
  • If some of your binaries are only ever used by your other binaries, consider putting them under /usr/lib or /usr/local/lib. It's not uncommon for binaries to be thought of as libraries

In short, /usr/sbin and /usr/bin are most likely correct.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related