Setting (permenant) environment variables in Ubuntu 10.0.4

2

I am running an application which requires setting environment variables to be set.

At the moment, the way I am achieving this is by exporting the EV at the command line, and then running the app from the command line.

I want to be able to run the app from my menu (it is already a menu item after I installed it).

How may I set the env var so that it is always available, so I can just run the app from the menu instead of from the CLI?

morpheous

Posted 2010-09-04T10:40:22.530

Reputation: 3 533

1systemwide or per-user? – akira – 2010-09-04T10:43:13.977

Answers

3

Add the environment variable declarations to the file .profile in your home directory:

export NAME='value'

If there are single quotes in the value, replace them by '\'' (there are other quoting mechanisms, this one is just the simplest to explain).

If you want to make the variables available to all users, add the declarations to /etc/profile.d/my-app-environment.sh (replace my-app-environment by a more descriptive name).

Gilles 'SO- stop being evil'

Posted 2010-09-04T10:40:22.530

Reputation: 58 319

Did Lucid change /etc/profile from a file to a directory? – Paused until further notice. – 2010-09-04T15:03:35.573

@Dennis: no, I meant /etc/profile.d, thanks for pointing it out. Since at least Ubuntu 8.04 and Debian lenny, /etc/profile sources /etc/profile.d/*.sh. – Gilles 'SO- stop being evil' – 2010-09-04T18:39:31.327

@Dennis, No - /etc/profile file loads what is in /etc/profile.d directory – laurent – 2010-09-04T18:40:25.770

@laurent: Yes, I know. It was a typo that threw me. – Paused until further notice. – 2010-09-04T18:59:32.800