Precisely this reason, because when things are run as root
, they are owned by root
and files it’ll create are root
-owned, too. Typically–as is the best practices in server administration–only the most system-critical services should be run as root
, because it’s the super user; it has the potential to bring down the entire system if it misbehaves or if exploited.
And internet-facing services, such as game servers, web servers, and its ilk are often very large projects which are impossible to keep exploit-free (or even just bug-free). Common services that do run as root
are like SSH, which are so finely tuned over decades that it is very trusted to be root
-run.
Anyway, all that ties in to “simply use a non-root
user for Minecraft servers”. Both in the webui and in the terminal.
If, for example, you were root
when you did rm -rf /
, you’d trash the whole system. But as mc
, you’d do pretty much no damage at all (to the system).
Likewise, the mc
user has full ownership of the directories it needs access to, which are your server directories located within /var/games/minecraft/servers/servername
. So running ServerStart.sh
is 100% possible with your mc
user, even if you can’t do anything to /var/
or /var/games/
or /var/games/minecraft
/, etc.
To fix this, run the following commands as root
(you have to be root
to correct it):
chown -R mc:mc /var/games/minecraft/{servers,archive,backup}/servername
(replace server name with each server).
That’s for one server. You can shortcut it for all servers in your webui with:
chown -R mc:mc /var/games/minecraft/{servers,archive,backup}/*