I want to su - nginx so I can check if I have set up soft and hard limit for opened files correctly.

Why can't I su - nginx? I get an error *No passwd entry for user 'nginx'*


Of course the user was www-data not nginx... When I do su - www-data I get This account is currently not available.

Basically what my question is, I want to see limits for opened files. If I do ulimit -n under root, I get 1024, which I know is wrong...

  • 1
    duplicated: stackoverflow.com/a/27849503/290338 – Anatoly Sep 8 '15 at 7:56
  • Your question has grown significant hair. It would be polite to clean it up. Ask the question you want to ask, and leave irrelevancies out of it. Note that you don't have to actually login as a user in order to check the limits applied to a process running as that user. – womble Sep 8 '15 at 9:03
  • Just for the record, you need to give www-data a login shell like this: su - www-data -s /bin/bash – Moritz Apr 8 '19 at 14:19

You have something of a misunderstanding. On most Linux systems, PAM sets resource limits when users log in as configured. But nginx never logs in. So you're measuring something that has nothing to do with anything -- nobody ever logs in as the www-data process, you weren't even able to do it, so whatever file limit that process creates wouldn't be one that affected anything.

The nginx process is started by some other process and inherits that process' resource limits. The launch script may or may not change them, and the nginx process itself may or may not change them. You can investigate this if you want, but not by logging in as the www-data user.

  • Thank you for additional information. As I understand PAM read the limits from /etc/security/limits.conf. I added there higher limits, but when I do ulimit -n, I still get the old value. I have restarted nginx and server. I guess my problem is how can I verify what resource limits there are set by the OS for nix... – Badr Hari Sep 8 '15 at 9:49
  • @BadrHari You're changing the limits set by PAM when the user logs in, but the user never logs in. So what you're doing doesn't make any sense. You need to look at how nginx is started on your platform and how nginx itself is configured. – David Schwartz Sep 8 '15 at 9:50

it looks like that there is no user nginx configured on the system.

Check with cat /etc/passwd | grep nginx

if you get This account is currently not available it means that there is no valid shell configured in /etc/passwd. Check this site on instructions how to fix it.

  • 1
    uh... embarrassing, it's www-data of course. But when I do su - www-data I get This account is currently not available – Badr Hari Sep 8 '15 at 7:54

Nginx is has a system user that have no ability to login, because the shell is /sbin/nologin (or even /bin/false) so you can just SU to it. Uou need to instruct the su command which shell to execute for us.

su nginx -s /bin/bash
ulimit -n

If you want to check limit for user www-data without editing /etc/passwd you can simple run following command:

su www-data -c 'ulimit -n' -s '/bin/bash'

  -c, --command COMMAND         pass COMMAND to the invoked shell
  -, -l, --login                make the shell a login shell
  -s, --shell SHELL             use SHELL instead of the default in passwd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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