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):

enter image description here

(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 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.

enter image description here

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?

  • 1
    First 13.10 is beyond EOL and not supported. Second, can you describe what you are trying to do? Normally you would send commands directly to the server as root , for example sudo service apache2 start|stop|reload no need to su to www-data
    – Panther
    Sep 17, 2014 at 22:12
  • As an addition, what you are trying to do is create an upstart script to automatically start the server under the user and group minecraft once you do that you should be use minecraft-client to login using 192.168.0.XXX:25565
    – jmunsch
    Sep 17, 2014 at 23:16
  • @bodhi.zazen - I hope I've clarified things a bit.
    – JDB
    Sep 18, 2014 at 1:36
  • 1
    We understand you have a user, minecraft. what command are you trying to run ?
    – Panther
    Sep 18, 2014 at 1:46
  • 1
    That appears to be entering commands directly into the server console. I think you are best off running in screen. minecraft should be running as the minecraft user even though you started it as root, same as any other server sudo service apache2 start runs apache as www-data for example. When you ssh in re-attach to the screen session. You can try sudo -u minecraft /bin/bash and start the server there, but you still need to detach, so seems screen will solve your problem.
    – Panther
    Sep 18, 2014 at 16:15

1 Answer 1


bodhi.zazen mentioned possibly "running in screen". I'd not heard of screen before, but it seems to have solved the problem.

First, I had to delete the minecraft user and re-create it as a normal user. Then I gave the minecraft user the necessary permissions to the minecraft server folder (using chmod). After I successfully started the minecraft server from the new minecraft user account, I stopped it and started a screen session:

enter image description here

and then started the minecraft server back up again (within screen):

enter image description here

I then used the standard screen shortcut to detach from the screen (Ctrl + a then just d). The minecraft server continues to run in the backround:

enter image description here

I can easily reattach to issue commands using screen -r:

enter image description here

enter image description here

I can end my SSH session without shutting down the server, then log back in from a different machine. For example, here I am logging back in using an android phone and JuiceSSH:

(noitce that you can see the commands I previously issued, since the screen was never terminated)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.