Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Last night, on my server, I did:

sudo su - mysql 

to change to the mysql user so I could run the mysql client, which is set up so it will only authenticate from the mysql account. I successfully ran the mysql client and made the change to the database. Nothing changed on the server overnight.

Today, nothing I try will allow my to change to the mysql user. It appears to succeed, given the message about no home directory, but whoami still reports my user id and trying to run mysql still fails.

wade@snoopy:~$ sudo su - mysql
[sudo] password for wade: 
No directory, logging in with HOME=/
wade@snoopy:~$ whoami
wade

wade@snoopy:~$ sudo su mysql
wade@snoopy:~$ whoami
wade

wwilliam@snoopy:~$ sudo -s
root@snoopy:/home/wade# 
root@snoopy:/home/wade# su mysql
root@snoopy:/home/wade# whoami
root

/etc/passwd for mysql:

mysql:x:110:119:MySQL Server,,,:/nonexistent:/bin/false

Has anyone ever seen behavior like this?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

su invokes the other user's login shell as given in /etc/passwd. In your case that's /bin/false so you don't get any interactive shell.

Use

sudo -u test /bin/bash

or

sudo -u test /usr/bin/mysql

or something like that instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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