How to not use "root" as the user your server is running on

Discussion in 'Bukkit Discussion' started by MeneXia, Jul 23, 2012.

Thread Status:
Not open for further replies.
  1. Is it dangerous to run "root" as the user your server is running on?
    The answer is: YES. If you were to give your root password to somebody else, he/she has the potential to delete various system files, as root is the superuser (i.e. has permissions on any command, anywhere on the system).

    The solution is to make another user and assign it permissions to your server folder.

    1. Log in as "root" on your server, and type in the following commands:
    Code:
    adduser <userName>
    passwd <userName>
    <userName> will be whatever you want it to be, I typed in: "menexia"
    When typing "passwd <userName>," you will prompted to type a password, and type it again for confirmation.

    2. Navigate to the user's folder:
    Assuming you logged in as root, you should be in the /root/ folder.
    Type in these commands:
    Code:
    cd ..
    cd home
    ls
    You should now see the username you typed in as a directory. From here, you can copy/move your server folder to the user folder. Here's an example command, assuming your server folder is in the "root" folder:
    Code:
    cp /root/<serverFolder>/ /home/<userName>/
    You can replace copy and move with cp and mv respectively.

    3. Add permissions for the user to open/edit/delete files from his/her folder:
    Assuming you are still in the /home/ directory, type:
    Code:
    chown -R <userName>:<userName> <userDirectory>
    For me, it would be: chown -R menexia:menexia menexia

    4. Make sure everything works.
    Exit your current session with root, and start a new session; login as the username you recently registered.
    Upon login, you will be in /home/<userName>/, so simply navigate to your server folder, and do whatever you need to do to start the server! Whether it be manually, or through an .sh script.
     
Thread Status:
Not open for further replies.

Share This Page