Operating System - Linux
1820635 Members
1783 Online
109626 Solutions
New Discussion юеВ

How to set environment variables for all users

 
SOLVED
Go to solution
Carles Viaplana
Valued Contributor

How to set environment variables for all users

Hello,

I need to set some paths for all users into my system. Is there any way to do this in suse linux 8?

I notice there's /etc/PATH file in HP-UX systems, but I don't know if there's something similar in Linux systems.

Thanks in advance for your help.
Regards,

Carles
6 REPLIES 6
Alexander Chuzhoy
Honored Contributor

Re: How to set environment variables for all users

It depends on the shell they use.
If they use bash (default in redhat linux)
and all the accounts are local, then they all "source" the /etc/bashrc file (by default).
Thus appending variables to /etc/bashrc will influent all users.
Carles Viaplana
Valued Contributor

Re: How to set environment variables for all users

Hello,

all users are local and are using basch shell.

In fact I need to add some paths to environment path variable and I have no idea where can I set it up.

I tried to create profile.local as copy from /etc/profile and I added paths, but it seems system doesn't like this kind of modifications.

Any idea?

Thanks in advance for your help.
Regards,

Carles
Alexander Chuzhoy
Honored Contributor

Re: How to set environment variables for all users

Let's say you want to add /tmp folder to a path:
edit the file /etc/bashrc
append to its end the line
export PATH=/tmp:$PATH

save and exit
then as one of your users execute this command:
source /etc/bashrc or logout and login back.
Alexander Chuzhoy
Honored Contributor
Solution

Re: How to set environment variables for all users

instead of copying /etc/profile to /etc/profile.local try to only add the necessary line to /etc/profile.local.
In particulat the lines from previous responce.
Hope it helps.
Vitaly Karasik_1
Honored Contributor

Re: How to set environment variables for all users

The easiest way, IMHO, is add a shell script with your commands into /etc/profile.d directory.
Carles Viaplana
Valued Contributor

Re: How to set environment variables for all users

Finally I added just environment variables I need into profile.local instead to copy all.

Thanks to all for your help.
Regards,

Carles