8

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.

2 Answers 2

12

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)

1
  • 2
    If you have a network of machines, the user's home directory might not even be on the same machine. In that situation, you might not have the admin permissions to create it even if you wanted to.
    – alephzero
    Commented Jul 23, 2021 at 18:46
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .