I want to open a terminal (xterm, gnome-terminal, tilda, whatever) and have it prompt for a username and password to login as. I thought this would be simple but all my Google results are polluted with stuff about making bash a login shell, which means something completely different as running bash --login produces does not ask for a username and password.

Surely there is a way to do this?

EDIT: The environment is an embedded device. I want to have a way for technicians to be able to open a terminal overtop of the WebUI/browser, login and fix stuff.

ANSWER: xterm -e login

OR (more dangerously) something along the lines of:

while :; do
  read -p "User: " USER
  su - $USER -c "bash";

closed as unclear what you're asking by jasonwryan, slm, msw, Anthon, Flup Apr 24 '14 at 7:53

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Login to... what? – jasonwryan Apr 24 '14 at 1:33
  • Login to a shell. – hamstar Apr 24 '14 at 1:39
  • 3
    You are logged in already... This sounds like an X-Y problem: what exactly are you trying to achieve? – jasonwryan Apr 24 '14 at 1:46
  • 1
    Or if you want to login in as another user, use su (as an example: su - anotheruser) – Drav Sloan Apr 24 '14 at 1:53
  • Yes but I wish to have a terminal open but no access to shell until someone logs in. – hamstar Apr 24 '14 at 2:14

Well, you could try this:

Open Terminal Preferences -> Profiles -> Select the profile click edit -> In "Title and Command" Tab, enable "Run a custom command instead of my shell" and in "custom command" text box enter su - <login user>

Apply the settings and open a new terminal window to see if it works as desired.


If you are interacting with an x window server (gui), then by this point you have already logged in. There is no reason to prompt for what user to become since you are already authenticated.

Your options are:

  • Log out and log in as a different user
  • Use su foo to change to a different user

Perhaps what you are really looking for are virtual consoles.

ctrl + alt + x ( where x = any one of the function keys, F1, F2, ect..)

( Use ctrl + alt + F7 to return back to your original x window )

You will then be prompted which user to log in as.

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