Ubuntu Server上能否同时以不同用户运行Minecraft与OpenVPN?
Hey Fredrik, let's tackle your two questions one by one—this is totally doable, and we'll cover the user account tradeoffs clearly.
Absolutely! Ubuntu Server is built for multi-tasking, so as long as your machine has enough CPU, memory, and bandwidth to handle both services, they’ll coexist perfectly.
The key here is that the two services use distinct default ports, so there’s no conflict:
- OpenVPN typically runs on 1194 UDP
- Minecraft Server defaults to 25565 TCP/UDP
Just make sure you’ve opened both ports in your firewall (e.g., ufw allow 1194/udp and ufw allow 25565/tcp/ufw allow 25565/udp if you use Minecraft’s UDP mode). OpenVPN uses barely any system resources, so even a low-end server should handle both unless you’re running a massive Minecraft server with dozens of concurrent players.
fredrik user or create a dedicated minecraft user? This boils down to security and organization—let’s break the pros and cons of each option:
Using your fredrik user (quick, but less secure)
- Pros: No extra setup needed; you already know how to manage files and permissions under this user.
- Cons: If the Minecraft Server ever has a vulnerability (unlikely, but possible), an attacker could gain access to your
fredrikaccount, which might have permissions to modify OpenVPN configs or other critical system resources. Plus, Minecraft’s saves, logs, and mods will mix with your personal user files, getting messy over time.
Creating a dedicated minecraft user (recommended for long-term)
- Pros:
- Permission isolation: The
minecraftuser will only have access to its own files and the minimal resources needed to run the server. Even if something goes wrong with Minecraft, yourfredrikaccount (and OpenVPN) stays safe. - Clean organization: You can store all Minecraft-related files in a dedicated directory (like
/opt/minecraft) that’s separate from your personal home folder. - Safer service management: When setting up Minecraft to run as a systemd service (so it starts automatically on boot), you can specify
User=minecraftto run the server with limited privileges—this is a standard Linux security best practice for services.
- Permission isolation: The
- How to create the user:
Run this command to create a system user with a dedicated home directory:
Here’s what each flag does:sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft-r: Creates a system user (ideal for services, not interactive logins)-m: Creates the specified home directory (/opt/minecraft)-U: Creates a group with the same name as the user-d: Sets the home directory path-s: Sets the default shell to bash (useful if you need to log in to manage files)
Final recommendation
If this is a small personal server for just a few friends, using your fredrik user will work perfectly fine. But if you want to follow Linux security best practices, plan to run the server long-term, or open it to more players, creating a dedicated minecraft user is absolutely worth the 2-minute setup.
内容的提问来源于stack exchange,提问作者Fredrik Burmester

