Cannot run command as www-data using su

You are using su which is used to "switch user". Of course it won't work because www-data is a user account which cannot be used to login. You have told it: /usr/sbin/nologin.

Maybe what you want is sudo which is used to "execute a command as another user".

sudo -u www-data ./http-app.py

Without debating su vs. sudo you can try adding -s /bin/sh to your command line. (I could not verify this option is available for jessie since the Debian manpages webserver isn't working: https://manpages.debian.org/)


If you want not only execute one command, but switch to www-data in order to test some stuff for that user, this worked for me:

sudo -u www-data sh

It's a little bit shorter. Exit the session with [ctrl]+[d] or exit

Tags:

Debian

Su