---
name: "login.defs"
section: "5"
platform: "linux"
package: "shadow"
version: "4.20.0.arch1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/login.defs"
---

# login.defs(5)

shadow password suite configuration

## NAME

login.defs - shadow password suite configuration

## DESCRIPTION

The /etc/login.defs file defines the site-specific configuration for the shadow password suite. This file is required. Absence of this file will not prevent system operation, but will probably result in undesirable operation.

This file is a readable text file, each line of the file describing one configuration parameter. The lines consist of a configuration name and value, separated by whitespace. Blank lines and comment lines are ignored. Comments are introduced with a "#" pound sign and the pound sign must be the first non-white character of the line.

Parameter values may be of four types: strings, booleans, numbers, and long numbers. A string is comprised of any printable characters. A boolean should be either the value *yes* or *no*. An undefined boolean parameter or one with a value other than these will be given a *no* value. Numbers (both regular and long) may be either decimal values, octal values (precede the value with *0*) or hexadecimal values (precede the value with *0x*). The maximum value of the regular and long numeric parameters is machine-dependent.

This configuration file controls the behavior of system tools for user and group management. The parameters may be used by shadow-utils programs, PAM modules, and other system components. The actual behavior depends on the system configuration and which authentication mechanisms are enabled.

The following configuration items are provided:

**CHFN\_RESTRICT** (string)

This parameter specifies which values in the *gecos* field of the /etc/passwd file may be changed by regular users using the **chfn** program. It can be any combination of letters *f*, *r*, *w*, *h*, for Full name, Room number, Work phone, and Home phone, respectively. For backward compatibility, *yes* is equivalent to *rwh* and *no* is equivalent to *frwh*. If not specified, only the superuser can make any changes. The most restrictive setting is better achieved by not installing **chfn** SUID.

**CREATE\_HOME** (boolean)

Indicate if a home directory should be created by default for new users.

This setting does not apply to system users, and can be overridden on the command line.

**DEFAULT\_HOME** (boolean)

Indicate if login is allowed if we can't cd to the home directory. Default is no.

If set to *yes*, the user will login in the root (/) directory if it is not possible to cd to her home directory.

**ENCRYPT\_METHOD** (string)

This defines the system default encryption algorithm for encrypting passwords (if no algorithm is specified on the command line).

It can take one of these values: *SHA256*, *SHA512* (default), *YESCRYPT*. See [crypt(5)](/crypt/5.md) for recommendations.

Note: this only affects the generation of group passwords. The generation of user passwords is done by PAM and subject to the PAM configuration. It is recommended to set this variable consistently with the PAM configuration.

History: This variable is used by other programs, which may still default to unsafe algorithms such as DES. To avoid using unsafe algorithms, the variable should always be specified.

**ENV\_PATH** (string)

If set, it will be used to define the PATH environment variable when a regular user login. The value is a colon separated list of paths (for example */bin:/usr/bin*) and can be preceded by *PATH=*. The default value is *PATH=/bin:/usr/bin*.

**ENV\_SUPATH** (string)

If set, it will be used to define the PATH environment variable when the superuser login. The value is a colon separated list of paths (for example */sbin:/bin:/usr/sbin:/usr/bin*) and can be preceded by *PATH=*. The default value is *PATH=/sbin:/bin:/usr/sbin:/usr/bin*.

**FAIL\_DELAY** (number)

Delay in seconds before being allowed another attempt after a login failure.

**GID\_MAX** (number), **GID\_MIN** (number)

Range of group IDs used for the creation of regular groups by **useradd**, **groupadd**, or **newusers**.

The default value for **GID\_MIN** (resp. **GID\_MAX**) is 1000 (resp. 60000).

**HOME\_MODE** (number)

The mode for new home directories. If not specified, the **UMASK** is used to create the mode.

**useradd** and **newusers** use this to set the mode of the home directory they create.

**HUSHLOGIN\_FILE** (string)

If defined, this file can inhibit all the usual chatter during the login sequence. If a full pathname is specified, then hushed mode will be enabled if the user's name or shell are found in the file. If not a full pathname, then hushed mode will be enabled if the file exists in the user's home directory.

**LASTLOG\_UID\_MAX** (number)

Highest user ID number for which the lastlog entries should be updated. As higher user IDs are usually tracked by remote user identity and authentication services there is no need to create a huge sparse lastlog file for them.

No **LASTLOG\_UID\_MAX** option present in the configuration means that there is no user ID limit for writing lastlog entries.

**LOG\_UNKFAIL\_ENAB** (boolean)

Enable display of unknown usernames when login failures are recorded.

Note: logging unknown usernames may be a security issue if an user enter her password instead of her login name.

**LOGIN\_RETRIES** (number)

Maximum number of login retries in case of bad password.

This will most likely be overridden by PAM, since the default pam\_unix module has its own built in of 3 retries. However, this is a safe fallback in case you are using an authentication module that does not enforce PAM\_MAXTRIES.

**LOGIN\_TIMEOUT** (number)

Max time in seconds for login.

**MAIL\_DIR** (string)

The mail spool directory. This is needed to manipulate the mailbox when its corresponding user account is modified or deleted. If not specified, a compile-time default is used. The parameter CREATE\_MAIL\_SPOOL in /etc/default/useradd determines whether the mail spool should be created.

**MAIL\_FILE** (string)

Defines the location of the users mail spool files relatively to their home directory.

The **MAIL\_DIR** and **MAIL\_FILE** variables are used by **useradd**, **usermod**, and **userdel** to create, move, or delete the user's mail spool.

**MAX\_MEMBERS\_PER\_GROUP** (number)

Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID).

The default value is 0, meaning that there are no limits in the number of members in a group.

This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters.

If you need to enforce such limit, you can use 25.

Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it.

**NONEXISTENT** (string)

If a system account intentionally does not have a home directory that exists, this string can be provided in the /etc/passwd entry for the account to indicate this. The result is that pwck will not emit a spurious warning for this account.

**PASS\_MAX\_DAYS** (number)

The maximum number of days a password may be used. If the password is older than this, a password change will be forced. If not specified, -1 will be assumed (which disables the restriction).

**PASS\_WARN\_AGE** (number)

The number of days warning given before a password expires. A zero means warning is given only upon the day of expiration, a value of -1 means no warning is given. If not specified, no warning will be provided.

**PASS\_MAX\_DAYS**, and **PASS\_WARN\_AGE** are only used at the time of account creation. Any changes to these settings won't affect existing accounts.

**SHA\_CRYPT\_MIN\_ROUNDS** (number), **SHA\_CRYPT\_MAX\_ROUNDS** (number)

When **ENCRYPT\_METHOD** is set to *SHA256* or *SHA512*, this defines the number of SHA rounds used by the encryption algorithm by default (when the number of rounds is not specified on the command line).

With a lot of rounds, it is more difficult to brute force the password. But note also that more CPU resources will be needed to authenticate users.

If not specified, the libc will choose the default number of rounds (5000), which is orders of magnitude too low for modern hardware.

The values must be inside the 1000-999,999,999 range.

If only one of the **SHA\_CRYPT\_MIN\_ROUNDS** or **SHA\_CRYPT\_MAX\_ROUNDS** values is set, then this value will be used.

If **SHA\_CRYPT\_MIN\_ROUNDS** \> **SHA\_CRYPT\_MAX\_ROUNDS**, the highest value will be used.

Note: this only affect the generation of group passwords. The generation of user passwords is done by PAM and subject to the PAM configuration. It is recommended to set this variable consistently with the PAM configuration.

**SUB\_GID\_MIN** (number), **SUB\_GID\_MAX** (number), **SUB\_GID\_COUNT** (number)

If /etc/subuid exists, the commands **useradd** and **newusers** (unless the user already have subordinate group IDs) allocate **SUB\_GID\_COUNT** unused group IDs from the range **SUB\_GID\_MIN** to **SUB\_GID\_MAX** for each new user.

The default values for **SUB\_GID\_MIN**, **SUB\_GID\_MAX**, **SUB\_GID\_COUNT** are respectively 100000, 600100000 and 65536.

**SUB\_GID\_DETERMINISTIC** (boolean)

If set to *yes*, the commands **useradd**, **usermod**, and **newusers** will calculate subordinate GID ranges deterministically based on the user's UID instead of searching for the next free range. The formula used is:

```
      start = SUB_GID_MIN + ((UID - UID_MIN) * SUB_GID_COUNT)
      end   = start + SUB_GID_COUNT - 1
```

This ensures the same UID always receives the same subordinate GID range on every system, making it suitable for environments with centralized user management (LDAP, NIS, etc.) or synchronized UIDs across systems.

If **SUB\_GID\_DETERMINISTIC** is enabled, you can use **usermod --add-subgids -S** to produce deterministic subgids.

**WARNING**: Because **UID\_MIN** is used to calculate the ranges, any change of **UID\_MIN** will change the ranges calculated. **SUB\_GID\_COUNT** is used to calculate the ranges, any change of **SUB\_GID\_COUNT** will change the ranges calculated. Users with identities less than **UID\_MIN** are incompatible with **SUB\_GID\_DETERMINISTIC**, but can still be set manually.

**WARNING**: Do not mix deterministic and linear (default) allocation on the same system or across systems sharing /etc/subgid via network storage (NFS, etc.). Mixing allocation methods  **will cause subordinate ID range conflicts and overlaps** .

The default value for **SUB\_GID\_DETERMINISTIC** is *no*.

### Range Calculation Examples

With default configuration (**UID\_MIN**=1000, **SUB\_GID\_MIN**=100000, **SUB\_GID\_COUNT**=65536):

| | | |
| --- | --- | --- |
| **UID** | **Calculation** | **Subordinate GID Range** |
| 1000 | 100000 + ((1000-1000) \* 65536) | 100000-165535 |
| 1001 | 100000 + ((1001-1000) \* 65536) | 165536-231071 |
| 1002 | 100000 + ((1002-1000) \* 65536) | 231072-296607 |
| 1100 | 100000 + ((1100-1000) \* 65536) | 6653600-6719135 |

### Subordinate ID Space Planning

When planning subordinate ID allocation, calculate the maximum number of users the space can accommodate:

```
      capacity = (SUB_GID_MAX - SUB_GID_MIN) / SUB_GID_COUNT
```

With default values: (600100000 - 100000) / 65536 ≈ 9155 users.

For high-density environments with many users and smaller allocations:

```
        SUB_GID_COUNT  4096
        SUB_GID_MIN    100000
        SUB_GID_MAX    10000000
```

This gives: (10000000 - 100000) / 4096 ≈ 2417 users.

**UNSAFE\_SUB\_GID\_DETERMINISTIC\_WRAP** (boolean)

 **WARNING: SECURITY RISK - MAY CAUSE RANGE OVERLAPS AND PRIVILEGE ESCALATION!**

Only effective when **SUB\_GID\_DETERMINISTIC** is set to *yes*.

When set to *yes* (WRAP MODE), allows the deterministic range calculation to wrap around using modulo arithmetic when a UID would overflow the configured subordinate ID space. The subordinate ID space is treated as a ring buffer.

**WARNING**: Range overlaps can lead to container escapes and privilege escalation. For example, with **SUB\_GID\_MIN**=100000, **SUB\_GID\_MAX**=200000, **SUB\_GID\_COUNT**=65536, User A (UID 1000) gets range \[100000, 165535\] and User B (UID 1001) wraps and overlaps with User A. User B's container can now access files from User A's containers.

Use **only** in development, testing, or tightly constrained lab environments.

When set to *no* (default), any arithmetic overflow or range exceeding **SUB\_GID\_MAX** is a hard error. This guarantees non-overlapping, monotonic allocation.

The default value for **UNSAFE\_SUB\_GID\_DETERMINISTIC\_WRAP** is *no*.

**SUB\_GID\_STORE\_BY\_UID** (boolean)

If set to *yes*, subordinate group ID entries in /etc/subgid are stored using the numeric user ID rather than the username. The default value is *no*.

**SUB\_UID\_MIN** (number), **SUB\_UID\_MAX** (number), **SUB\_UID\_COUNT** (number)

If /etc/subuid exists, the commands **useradd** and **newusers** (unless the user already have subordinate user IDs) allocate **SUB\_UID\_COUNT** unused user IDs from the range **SUB\_UID\_MIN** to **SUB\_UID\_MAX** for each new user.

The default values for **SUB\_UID\_MIN**, **SUB\_UID\_MAX**, **SUB\_UID\_COUNT** are respectively 100000, 600100000 and 65536.

**SUB\_UID\_DETERMINISTIC** (boolean)

If set to *yes*, the commands **useradd**, **usermod**, and **newusers** will calculate subordinate UID ranges deterministically based on the user's UID instead of searching for the next free range. The formula used is:

```
      start = SUB_UID_MIN + ((UID - UID_MIN) * SUB_UID_COUNT)
      end   = start + SUB_UID_COUNT - 1
```

This ensures the same UID always receives the same subordinate UID range on every system, making it suitable for environments with centralized user management (LDAP, NIS, etc.) or synchronized UIDs across systems.

If **SUB\_UID\_DETERMINISTIC** is enabled, you can use **usermod --add-subuids -S** to produce deterministic subuids.

**WARNING**: Because **UID\_MIN** is used to calculate the ranges, any change of **UID\_MIN** will change the ranges calculated. **SUB\_UID\_COUNT** is used to calculate the ranges, any change of **SUB\_UID\_COUNT** will change the ranges calculated. Users with identities less than **UID\_MIN** are incompatible with **SUB\_UID\_DETERMINISTIC**, but can still be set manually.

**WARNING**: Do not mix deterministic and linear (default) allocation on the same system or across systems sharing /etc/subuid via network storage (NFS, etc.). Mixing allocation methods  **will cause subordinate ID range conflicts and overlaps** .

The default value for **SUB\_UID\_DETERMINISTIC** is *no*.

### Range Calculation Examples

With default configuration (**UID\_MIN**=1000, **SUB\_UID\_MIN**=100000, **SUB\_UID\_COUNT**=65536):

| | | |
| --- | --- | --- |
| **UID** | **Calculation** | **Subordinate UID Range** |
| 1000 | 100000 + ((1000-1000) \* 65536) | 100000-165535 |
| 1001 | 100000 + ((1001-1000) \* 65536) | 165536-231071 |
| 1002 | 100000 + ((1002-1000) \* 65536) | 231072-296607 |
| 1100 | 100000 + ((1100-1000) \* 65536) | 6653600-6719135 |

### Subordinate ID Space Planning

When planning subordinate ID allocation, calculate the maximum number of users the space can accommodate:

```
      capacity = (SUB_UID_MAX - SUB_UID_MIN) / SUB_UID_COUNT
```

With default values: (600100000 - 100000) / 65536 ≈ 9155 users.

For high-density environments with many users and smaller allocations:

```
        SUB_UID_COUNT  4096
        SUB_UID_MIN    100000
        SUB_UID_MAX    10000000
```

This gives: (10000000 - 100000) / 4096 ≈ 2417 users.

**UNSAFE\_SUB\_UID\_DETERMINISTIC\_WRAP** (boolean)

 **WARNING: SECURITY RISK - MAY CAUSE RANGE OVERLAPS AND PRIVILEGE ESCALATION!**

Only effective when **SUB\_UID\_DETERMINISTIC** is set to *yes*.

When set to *yes* (WRAP MODE), allows the deterministic range calculation to wrap around using modulo arithmetic when a UID would overflow the configured subordinate ID space. The subordinate ID space is treated as a ring buffer.

**WARNING**: Range overlaps can lead to container escapes and privilege escalation. For example, with **SUB\_UID\_MIN**=100000, **SUB\_UID\_MAX**=200000, **SUB\_UID\_COUNT**=65536, User A (UID 1000) gets range \[100000, 165535\] and User B (UID 1001) wraps and overlaps with User A. User B's container can now access files from User A's containers.

Use **only** in development, testing, or tightly constrained lab environments.

When set to *no* (default), any arithmetic overflow or range exceeding **SUB\_UID\_MAX** is a hard error. This guarantees non-overlapping, monotonic allocation.

The default value for **UNSAFE\_SUB\_UID\_DETERMINISTIC\_WRAP** is *no*.

**SUB\_UID\_STORE\_BY\_UID** (boolean)

If set to *yes*, subordinate user ID entries in /etc/subuid are stored using the numeric user ID rather than the username. The default value is *no*.

**SYS\_GID\_MAX** (number), **SYS\_GID\_MIN** (number)

Range of group IDs used for the creation of system groups by **useradd**, **groupadd**, or **newusers**.

The default value for **SYS\_GID\_MIN** (resp. **SYS\_GID\_MAX**) is 101 (resp. **GID\_MIN**-1).

**SYS\_UID\_MAX** (number), **SYS\_UID\_MIN** (number)

Range of user IDs used for the creation of system users by **useradd** or **newusers**.

The default value for **SYS\_UID\_MIN** (resp. **SYS\_UID\_MAX**) is 101 (resp. **UID\_MIN**-1).

**SYSLOG\_SG\_ENAB** (boolean)

Enable "syslog" logging of **sg** activity.

**TTYGROUP** (string), **TTYPERM** (number)

The terminal permissions: the login tty will be owned by the **TTYGROUP** group, and the permissions will be set to **TTYPERM**.

**TTYGROUP** can be either the name of a group or a numeric group identifier.

If TTYGROUP is not defined, then the group ownership of the terminal is set to the user's primary group. If TTYPERM is not defined, then the permissions are set to *0600*.

If you have a **write** program which is "setgid" to a special group which owns the terminals, define TTYGROUP to the group number and TTYPERM to 0620. Otherwise leave TTYGROUP commented out and assign TTYPERM to either 622 or 600.

**UID\_MAX** (number), **UID\_MIN** (number)

Range of user IDs used for the creation of regular users by **useradd** or **newusers**.

The default value for **UID\_MIN** (resp. **UID\_MAX**) is 1000 (resp. 60000).

**UMASK** (number)

The file mode creation mask is initialized to this value. If not specified, the mask will be initialized to 022.

**useradd** and **newusers** use this mask to set the mode of the home directory they create if **HOME\_MODE** is not set.

It is also used by **pam\_umask** as the default umask value.

**USERDEL\_CMD** (string)

If defined, this command is run when removing a user. It should remove any at/cron/print jobs etc. owned by the user to be removed (passed as the first argument).

The return code of the script is not taken into account.

Here is an example script, which removes the user's cron, at and print jobs:

```
#! /bin/sh
# Check for the required argument.
if [ $# != 1 ]; then
	echo "Usage: $0 username"
	exit 1
fi
# Remove cron jobs.
crontab -r -u $1
# Remove at jobs.
# Note that it will remove any jobs owned by the same UID,
# even if it was shared by a different username.
AT_SPOOL_DIR=/var/spool/cron/atjobs
find $AT_SPOOL_DIR -name "[^.]*" -type f -user $1 -delete \;
# Remove print jobs.
lprm $1
# All done.
exit 0
```

**USERGROUPS\_ENAB** (boolean)

If set to *yes*, **userdel** will remove the user's group if it contains no more members, and **useradd** will create by default a group with the name of the user.

**YESCRYPT\_COST\_FACTOR** (number)

When **ENCRYPT\_METHOD** is set to *YESCRYPT*, this defines the cost factor used by the encryption algorithm by default (when the cost factor is not specified on the command line).

With a high cost factor, it is more difficult to brute force the password. But note also that more CPU resources will be needed to authenticate users.

The value must be inside the 1-11 range.

Note: this only affect the generation of group passwords. The generation of user passwords is done by PAM and subject to the PAM configuration. It is recommended to set this variable consistently with the PAM configuration.

## CROSS REFERENCES

The following cross references show which programs in the shadow password suite use which parameters.

chfn

CHFN\_RESTRICT

chgpasswd

ENCRYPT\_METHOD MAX\_MEMBERS\_PER\_GROUP SHA\_CRYPT\_MAX\_ROUNDS SHA\_CRYPT\_MIN\_ROUNDS YESCRYPT\_COST\_FACTOR

chpasswd

SHA\_CRYPT\_MAX\_ROUNDS SHA\_CRYPT\_MIN\_ROUNDS YESCRYPT\_COST\_FACTOR

gpasswd

ENCRYPT\_METHOD MAX\_MEMBERS\_PER\_GROUP SHA\_CRYPT\_MAX\_ROUNDS SHA\_CRYPT\_MIN\_ROUNDS YESCRYPT\_COST\_FACTOR

groupadd

GID\_MAX GID\_MIN MAX\_MEMBERS\_PER\_GROUP SYS\_GID\_MAX SYS\_GID\_MIN

groupdel

MAX\_MEMBERS\_PER\_GROUP

groupmod

MAX\_MEMBERS\_PER\_GROUP

grpck

MAX\_MEMBERS\_PER\_GROUP

grpconv

MAX\_MEMBERS\_PER\_GROUP

grpunconv

MAX\_MEMBERS\_PER\_GROUP

lastlog

LASTLOG\_UID\_MAX

newgrp / sg

SYSLOG\_SG\_ENAB

newusers

ENCRYPT\_METHOD GID\_MAX GID\_MIN MAX\_MEMBERS\_PER\_GROUP HOME\_MODE PASS\_MAX\_DAYS PASS\_WARN\_AGE SHA\_CRYPT\_MAX\_ROUNDS SHA\_CRYPT\_MIN\_ROUNDS SUB\_GID\_COUNT SUB\_GID\_MAX SUB\_GID\_MIN SUB\_GID\_DETERMINISTIC SUB\_GID\_STORE\_BY\_UID SUB\_UID\_COUNT SUB\_UID\_MAX SUB\_UID\_MIN SUB\_UID\_DETERMINISTIC SUB\_UID\_STORE\_BY\_UID SYS\_GID\_MAX SYS\_GID\_MIN SYS\_UID\_MAX SYS\_UID\_MIN UID\_MAX UID\_MIN UMASK UNSAFE\_SUB\_GID\_DETERMINISTIC\_WRAP UNSAFE\_SUB\_UID\_DETERMINISTIC\_WRAP YESCRYPT\_COST\_FACTOR

pwck

PASS\_MAX\_DAYS PASS\_WARN\_AGE

pwconv

PASS\_MAX\_DAYS PASS\_WARN\_AGE

useradd

CREATE\_HOME GID\_MAX GID\_MIN HOME\_MODE LASTLOG\_UID\_MAX MAIL\_DIR MAX\_MEMBERS\_PER\_GROUP PASS\_MAX\_DAYS PASS\_WARN\_AGE SUB\_GID\_COUNT SUB\_GID\_MAX SUB\_GID\_MIN SUB\_GID\_DETERMINISTIC SUB\_GID\_STORE\_BY\_UID SUB\_UID\_COUNT SUB\_UID\_MAX SUB\_UID\_MIN SUB\_UID\_DETERMINISTIC SUB\_UID\_STORE\_BY\_UID SYS\_GID\_MAX SYS\_GID\_MIN SYS\_UID\_MAX SYS\_UID\_MIN UID\_MAX UID\_MIN UMASK UNSAFE\_SUB\_GID\_DETERMINISTIC\_WRAP UNSAFE\_SUB\_UID\_DETERMINISTIC\_WRAP

userdel

MAIL\_DIR MAIL\_FILE MAX\_MEMBERS\_PER\_GROUP USERDEL\_CMD USERGROUPS\_ENAB

usermod

LASTLOG\_UID\_MAX MAIL\_DIR MAIL\_FILE MAX\_MEMBERS\_PER\_GROUP SUB\_GID\_COUNT SUB\_GID\_MAX SUB\_GID\_MIN SUB\_GID\_DETERMINISTIC SUB\_UID\_COUNT SUB\_UID\_MAX SUB\_UID\_MIN SUB\_UID\_DETERMINISTIC UNSAFE\_SUB\_GID\_DETERMINISTIC\_WRAP UNSAFE\_SUB\_UID\_DETERMINISTIC\_WRAP

## BUGS

Much of the functionality that used to be provided by the shadow password suite is now handled by PAM. Thus, /etc/login.defs is no longer used by [**passwd**(1)](/passwd/1.md), or less used by [**login**(1)](/login/1.md), and [**su**(1)](/su/1.md). Please refer to the corresponding PAM configuration files instead.

## SEE ALSO

[**login**(1)](/login/1.md), [**passwd**(1)](/passwd/1.md), [**su**(1)](/su/1.md), [**passwd**(5)](/passwd/5.md), [**shadow**(5)](/shadow/5.md), [**pam**(8)](/pam/8.md).
