I want to run GeoServer 2.14 with Jetty on a Ubuntu 18.04.
I copied the war-file in the `webapps` folder and GeoServer is responding.

Unfortunately I can not set the data directory location as described in the [GeoServer docs](https://docs.geoserver.org/stable/en/user/datadirectory/setting.html#linux).

I appended the following line to `/etc/environment`: 

```
GEOSERVER_DATA_DIR="/opt/geoserver_data"

```

After logging in to the system the variable is set as expected: 

```
#echo $GEOSERVER_DATA_DIR
/opt/geoserver_data

```

I also created the folder `/opt/geoserver_data`: 

```
#ls -la /opt/geoserver_data
total 8
drwxr-xr-x 2 root root 4096 Nov 12 15:20 .
drwxr-xr-x 5 root root 4096 Nov 12 15:20 ..

```

When I restart Jetty, the first two GeoServer log lines are:

```
INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-6077051313967886521.dir/webapp/data
INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-6077051313967886521.dir/webapp/data

```

This is strange because according to the [GeoServer source code](https://github.com/geoserver/geoserver/blob/445625cdad44e79c48682b0c9852e1e2586c018e/src/platform/src/main/java/org/geoserver/platform/GeoServerResourceLoader.java#L563), there should be a warning that the given folder does not exist or is not writable.

Obviously I am doing something wrong, but I have no idea what?

---

Based on [Ian Turton's answer](https://gis.stackexchange.com/a/302325/26663), I ensured that `jetty` is not run as `root`.
Furthermore I start jetty now with `-DGEOSERVER_DATA_DIR=/opt/geoserver_data`, which is easier to handle than a system variable.

At the moment I still get the following warning messages: 

```
WARN [geoserver.platform] - Found Java environment variable GEOSERVER_DATA_DIR set to /opt/geoserver_data , which is not writeable
INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-1540535100624462590.dir/webapp/data

```

But at least the expected warning is shown. Although the fallback data directory still looks odd.