16

I have to check if my web page running locally on nginx does not work due to permission issue. My web scripts are running as _www user, so I tried to switch to _www but this does not work:

maciek@macus:~$ sudo su - _www
Password:
maciek@macus:~$ whoami
maciek

How can I do this in 10.8.5?

12

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.

  • normal users should not use sudo. – CousinCocaine Jan 5 '16 at 11:38
  • 1
    @CousinCocaine define normal? are we normal? – Ray Foss Sep 20 '17 at 17:28
16

Use login:

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

  • 1
    I don't think that system users have passwords. It prompts for password, and empty does not work. – Maciej Sz Apr 2 '14 at 19:13
  • 3
    this is the correct way to do it. – CousinCocaine Jan 5 '16 at 11:37
  • As the OP commented, this won't work for users that don't have passwords (which the _www user won't have by default, nor should it have one). – mjturner Jan 5 '16 at 13:53

You must log in to answer this question.

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