Setting up wide env variables for every users.


I try to set env variables of my own for every users.
Every users log in graphical env : KDE dektop.

I have create a file : /etc/profile.local and put in it :

if  "$PROFILE_LOCAL_READ" != "true" ]] ; then
    # For all users

    export PATH=/backup_sys/000_COMMON/Bin:$PATH

# set only once
if  -z "$PROFILE_LOCAL_READ" ]] ; then
    readonly PROFILE_LOCAL_READ=true

The script “/backup_sys/000_COMMON/Bin/system_wide_common_env_set”
source two other scripts

source "/backup_sys/000_COMMON/Bin/system_common_general_env_var"
source "/backup_sys/000_COMMON/Bin/system_common_function"

The file /backup_sys/000_COMMON/Bin/system_common_general_env_var contains :

declare -i   E_BAD_ARGS=3  E_BAD_OPTS=4  .....
export E_BAD_ARGS  E_BAD_OPTS .... 

And the file /backup_sys/000_COMMON/Bin/system_common_function contains

function date2stamp_full2  {
#    "2016-11-27__14h15m02s"
    date --date "$1" +%Y-%m-%d__%Hh%Mm%Ss
function date2stamp2  {
#    "2016_11_27__14h15"
    date --date "$1" +%Y_%m_%d__%Hh%M
export -f date2stamp_full2 date2stamp2 ........

After log in, In a terminal (konsole) when I test a variable, it is unset.
I have used the command logger to display value in the journal.
It seems OK

So it seems that I have to put the assignment directly in /etc/profile.local
Or may I source the file from /etc/profile.local
Or what else

Any help is welcome.

NAME="openSUSE Leap"
PRETTY_NAME="openSUSE Leap 42.2"

#1 SMP Fri Apr 21 16:14:48 UTC 2017 (84f9824)

GNU bash, version 4.3.42(1)-release (x86_64-suse-linux-gnu)

Without specific data,
I wouldn’t know why you may be experiencing problems but

2 things jump out at me… which may or may not be relevant…

  • The file /etc/profile and /etc/profile.local are read on boot.
    For that reason, there are relatively few if any differences how the settings might vary.
    So, are you sure you should be writing conditional statements? If the statement is true every time for example, then IMO you should just set the environment variable and not test conditionally whether to do so.

  • This more a matter of form, but you seem to like placing scripts in binary (bin) folders. I generally only place compiled binaries in bin folders and locate scripts elsewhere. It’s just keeping things categorized consistently, a small thing with benefits down the road.

While troubleshooting and creating your scripts, since your lines of code are so few you might combine them into a single script at least temporarily instead of their current modular form to be certain they all execute properly, and then instrument critical steps (you describe using a command logger of some type), you can also insert additional feedback writing to a file or if a console can be opened you can echo to stdout.


You run this script as command which means it does not modify state of shell that is sourcing profile.local.

Or may I source the file from /etc/profile.local


This is the way /etc/profile is written :

# Avoid overwriting user settings if called twice
if test -z "$PROFILEREAD" ; then
    readonly PROFILEREAD=true
    export PROFILEREAD

I used the same way for my own variable “PROFILE_LOCAL_READ”.

Not really on my Leap system ( fresh install ).
Analyzing systemd journal I can say that these files are read as soon as a user log in successfully.

Any way thank you for trying to help me.

It works.
I should have guessed it myself

Thank you.