Apple - How to login as a different bash user in terminal?

Use login:

$ login
login: username
Password:
Last login: Day Month Date HH:MM:SS on ttys000
$ whoami
username


The sudo is failing because the _www user has /usr/bin/false as its shell, causing the session to end as soon as you've switched user.

The solution is to use the -s option, which will execute your current shell instead of _www's shell:

$ sudo -s -u _www
Password:
$ whoami
_www

Just tested on a 10.9 system but it should work fine on 10.8.

Tags:

Macos