6

I'm using Ubuntu 10.10

When I log in using normal GUI desktop, it seems that the environment is not the same with the terminal.

I modified $PATH and other information in .bashrc. But, this doesn't apply to the GUI session.

The actual problem is like this:

  • I made a shortcut to Eclipse on Ubuntu desktop. When I click it, it complains it can't find JVM path.
  • But, launching Eclipse from the terminal is okay.

How can I solve this problem?

1 Answer 1

8

There are three recommended ways:

Session-wide environment variables

Environment variable settings that should affect just a particular user (rather than the system as a whole) should be set into:

~/.pam_environment

System-wide environment variables

Environment variable settings that affect the system as a whole (rather than just a particular user) should not be placed in any of the many system-level scripts that get executed when the system or the desktop session are loaded, but into

/etc/environment

Launching desktop application with an environment variable

You can add an environment variable to an application by editing its .desktop file. For example, to run "digiKam" with the environment variable APPMENU_DISPLAY_BOTH=1, find the corresponding digikam.desktop file and add the setting of the variable, via the env command, to the entry "Exec":

Exec=env APPMENU_DISPLAY_BOTH=1 digikam -caption "%c" %i

You should read this article and decide which method best suits for your needs:

Ubuntu Community Wiki: Environment Variables

5
  • /etc/profile too Feb 21, 2013 at 3:28
  • @technosaurus: That's what I thought, too, but it is specifically not recommended by the referenced Ubuntu article.
    – garyjohn
    Feb 21, 2013 at 6:04
  • also ~/.profile works too.
    – Hieu
    Feb 13, 2017 at 15:35
  • is there an easy way to see these variables?
    – Ben Creasy
    Oct 28, 2018 at 19:05
  • @BenCreasy, Yes, you can use env or printenv command from GNU coreutils with no parameters. Run it in xterm or similar terminal emulator to see the effective environment variables in GUI session. The article at the end of my answer has more info.
    – sm4rk0
    Oct 30, 2018 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .