LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Launch Minecraft and Minecraft server as non-root user (https://www.linuxquestions.org/questions/linux-general-1/launch-minecraft-and-minecraft-server-as-non-root-user-4175563014/)

Hasek39 01-03-2016 03:57 PM

Launch Minecraft and Minecraft server as non-root user
 
Hello everyone, I have a few questions about running Minecraft and Minecraft server as root and non-root user.

First of all in a few words let me tell about how I launch them now. I have an official Mojang account and downloaded Minecraft.jar and Minecraft_server.1.8.9.jar from an official site minecraft.net. I want Minecraft be at /usr/local/games/ and Minecraft server at /usr/local/games/minecraft_server/ so I moved them to wished path. I cannot access /usr/local/ path as non-root user (for example if run mkdir /usr/local/testdir the output will be "Permission denied") so I thought it is necessary to use sudo before commands java -jar /usr/local/games/minecraft.jar or java -jar /usr/local/games/minecraft_server/minecraft_server.1.8.9.jar when I want to launch the game or server. For the first time I launched them via sudo. But then I found that I can run minecraft.jar without sudo and it will work! But I can't run server without sudo because if I do that the server wouldn't be able to find and then to create file server.properties (I think because it hasn't permission to write at /usr/local/.../ path as non-root process) so it wouldn't work.

My questions are:
1. Is it possible to run Minecraft server at /usr/local/games/minecraft_server/ as non-root process maybe in any other way? It is obvious that if possible it is better to run any process as non-root.
2. If it isn't possible is it safe to run Minecraft server as root? I had to run it as root for about week ot two and there wasn't any troubles with it and my system in general but on the other web-sites I found quotes like "NEVER EVER RUN MINECRAFT SERVER AS ROOT!" or "NEVER! ever! run minecraft as root."
3. If, for example, it is possible is it safe for existing world on my server? Or will server launched without sudo overwrite existing files and create a new world? I don't want this because I play on server with my friends.
4. After installation Minecraft created /.minecraft and /.oracle_jre_usage directories at my user and root home directories. Is it safe just to remove /root/.minecraft and /root /.oracle_jre_usage? I understood that there are all saved games that I have played in singleplayer when used to launch Minecraft via sudo but can it cause any other problems? Will the game works after that just without saved worlds in singleplayer?

If it is important my distribution is GNU/Linux Slackware 14.1 and desktop environment is KDE 4.10.5.

Hasek39 01-03-2016 04:26 PM

To moderators: can you please move my thread to Linux-Software/Linux-Games forum?

jmgibson1981 01-03-2016 07:43 PM

The minecraft server files go where the .jar file is. So wherever you want that .jar to be has to be writeable by the user.

Hasek39 01-03-2016 11:52 PM

Quote:

Originally Posted by jmgibson1981 (Post 5472675)
The minecraft server files go where the .jar file is. So wherever you want that .jar to be has to be writeable by the user.

So to be writeable by user it can only be somewhere in /home/user/ directory, am I right?

Hasek39 01-04-2016 03:06 AM

I have successfully solved my problem by changing the owner of server directory. This is how I did that:
Code:

sudo chown -hR $my_user_name$ /usr/local/games/minecraft_server/
I can run both Minecraft server and client as non-root user now.


All times are GMT -5. The time now is 01:01 AM.