Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running FreeBSD 7 and apache-2.2.13.

I am trying to debug a cgi script at . This script is a simple script written in Bourne shell.

I would like to run this script from the unix commandline, as user 'www'. However, the user 'www' does not have a shell (by design). This means I cannot 'su' to user 'www' to execute this script:

# su www -c /usr/local/www/apache22/cgi-bin/printenv
This account is currently not available.

# su - www -c /usr/local/www/apache22/cgi-bin/printenv
su: no directory

How can I run this script as user 'www'?

share|improve this question
up vote 1 down vote accepted

Your first example is fine - that error probably means the shell is currently pointed to nologin. Simply change it to a valid shell or use something like sudo which is sort of a hack but would work.

[root@monkey]# grep monkey /etc/passwd

[root@monkey]# sudo -u monkeyman echo "hi"
[root@monkey]# su monkeyman -c 'echo hi'
This account is currently not available.
share|improve this answer
This is Linux however I suspect the same behavior. – WinkyWolly Mar 23 '11 at 0:59
The same behavior happens on Linux. However, Linux has a su --shell=/bin/sh option to bypass this problem. – Stefan Lasiewski Mar 24 '11 at 17:39
I was hoping to avoid sudo (I was hoping to avoid any system modifications). But it seems this is the only option for me. Thanks. – Stefan Lasiewski Mar 24 '11 at 17:40
Ah, I never thought to check if I could set a shell with su. Good catch :). – WinkyWolly Mar 26 '11 at 18:49

Have you tried what is suggested on Run as different user under FreeBSD?

share|improve this answer

Your Answer


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.