• Check it out - we have a chatbot! Go ask TuxBot a question in the Ask Tuxbot section!

useradd -M is creating a home directory

skybird182

New Member
Joined
Mar 25, 2021
Messages
3
Reaction score
0
Credits
34
It appears the -M / --no-create-home switch does not prevent the creation of the home directory as can be seen in the command line text below.
The useradd man page clearly states the following:
-M, --no-create-home Do not create the user's home directory, even if the system wide setting from /etc/login.defs (CREATE_HOME) is set to yes.

Is this a bug ? Am I missing something ? I am using xubuntu 20.04 LTS

In the /etc/login.defs I could only fine CREATE_HOME and not DEFAULT_HOME.

[email protected]:~$ sudo useradd -M test_acct
[email protected]:~$ grep test_acct /etc/passwd
test_acct:x:1004:1004::/home/test_acct:/bin/sh
[email protected]:~$

from /etc/logins.def

# Should login be allowed if we can't cd to the home directory?
# Default in no.
#
DEFAULT_HOME yes
 


KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,581
Reaction score
7,330
Credits
69,754
Can you try:

Code:
adduser --no-create-home

The useradd has been supplanted/depreciated (as far as my memory says). It may not work because there's a newer tool and there could be some conflict between the two.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,581
Reaction score
7,330
Credits
69,754
OP
S

skybird182

New Member
Joined
Mar 25, 2021
Messages
3
Reaction score
0
Credits
34
I switched to adduser. The home account is still created.
[email protected]:~# adduser --no-create-home junk_acct
Adding user `junk_acct' ...
Adding new group `junk_acct' (1004) ...
Adding new user `junk_acct' (1004) with group `junk_acct' ...
Not creating home directory `/home/junk_acct'.

The account is still created.
[email protected]:/# grep junk /etc/passwd
flyboy:x:1003:1003::/junk:/bin/sh
junk_acct:x:1004:1004:,,,:/home/junk_acct:/bin/bash
[email protected]:/#

After further investigation I discovered this:
[email protected]:/# su junk_acct
[email protected]:/$ ls
bin boot cdrom dev etc home (abbreviated list)
[email protected]:/$ cd home
[email protected]:/home$ pwd
/home

[email protected]:/$ cd junk
bash: cd: junk: No such file or directory
[email protected]:/$

Is /etc/passwd creating a phantom directory ?
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,581
Reaction score
7,330
Credits
69,754
Is /etc/passwd creating a phantom directory

So it seems. I finally decided to check and I get the same behavior with an Ubuntu VM. But, if I look at /home, I do not see my 'testing' user's /home/testing account.
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Latest posts

Top