Ubuntu 12.04 setting /etc/environment variables

0

If I set a variable in /etc/environment, it only seems to apply to administrators while in sudo su.

How can I get the variables to apply to everyone? Especially when they are in terminal?

MichaelGuest

Posted 2013-02-26T03:09:45.500

Reputation: 1

Have you checked the mode (permissions) of the /etc/environment file?  It should probably be set to 644 (rw–r––r––). – Scott – 2013-02-26T03:36:55.733

It set to: -rw-r--r-- – MichaelGuest – 2013-02-26T04:06:20.083

Answers

0

One way to do this may be to add the variables into /etc/.bashrc (assuming everyone is using a bash shell)

davidgo

Posted 2013-02-26T03:09:45.500

Reputation: 49 152

1Um, are you sure that’s the file you mean?  Not /etc/profile? – Scott – 2013-02-26T03:52:33.580

@scott - Yes, I'm sure thats the file I meant, but after googling a bit, /etc/profile is probably better. – davidgo – 2013-02-26T04:10:23.247

0

If you want to setup variables to apply to everyone, the best place is neither /etc/environment nor /etc/profile, because they are system files -- messing them up will give you headaches when you system is upgraded.

Best approach:

  • Create your own files under /etc/profile.d/,
  • Give it a .sh extension
  • make it executable (via chmod 755 file)

That's it. When you need to have similar setting on different boxes, or when it time to do a brand new installation, or any similar situation. Just backup/copy the file over, and you are done for the day.

HTH

xpt

Posted 2013-02-26T03:09:45.500

Reputation: 5 548