Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I defined several environment variables in /etc/environment, but a process (build started by TeamCity) cannot see their values. I don't know what I'm doing wrong here.. this is the content of my /etc/environment file:



ACTIVEMQ_OPTS_MEMORY="-Xms128m -Xmx192m"


The build started by TeamCity uses a Maven runner, and which at some point kicks an Ant build. Since the build was failing, I used Ant to print all environment variables in the system:

<!-- Provides all environment variables as Ant properties prefixed by "env.".
For example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH} -->
<property environment="env"/>

<echo>List of all Environment Variables found in the system:</echo>
        <propertyref prefix="env."/>

Sure enough, the ones I set in /etc/environment don't show up.

The build agent running this is started using Ubuntu's Startup app's, where I configured it to run the command:

sudo -H -u administrator /bin/bash --login -c "~administrator/BuildAgent/bin/ start"

Could it be that this line runs before /etc/environment are set?

If I do a echo $CATALINA_HOME I see the value properly set, but the build for some reason cannot see it...

NOTE: Although I know it is the wrong way of doing it, I also tried adding export to the declarations inside /etc/environment, without any success. Then I removed it.

NOTE 2: I rebooted the machine after making changes to /etc/environment file, of course.

I'm on 14.04 LTS Server with minimal desktop installed (ubuntu-desktop --no--install-recommends) plus a few extras.

Any help is appreciated, thank you!

share|improve this question

Read carefully sudo man page SECURITY NOTES.

try -i option that (simulate initial login) option runs the shell specified in the passwd(5) entry of the target user as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed. sudo attempts to change to that user’s home directory before running the shell. It also initializes the environment, leaving DISPLAY and TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and PATH, as well as the contents of /etc/environment on Linux and AIX systems. All other environment variables are removed..

    sudo -u administrator -i "~administrator/BuildAgent/bin/ start"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.