Elasticsearch database runs as a user elasticsearch and this user is part of a group named elasticsearch. This user and group gets automatically created at the time of installation (if installed using packages).

Every user and group in Linux has an id. User is is called UID and group id is called GID.

Usually the UID and GID of the elasticsearch user and group will be same across all the Elasticsearch installations. But in some cases, if some other user or group exists in the system with the same id, then the elasticsearch user and group will get a different id rather than the default ids.

In some cases, we may have to make adjustments to the elasticsearch uid and gid. This is required in case of mounting same snapshot repository across multiple Elasticsearch clusters.

The steps for updating the UID and GID of elasticsearch are given below. It is very simple.

# To Know your elasticsearch gid and uid
id elasticsearch  

# Stop the Elasticsearch
service elasticsearch stop

# Update the UID of elasticsearch
usermod -u NEWUID elasticsearch

# Update the GID of elasticsearch
groupmod -g NEWGID elasticsearch

# Update the files owned by old UID with new UID
find / -user OLDUID -exec chown -h NEWUID {} \;


# Update the files owned by old GID with new GID
find / -group OLDGID -exec chgrp -h NEWGID {} \;

# Start the Elasticsearch
service elasticsearch start

I hope this tip is useful. Feel free to comment if you have any questions or feedback.