Ubuntu – getting a “failed to create pid file…Permission Denied” error

permissions

If a program requires write permission how should I set it with chown? Specifically, what would program foo's permissions be to solve this error?

failed to create pid file '/var/run/bar.pid': Permission denied

Best Answer

If you have a program foo trying to create/write to a file, the permissions of the foo binary don't matter, but the user it's running as makes all the difference.

In this case, foo is trying to write to /var/run, which is owned by root and only writable by root.

So you would have to run the program as sudo foo for it to create that PID file. Please consider the security implications of allowing a program to run as root before you do it...