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?

2
  • try this link
    – Lety
    Nov 30, 2014 at 15:32
  • and this
    – Lety
    Nov 30, 2014 at 15:38

2 Answers 2

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.

3
  • 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, 2014 at 14:55
  • @Hinklo: There is a section in the tutorial EnvironmentVariables which deals with this issue, and where editing /etc/sudoers mentions. Probably sudo -E should bee mentioned there too. Nov 30, 2014 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, 2014 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

3
  • I don't want to do that, this is against Ubuntu philosophy
    – Hinklo
    Nov 30, 2014 at 14:48
  • 1
    If you did enable the root user, then you wouldn't need su at all would you? You could just log in as root...
    – Xen2050
    Nov 30, 2014 at 14:56
  • That is correct. su becomes redundant in this case. I just wanted to mention that enabling the root user is a possibility. Nov 30, 2014 at 15:01

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