How to login from terminal ?

Asked by Emad William

how to log off the current user of the terminal (of Gnome, the one in Applications->Accessories) and sign in using another one ?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Solved by:
Emad William
Solved:
Last query:
Last reply:
Revision history for this message
Raphaël Walther (rafikiwi-deactivatedaccount) said :
#1

Hello Wiliam,

Use the "su" commande to become another user i.e. :
su andrew
to log as andrew.

Hope this help.

Regards,
Raphaël

Revision history for this message
Emad William (emadwilliam) said :
#2

Thanks for answering.
Is there anyway to pass the password as an argument, because I want to call it from php.

Revision history for this message
Raphaël Walther (rafikiwi-deactivatedaccount) said :
#3

Emad,
I don't know. I have found nothing which can help in the man page "man su".
Regards,
Raphaël

Revision history for this message
Lasse Luttermann (lasse-luttermann) said :
#4

You could use something like
$ sudo su - USERNAME -c 'command_to_be_executed'

sudo makes the command be executed as root, and then su doesn't need a password. and sudo doesn't need one if it is specified in it's config file.
man sudo
man sudoers

This is kind if a dirty hack, be ware that it is dangerous to have anything running as root! including the su command.

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#5

To logout from a user you can use the:

logout

command or

exit

command or type CTRL+D from keyboard

Hope this helps

Revision history for this message
Okougbo Lexity (lexity-okougbo) said :
#6

tanks