I setup a minecraft server on a Ubuntu system. When I launch the server from the command line, the server listens to the standard input and responds to various commands (such as changing the game mode, difficulty level or time of day):
(See this demo of entering commands into the server console)
I don't like locking up my root user to run minecraft, though, so today I setup a system user named, simply, "minecraft":
sudo adduser --system --no-create-home --home /srv/minecraft-server minecraft
sudo addgroup --system minecraft
sudo adduser minecraft minecraft # this adds user "minecraft" the group "minecraft"
and I'm using a config file to launch the minecraft server under that user:
start on runlevel [2345]
console log
chdir /minecraft_server
setuid minecraft
setgid minecraft
respawn
respawn limit 20 5
exec /usr/bin/java -Xms1024M -Xmx1800M -jar minecraft_server.1.8.jar nogui
I want to send commands to the minecraft server via the standard input, just as I'm able to when I launch it under the current user. I've tried su
and sudo
, but the first seems to be ignored and the second produces a "command not found" error. Since minecraft is a system user, I'm guessing that interactive login is disabled.
I've worked with linux systems a little in the past, but I'm out of my depth here. How can I pass along commands to the minecraft user to pass along to the minecraft server? Or is that not possible in my current situation?
sudo service apache2 start|stop|reload
no need to su to www-dataupstart
script to automatically start the server under the user and groupminecraft
once you do that you should be use minecraft-client to login using 192.168.0.XXX:25565sudo service apache2 start
runs apache as www-data for example. When you ssh in re-attach to the screen session. You can trysudo -u minecraft /bin/bash
and start the server there, but you still need to detach, so seems screen will solve your problem.