This is a question that I would expect to quickly get an answer from google. However somehow google is failing me. Let's assume I'm logged in to a terminal session and I would like temporarily work as another non-root user whose password I know without leaving my session. When logged as this user I want the home directory, etc, for this user set up correctly until I log out. How do I do that?

I tried

su -- username

and then keying in the password, it did not produce any error but I saw no visible changes of the command prompt it would still say myname@myhost. The home directory also was that of myname and not the new login I tried to login as.

I'm - as it's apparent now - quite inexperienced in linux/Ubuntu, so any info is welcome.

2 Answers 2


To which user you want to change to?

The problem is that you are trying to "su" into a user that does not have a shell assigned to it. Most of the users such as mysql, pulse, etc, created by the system or by some packages when you install software does not have a shell assigned.

You can check if a user has a shell assigned by looking into the /etc/passwd file, just look at the end of the line of each user, if it says /bin/false it means that it does not have a shell assigned, if it has something like /bin/bash or any other shell, then you should be able to "su" into that user.

When i say "shell assigned" it basically means that it has "shell access"

still if the user does not have shell access, you can always execute commands as that user with

 sudo -u user command
  • still if the user does not have shell access, you can always execute commands as that user with "sudo -u user command"
    – Sam
    Nov 16, 2012 at 5:55
  • 1
    Append -s /bin/bash to your su command or use chsh -u username -s /bin/bash to change the shell for a user. Beware of the security implications this might have.
    – gertvdijk
    Nov 16, 2012 at 8:24

if you have sudo access then I would recommend

sudo su username -

It does basically the same thing, but only requires you to know your password not the other users.

however if you have the other users password:

su username - should work just fine.

notice the 1 - and that it's at the end.

  • Somehow both ways you described behave exactly as mine - the command is accepted without error but the home directory is not right and the prompt says that I'm still the original user. If I do logout after that I logout completely. Nov 16, 2012 at 5:43
  • Ok, is the user your logging in as allowed to log in? You can block account from logging in by setting their shell to "true" and that will do exactly as you describe. This used to be used alot on "system" account like "apache" and "ftp" To check sudo cat /etc/passwd DO NOT PASTE THE CONTENT HERE. Just eyeball it and make sure the user has a real shell as the last little bit of their line.
    – coteyr
    Nov 16, 2012 at 5:50
  • 1
    side note, the more proper way to do this is setting a shell to "false" which will throw an error. Though some systems and accounts still use true for technical or psudo-security reasons (to aggravate the snot out of wana-be-hackers)
    – coteyr
    Nov 16, 2012 at 5:51

You must log in to answer this question.

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