useradd --help
-d, --home-dir HOME_DIR home directory for the new user account -M, do not create user's home directory yet useradd -M -s /sbin/nologin FRED
produces in /etc/passwd
fred:x:504:504::/home/fred:/sbin/nologin
Trying again with
useradd -d /dev/null -s /sbin/nologin doris
gives a CLI message
useradd: warning: the home directory already exists. Not copying any file from skel directory into it.
and in /etc/password
doris:x:505:505::/dev/null:/sbin/nologin
QUESTION
What is the 'official' method of creating a user with no home directory and no log-on ability ?
Thank you.
On 25.01.2015 04:30, Always Learning wrote:
useradd --help
-d, --home-dir HOME_DIR home directory for the new user account -M, do not create user's home directory
yet useradd -M -s /sbin/nologin FRED
produces in /etc/passwd
fred:x:504:504::/home/fred:/sbin/nologin
Trying again with
useradd -d /dev/null -s /sbin/nologin doris
gives a CLI message
useradd: warning: the home directory already exists. Not copying any file from skel directory into it.
and in /etc/password
doris:x:505:505::/dev/null:/sbin/nologin
QUESTION
What is the 'official' method of creating a user with no home directory and no log-on ability ?
Your first invocation seemed to look fine. What result do you expect to get? Every user needs a home directory in /etc/passwd even if it doesn't exist.
Regards, Dennis
On Sun, 2015-01-25 at 04:38 +0100, Dennis Jacobfeuerborn wrote:
On 25.01.2015 04:30, Always Learning wrote:
useradd --help
-d, --home-dir HOME_DIR home directory for the new user account -M, do not create user's home directory
yet useradd -M -s /sbin/nologin FRED
produces in /etc/passwd
fred:x:504:504::/home/fred:/sbin/nologin
Trying again with
useradd -d /dev/null -s /sbin/nologin doris
gives a CLI message
useradd: warning: the home directory already exists. Not copying any file from skel directory into it.
and in /etc/password
doris:x:505:505::/dev/null:/sbin/nologin
QUESTION
What is the 'official' method of creating a user with no home directory and no log-on ability ?
Your first invocation seemed to look fine. What result do you expect to get? Every user needs a home directory in /etc/passwd even if it doesn't exist.
Guten Morgen Denis,
Aber/But .....
-M, do not create user's home directory
so why do I see in /etc/passwd
fred:x:504:504::/home/fred:/sbin/nologin
Should the 'correct' entry be:-
fred:x:504:504:::/sbin/nologin ?
OK, I can use -d /nix but what should -M actually do ?
On Sun, Jan 25, 2015 at 03:43:06AM +0000, Always Learning wrote:
-M, do not create user's home directory
so why do I see in /etc/passwd
fred:x:504:504::/home/fred:/sbin/nologin
-M stops it doing a "mkdir" to create the actual directory in the filesystem
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.
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
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 ++++++++++++++++++++++++++++++++++++++++
On 25.01.2015 04:54, 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
You can add the -M option too which should get rid of the warning messages (though I have not tested this).
Regards, Dennis