0

su manual

http://manpages.ubuntu.com/manpages/precise/man1/su.1.html

The current environment is passed to the new shell.

Obviously you cant use su in Ubuntu as in su but it has to be always sudo susince the root user is disabled in Ubuntu but it seems this changes the abilities of the su command.

Any explanation?

Xen2050
  • 8,588
  • 4
  • 32
  • 51
Hinklo
  • 626
  • 3
  • 9
  • 25
  • try this [link](http://askubuntu.com/questions/503583/i-dont-know-what-does-sudo-su-bash-mean/503634#503634) – Lety Nov 30 '14 at 15:32
  • and [this](http://askubuntu.com/questions/487785/why-cant-a-process-see-environment-variables-set-in-etc-environment/488190#488190) – Lety Nov 30 '14 at 15:38

2 Answers2

4

I think I read somewhere that sudo does not pass along all environment variables on purpose, since that could be used to introduce root exploits (not unlike the recent bash bugs). Or you may need to use sudo with -E

 -E, --preserve-env
             Indicates to the security policy that the user wishes to pre‐
             serve their existing environment variables.  The security
             policy may return an error if the user does not have permis‐
             sion to preserve the environment.

So you may have a different "security policy" set, somewhere. man sudo has more info, it appears to have more settings than just su does.

Xen2050
  • 8,588
  • 4
  • 32
  • 51
  • I see! I always thought sudo was a friendly command, now I know that it can ruin lots of things. sudo -E is my new friend. – Hinklo Nov 30 '14 at 14:55
  • @Hinklo: There is a [section in the tutorial EnvironmentVariables](https://help.ubuntu.com/community/EnvironmentVariables#sudo_caveat) which deals with this issue, and where editing `/etc/sudoers` mentions. Probably `sudo -E` should bee mentioned there too. – Gunnar Hjalmarsson Nov 30 '14 at 17:52
  • FYI, I just searched (`/` key) in `man sudo` and `man su` for "environment" or "variable", in the future for something acting strangely `man [xxxx]` is a good place to start looking. (And you can always accept / check mark my answer if you like :) – Xen2050 Nov 30 '14 at 22:49
0

You can use su directly if you have enabled the root user by setting a password for the same.

This can be done with the command

sudo passwd root

Rohith Madhavan
  • 8,229
  • 5
  • 24
  • 43