# How to specify custom /etc/default file in elasticsearch 7

**URL:** <https://discuss.elastic.co/t/how-to-specify-custom-etc-default-file-in-elasticsearch-7/236540>\
**Category:** Elasticsearch\
**Created:** [June 10, 2020, 3:47pm UTC](https://discuss.elastic.co/t/how-to-specify-custom-etc-default-file-in-elasticsearch-7/236540 "2020-06-10T15:47:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nestor\_Manrique](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nestor_manrique/32/70072_2.png) [@Nestor\_Manrique](https://discuss.elastic.co/u/Nestor_Manrique)\
**Post date:** [June 10, 2020, 3:47pm UTC](https://discuss.elastic.co/t/how-to-specify-custom-etc-default-file-in-elasticsearch-7/236540/1 "2020-06-10T15:47:26Z")

</div>

In the documentation it says explicitly

> For the package distributions, the config directory location defaults to `/etc/elasticsearch` . The location of the config directory can also be changed via the `ES_PATH_CONF` environment variable, but note that setting this in your shell is not sufficient. Instead, this variable is sourced from `/etc/default/elasticsearch` (for the Debian package) and `/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the `ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to change the config directory location.

Is there a way to specify my own path for a different `/etc/default/elasticsearch` file for a package distribution installation? I already tried by adding the following in my systemd service file which uses the EnvironmentFile I want, but it still uses `/etc/default/elasticsearch` when the service is comming up.

`EnvironmentFile=-/etc/default/elasticsearch-development`

---

<div class="post-metadata">

**Author:** ![Nestor\_Manrique](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nestor_manrique/32/70072_2.png) [@Nestor\_Manrique](https://discuss.elastic.co/u/Nestor_Manrique)\
**Post date:** [June 11, 2020, 11:36pm UTC](https://discuss.elastic.co/t/how-to-specify-custom-etc-default-file-in-elasticsearch-7/236540/2 "2020-06-11T23:36:42Z")

</div>

The answer to this (at least for version 7.7.0) is that you can't do it seamlessly with any option or environment variable because it is not provided. However it is possible to edit the file `/usr/share/elasticsearch/elasticsearch-env` that comes with the package installation and replace line 81 with the following:

```auto
if [! -z "$ES_DEFAULT"]; then
  source $ES_DEFAULT
else
  source /etc/default/elasticsearch
fi

```

Then it is possible to set `ES_DEFAULT` in the system service file to point to a different `/etc/default` file.

```auto
[Service]
...
Environment=ES_DEFAULT=/etc/default/elasticsearch-development

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 9, 2020, 11:36pm UTC](https://discuss.elastic.co/t/how-to-specify-custom-etc-default-file-in-elasticsearch-7/236540/3 "2020-07-09T23:36:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
