I want to create an unprivileged user to run my RhodeCode server and Celery daemon on a CentOS instance. I think the accepted definition of this is no home directory, login disabled, and no shell access? Looking over the man page for adduser I just don't see an intuitive method for doing this. Any suggestions are appreciated. Thanks.

3 Answers 3


I think I should link here two answers from serverfault:

Basically -r means "set account as a system one" -- "no expiration", etc -- and the full spell may look like

useradd -s /bin/false -r <username>


useradd -s /usr/sbin/nologin -r -M -d /dev/null <username>

or similar )

NB. For things like samba one may also want to provide this user with a password and may be also add /usr/sbin/nologin to /etc/shells :

# which nologin >> /etc/shells

NB(2): as per OrangeDog's comment: -r actually implies -M, so -M is not strictly necessary.

PS. And yes, looking for the same thing at serverfault, askubuntu -- and here -- seems a bit odd to me; is there a way to run a meta-search on, say, all stackoverflow sites ?

  • As for meta-search -- any "native" option is missing for the moment, but there is custom Google search for stack exchange Oct 21, 2012 at 4:45
  • I've seen services like named using /sbin/nologin in /etc/passwd. So how do they start their services?
    – Antarus
    Oct 30, 2013 at 6:20
  • @OrangeDog: I don't have a CentOS system at my disposal right now, but on both Redhat and Debian -d is not ignored; it is strange that none of the reviewers had actually bothered to test ) Jul 4, 2015 at 7:48

From here (centos.org)

useradd (which is the actual binary the runs when you call adduser, it just behaves differently. See here about that.) has an flag -r which is documented as follows:

-r   Create a system account with a UID less than 500 and without a home directory

Which sounds like what you want to do.

  • Interestingly, at least on Redhat /etc/passwd will have a home directory entry (/home/username by default); the directory, of course, won't exist, but that's kinda strange ) Jul 4, 2015 at 7:55

You're looking for the -r option.

  • I just created a user using adduser -s /sbin/nologin -M rhodecode, but the -r option does seem to be what I'm looking for. What is the difference between using -r and what I did? I'm a shell scripting noob, sorry. Oct 7, 2011 at 18:15
  • I recommend you look at the useradd(8) man page to see how it affects the user created. Oct 7, 2011 at 18:25

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.