1

I am referring to the following URL Setting the JAVA_HOME

I am interested in the last solution given by Nils, that edit the /etc/profile.local file, this will set it for all the users. The question is that I am using openSUSE 12.3 and it does not have /etc/profile.local.

What should be done in this case?

3 Answers 3

3

The /etc/profile.local file used to be the location to make system specific changes that would not be overwritten when /etc/profile would get an update.

Your system might still source the file if it exists, you could either check /etc/profile to see if it does (search for the profile.local filename, or just create the file and try out.

However, if you have a directory /etc/profile.d, and if your /etc/profile has something like (this is from Ubuntu 12.04) the following in it:

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

then this mechanism sources (. $i) each of the files found in that directory. That is a more modern solution to the single .local file (with the advantage of different packages being able to drop in their files and remove them as needed without breaking something else). If your OpenSUSE has something like that, you can just create a file /etc/profile.d/your_name.sh and put the required code in there.

If you don't have all of that you can add the lines directly to /etc/profile, but you do run the risk of loosing your changes on a package upgrade.

1
  • I have tried this, as there is no file profile.local in /etc/ ,I have created a new /etc/profile.local and edited it with JAVA_HOME=/usr/java/jdk1.7.0_05 export JAVA_HOME
    – Harbir
    May 4, 2014 at 19:29
0

From the openSUSE first rows of /etc/profile :

# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

This means that you have to create (from root account) the /etc/profile.local . Then /etc/profile will automatically source even /etc/profile.local that will be preserved upon packages updating.

0

From my openSuSE 15.2 system's /etc/profile:

#
# And now let's see if there is a local profile
# (for options defined by your sysadmin, not SUSE Linux)
#
test -s /etc/profile.local && . /etc/profile.local

On our production SLES 12.3 server, it has the same thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.