7

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.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
dazckel
  • 79
  • 1
  • 3

2 Answers2

11

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)

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
  • 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 Jul 23 '21 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.