While logged in as root I would like to su to a specific regular user. I run su username and immediately receive the prompt back, still as root. There is no error given. I'm aware of the old "the user you're trying to su to doesn't have permission for the folder you're currently in" problem, and that's not the case in this scenario. Furthermore, there is no error displayed, which is always the case (as far as I know) when that particular permissions issue is encountered.

I've tried su - username with the same effect. The command is processed, no errors are seen, and I receive the prompt back immediately.

What could be causing this behavior? How can I troubleshoot this?

  • 8
    What shell does the user have? Is it /bin/false? – camh May 25 '12 at 5:47
  • 4
    You should really be using sudo -u username -s (or -i) BTW. – mgorven May 25 '12 at 6:57
  • 2
    @camh facepalm That was it. I swear I checked /etc/passwd last night and it wasn't like that! =) Can you put that as an answer? I'll accept it. – Wesley May 25 '12 at 17:05

Check what shell the user has in /etc/passwd. If the shell is /bin/false (a common shell to disallow logins), then you will see the behavior you describe. Alternatively, it may be some other immediately-terminating program that gives the same effective result.

  • 2
    That was it. I swear I looked first! =) – Wesley May 26 '12 at 2:42
  • 25
    And if you need to debug something under user which has /bin/falseas its shell, you can do it with su - user -s /bin/sh. – Marki555 May 27 '12 at 8:47

I'd suggest using strace on the su process to see where the process is failing.

strace su donaldduck

Should give you LOTS of output to sort through, but something in there should indicate where the problem is occurring.

  • 1
    Stupid markdown.... – Magellan May 25 '12 at 5:32

You should check the shell in /etc/passwd, and, without wishing to be patronising, check the output of whoami after running su.

  • 1
    Not sure why that would be considered patronizing, for I certainly wouldn't have taken it that way. I mean I can if you want, but that wouldn't be my first inclination. =) Anyway, yes, I forgot to state that I did that just to make sure I was who I thought I was, and I was still root and not the user I was trying to switch to. – Wesley May 25 '12 at 16:59

Check your system logs : using sudo should log all the actions. So if there is a problem, it should be written.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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