1

Java build machine is on Redhat 7.5 to run mvn clean package deploy for building Java code.

Multiple users login with their username to this build machine, to build Java code.

To permanently set JAVA_HOME & update PATH environment for all users,

Updating /etc/profile needs sudo source /etc/profile for every login, by every user. All users are part of wheel group

Edit:

Using sudo on internal command is invalid


How to permanently set these variables, for every login?

overexchange
  • 15,768
  • 30
  • 152
  • 347
  • Are all your users using the bash shell or another shell? For bash, /etc/profile is usually read automatically and doesn't need to be sourced explicitly. Have you made sure that you exported the variables? – RealSkeptic Dec 25 '18 at 15:28
  • @RealSkeptic It is bash. I did not export – overexchange Dec 25 '18 at 15:47
  • 1
    Without export, those are not environment variables but shell variables. So you have to export. Emma's answer is the correct one. – RealSkeptic Dec 25 '18 at 15:59

2 Answers2

2

Editing /etc/profile should work, but not recommended. you should create a new file in /etc/profile.d/ and set the JAVA_HOME there with export.

1

There are some strange points in your question.

sudo source /etc/profile should normally give the answer sudo: source: command not found. source is not a command, but an internal. You can't sudo it.

Updating /etc/profile should work if the permissions on /etc/profile are correct, that is, at least r-- (644) for all users, although 755 is also common. In any case, do not restrict your /etc/profile to a specific group.

Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31