Changing Default Settings for User Accounts

View and change the default settings for a user account.

To display the default settings for the current user account, use the following command:

useradd -D

The output of the command resembles the following:

GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
  • INACTIVE: Specifies after how many days the system locks an account if a user's password expires. If set to 0, the system locks the account immediately. If set to -1, the system doesn't lock the account.

  • SKEL: Defines a template directory, the contents of which are copied to a new user's home directory. The contents of this directory matches the default shell defined by SHELL.

You can specify options to useradd -D to change the default settings for the current user account. For example, to change the defaults for INACTIVE, HOME and SHELL:

sudo useradd -D -f 3 -b /home2 -s /bin/sh

Note:

  • If you change the default login shell, consider creating a SKEL template directory that contains contents that are appropriate to the new shell.

  • If you specify /sbin/nologin for a user's SHELL, that user can't sign in to the system directly but processes can run with that user's ID. This setting is typically used for services that run as users other than root.

The default settings are stored in the /etc/default/useradd file.

For more information, see Configuring Password Ageing and the useradd(8) manual page.