9

How do I set global environment variables in Ubuntu, in such a way, that they would apply also to root user?

Setting PATH or JAVA_HOME in /etc/environment
or in /etc/profile.d/my_settings.sh
both works for usual user, but not for root.

I'm logging in as root using sudo bash or sudo zsh.

NOTE: using Ubuntu 10.04.

0

1 Answer 1

12

You will need to get into a real root login shell:

sudo su -
4
  • I get an error: "Sorry, user [...] is not allowed to execute '/bin/su' as root on [...]" Sep 26, 2011 at 10:37
  • Have you used sudo before su?
    – enzotib
    Sep 26, 2011 at 16:47
  • 7
    sudo -i also works.
    – elmicha
    Sep 26, 2011 at 17:39
  • 1
    @AleksandrDubinsky sudo su without the hyphen (not an en-dash or em-dash; that could break things) does not execute /etc/profile, which does not answer OP's question
    – Doktor J
    Jul 8, 2016 at 17:49

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