How to create linux account with useradd without creating mail spool

man useradd

   -K, --key KEY=VALUE
       Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others).

       Example: -K PASS_MAX_DAYS=-1 can be used when creating system account to turn off password ageing, even though
       system account has no password at all. Multiple -K options can be specified, e.g.: -K UID_MIN=100 -K UID_MAX=499

So, try this:

# useradd -K MAIL_DIR=/dev/null nomailuser

A warning would appear (Creating mailbox file: Not a directory), but you can ignore.

Leave a Comment