[CentOS] C5 & C6 : useradd

Sun Jan 25 04:37:36 UTC 2015
Valeri Galtsev <galtsev at kicp.uchicago.edu>

On Sat, January 24, 2015 9:54 pm, Always Learning wrote:
>
> On Sat, 2015-01-24 at 22:45 -0500, Stephen Harris wrote:
>
>> On Sun, Jan 25, 2015 at 03:43:06AM +0000, Always Learning wrote:
>
>> > Should the 'correct' entry be:-
>> >
>> > 	fred:x:504:504:::/sbin/nologin  ?
>>
>> No; that's invalid.  There must be an entry in the home directory field.
>
> Thanks Stephen and Dennis for the helpful explanation.
>
> I will use:    useradd -d /dev/null -s /sbin/nologin snowman
>

Interesting. I'm usually putting slightly more effort in creation of such
users. I do create them with regular command

/usr/sbin/useradd -s /sbin/nologin -c "Whatever user or something" whatever
/usr/sbin/usermod -d /var/nonexistent whatever
/bin/rm -rf /home/whatever
/bin/rm -f /var/spool/mail/whatever

(I made sure once /var/whatever does not exist).

I wonder, under which circumstances pointing to /dev/null as to such
user's home directory is preferable compared to pointing to place that
doesn't exist on file system.

I don't know where I picked up a habit pointing to nonexistent place as
home directory for such user. I do know though why I type the whole path
beginning with leading slash for commands I execute as almighty user root
;-)

Valeri

++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++