While reading useradd manual pages, see that useradd -M user
creates a user without home directory and I can not figure out what is the purpose on it.
I am new on sysadmin topics and do not know much about it.
You may possibly want to use -M
with useradd
if the new user's home directory already exists.
Note that the -M
option turns off the creation of the user's home directory. You may use -d
to assign a home directory to the new user while at the same time using -M
.
It would be highly unusual to create a user with no home directory defined at all. Most daemon accounts (accounts associated with services) and other system accounts have home directories, although some may well have non-existing home directories, such as the _apt
user on Ubuntu:
$ getent passwd _apt
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
Also related: Correct way to create users without home (for shadow.service)
I have a NAS (ZFS) with users data. on the NAS, user don't have to have a home drive as they will never access that, but will require a user account to connect to their SMB share/s. In this case you will create the user account without the home directory. also system user (service account in Windows world) will not require a home directory either.