# Refusing to Run with Root Privilege

{% hint style="success" %}
Want to bypass this without worry? Use the [Build and Push Feature](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/toolbar/build-and-push) that comes built into PCU and it'll do this for you, automatically.
{% endhint %}

Unreal Engine is a great engine, but it has some quirks. One of those quirks is preventing users from running as root so that if the server was to be taken over, it wouldn't allow any further access which is great! Fantastic! Downside? Playflow boots the server under root. (It's not Playflow's fault! Please don't think I am saying that! Linux servers by default will boot under root and Unreal doesn't like root.) We need to circumvent this.

As explained earlier in:

{% content-ref url="../welcome" %}
[welcome](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/welcome)
{% endcontent-ref %}

The game server starting script (which normally is the file that we launch because it's easier) which is the GameProjectNameServer.sh needs to be changed to Server.x86\_64. What we need to do now is also edit our Starting Server Script so that we can fix that root issue. There is a way to disable the root check via editing files in Source, but that's annoying to go back and edit the files. We're gonna do it an easier way by replacing and chunking stuff in our script.

Below is the replacement you're going to need, simply copy and paste it in there and be mindful of the spaces that have the \<REPLACE ME> as that should be your project's name.

{% hint style="danger" %}
ENSURE THAT YOU ARE REPLACING THE \<REPLACE ME> WITH YOUR ACTUAL PROJECT NAME. IF YOU ARE USING SHIPPING BUILDS ENSURE YOU ARE USING THE CORRECT FILE FROM YOUR BINARIES/LINUX/ FAILURE TO DO SO WILL RESULT IN YOUR SERVER NOT LAUNCHING!
{% endhint %}

```
#!/bin/sh
UE4_TRUE_SCRIPT_NAME=$(echo "$0" | xargs readlink -f)
UE4_PROJECT_ROOT=$(dirname "$UE4_TRUE_SCRIPT_NAME")

# Ensure the server binary is executable
chmod +x "$UE4_PROJECT_ROOT/<REPLACE ME>/Binaries/Linux/<REPLACE ME>"


# If we're root, drop privileges and run as 'unreal'
if [ "$(id -u)" -eq 0 ]; then
    # Create 'unreal' user if it doesn't exist
    id -u unreal >/dev/null 2>&1 || useradd -m unreal
    
    # Make sure unreal owns the server files
    chown -R unreal:unreal "$UE4_PROJECT_ROOT"
    
    # Run server as 'unreal' - fixed argument passing
    exec su unreal -c "cd '$UE4_PROJECT_ROOT' && ./<REPLACE ME>/Binaries/Linux/<REPLACE ME> <REPLACE ME> $*"
else
    # Not root, just run normally
    exec "$UE4_PROJECT_ROOT/<REPLACE ME>/Binaries/Linux/<REPLACE ME>" <REPLACE ME> "$@"
fi

```

Once you've replaced the \<REPLACE ME> and ensured things are you right, your game server should now launch.

{% hint style="info" %}
TLDR of what happens: we ensure we can actually run the server and if we're root we make a user called 'unreal' to run it under. Then we launch. Easy.
{% endhint %}
