Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

From here (

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.

share|improve this answer
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 at 7:55

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 ?

share|improve this answer
As for meta-search -- any "native" option is missing for the moment, but there is custom Google search for stack exchange – ジョージ Oct 21 '12 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 '13 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 at 7:48

You're looking for the -r option.

share|improve this answer
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. – Lester Peabody Oct 7 '11 at 18:15
I recommend you look at the useradd(8) man page to see how it affects the user created. – Ignacio Vazquez-Abrams Oct 7 '11 at 18:25

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.