Cannot create UNIX socket in /run

According to FSH UNIX Sockets shall be created in /run (or on legacy distros in /var/run). I am trying to create a socket in a non-root application in that directory and get error 13. Is /run only for services started via systemd/init? If so, where do you put UNIX sockets from user applications?

>Solution :

Is /run only for services started via systemd/init?

For root, yes.

where do you put UNIX sockets from user applications?

On modern systems in $XDG_RUNTIME_DIR if the variable is set, with fallback to /run/user/$UID if not set. For portability, you can use /tmp.

Usually $XDG_RUNTIME_DIR will be just set to /run/user/$uid.

https://renenyffenegger.ch/notes/Linux/fhs/run/user/uid/index https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Leave a Reply