Direct answer

Use a separate non-root account for the Minecraft Java process. This limits access to unrelated files if the server or a plugin is compromised and avoids mixing production files with an administrator’s home directory.

Create or reuse a service account

  1. First check whether your panel or hosting provider already created a Minecraft user. Avoid making a conflicting second account.
  2. On a self-managed Linux host, an administrator can create a system account such as sudo useradd --system --home-dir /srv/minecraft --shell /usr/sbin/nologin minecraft. The no-login path differs across distributions; check before using it.
  3. Create the game folder with appropriate ownership, e.g. sudo install -d -o minecraft -g minecraft -m 750 /srv/minecraft.
  4. Configure your process manager or systemd unit to run with User=minecraft.

Verify identity

Read id minecraft, test the expected directories and check process ownership with ps -eo user,pid,args | grep '[j]ava'. Minecraft should write only its intended data. Give the account no unnecessary sudo rights or access to unrelated secrets.

Version and safety notes

Service-account creation paths, UID ranges, shell locations and SELinux/AppArmor policies vary by distribution and host.

Security note

A non-root user is one layer, not a complete sandbox. Keep server software and plugins maintained, constrain network exposure, back up before permission changes and avoid blanket ownership changes outside the Minecraft directory.

References

Check documentation for the versions and hosting environment you actually run.

Was this article helpful?
Help us improve this article

Tell us what is missing, unclear, outdated, or incorrect. You can also suggest something we should add.

What could we improve?
Do not include passwords, server IPs, or other private information.0 / 1000