How to change UID of xray user

Prasanna Narayana
2019-07-17 16:25

Summary

Changing the UID of xray user

Details

There might be cases where in due to company policy or some restrictions of the operating system, we might have to change the UID of xray user (default value is 955)  If that is the case, we can change the UID of the xray user by following the steps below and making the necessary additional changes provided below.

Resolution

1. Stop Xray and all the microservices using the command :

./xray.sh stop all

2. Change the UID (For this test we are changing it to 2000) of xray user using the command : 

usermod -u 2000 xray  

3. We have to change the ownership of the directories to reflect the new UID. We need to use the chown command on the following directories.

chown -R xray:xray /var/opt/jfrog/xray/data/

chown -R xray:xray /opt/jfrog/xray/

Before using the chown command, please make sure the contents in these directories are owner by xray user before hand (You can use the command ls -n to check the user and UID of a file/directory). If there are some files which are owner by root user, please keep it as is and do not chown those files/directories.

4. You can now go ahead and start Xray using the command :

./xray.sh start all 

These steps should successfully change the UID of the xray user in your existing set up.

Upgrading: After a successful upgrade, the UID of the xray user will be changed back to 995 so we can perform the above mentioned steps again to successfully change the UID and get Xray server up and running. Be sure to include these steps in any instrumentation you might be using for upgrades.