LOGIN.DEFS(5)
๐ธ NAME ๐ธ
okay so this is login.defs(5), bestie โ the shadow password suite configuration page. ๐
โจ 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, and each line of the file describes 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. โจ
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: DES (default), MD5, SHA256, SHA512, YESCRYPT. MD5 and DES should not be used for new hashes, see crypt(5) for recommendations.
Note: this parameter overrides the MD5_CRYPT_ENAB variable.
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. ๐ญ
๐ 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. ๐
๐ ERASECHAR (number) ๐
Terminal ERASE character (010 = backspace, 0177 = DEL). โซ
The value can be prefixed "0" for an octal value, or "0x" for an hexadecimal value.
๐ FAIL_DELAY (number) ๐
Delay in seconds before being allowed another attempt after a login failure. โณ
๐ FAKE_SHELL (string) ๐
If set, login will execute this shell instead of the users' shell specified in /etc/passwd. ๐
๐ 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. ๐คซ
๐ KILLCHAR (number) ๐
Terminal KILL character (025 = CTRL/U). ๐
The value can be prefixed "0" for an octal value, or "0x" for an hexadecimal value.
๐ 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_OK_LOGINS (boolean) ๐
Enable logging of successful logins. โ
๐ 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. ๐ฌ
๐ MD5_CRYPT_ENAB (boolean) ๐
Indicate if passwords must be encrypted using the MD5-based algorithm. If set to yes, new passwords will be encrypted using the MD5-based algorithm compatible with the one used by recent releases of FreeBSD. It supports passwords of unlimited length and longer salt strings. Set to no if you need to copy encrypted passwords to other systems which don't understand the new algorithm. Default is no. ๐
This variable is superseded by the ENCRYPT_METHOD variable or by any command line option used to configure the encryption algorithm.
This variable is deprecated. You should use ENCRYPT_METHOD. ๐จ
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.
๐ 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_MIN_DAYS (number) ๐
The minimum number of days allowed between password changes. Any password changes attempted sooner than this will be rejected. If not specified, 0 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, PASS_MIN_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. ๐
๐ SULOG_FILE (string) ๐
If defined, all su activity is logged to this file. ๐
SU_NAME (string)
If you define this, it's the command name that shows up when you're running su -. Like, say you set it to "su" โ then a ps will literally show the command as -su. If you don't define it, then ps shows the name of the shell that's actually running, e.g. something like -sh. That's it, that's the whole vibe check โจ
SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number)
If /etc/subuid exists, then useradd and newusers (unless the user already has subordinate group IDs, bestie, it's conditional ๐
) 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. Those are the numbers, memorize them or don't, but they're there ๐
SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number)
If /etc/subuid exists, then useradd and newusers (again, unless the user already has subordinate user IDs โ same little caveat ๐ซถ) 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. Slay, consistency ๐ฆ
SYS_GID_MAX (number), SYS_GID_MIN (number)
This is the range of group IDs used when useradd, groupadd, or newusers create system groups.
The default value for SYS_GID_MIN (resp. SYS_GID_MAX) is 101 (resp. GID_MIN-1). Cute little range, right? ๐ธ
SYS_UID_MAX (number), SYS_UID_MIN (number)
Same energy, but for user IDs โ this is the range 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). Periodt ๐
SYSLOG_SG_ENAB (boolean)
Turns on "syslog" logging of sg activity. That's it. That's the whole option โจ
SYSLOG_SU_ENAB (boolean)
Turns on "syslog" logging of su activity โ and yes, that's in addition to the sulog file logging. Double the logging, double the fun ๐
TTYGROUP (string), TTYPERM (number)
Okay so this one's about 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. Either works, no cap.
If TTYGROUP is not defined, then the group ownership of the terminal gets set to the user's primary group. And if TTYPERM is not defined, then the permissions get set to 0600.
Here's the tea ๐ โ if you have a write program which is "setgid" to a special group that 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. Those are your two paths, bestie, pick one.
TTYTYPE_FILE (string)
If defined, this is the file which maps tty line to the TERM environment parameter. Each line of the file is in a format something like "vt100 tty01". Little mapping file, doing its thing ๐ง
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). Iconic defaults, honestly ๐
UMASK (number)
The file mode creation mask gets initialized to this value. If it's 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 โ but only if HOME_MODE is not set. Conditional again, love that for us ๐
It's also used by pam_umask as the default umask value. Multitasking icon ๐
USERDEL_CMD (string)
If defined, this command is run when removing a user. Its whole job is to remove any at/cron/print jobs etc. owned by the user being removed โ and that user gets passed as the first argument.
The return code of the script is not taken into account. No pressure, script ๐
Here's 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
Copy it exactly, it's giving reference implementation ๐
USERGROUPS_ENAB (boolean)
If set to yes, then 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. One boolean, two behaviours. Efficient ๐
YESCRYPT_COST_FACTOR (number)
When ENCRYPT_METHOD is set to YESCRYPT, this defines the cost factor used by the encryption algorithm by default โ i.e. when the cost factor is not specified on the command line.
With a high cost factor, it's more difficult to brute force the password. But also, fair warning ๐ญ โ more CPU resources will be needed to authenticate users. Tradeoff city.
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.
So yeah, group passwords only โ PAM is running the user password show, don't forget it ๐ซถ
๐ CROSS REFERENCES ๐
The following cross references show which programs in the shadow password suite use which parameters. It's giving "who's in the group chat with whom" ๐
chfn
CHFN_RESTRICT
chgpasswd
ENCRYPT_METHODMAX_MEMBERS_PER_GROUPMD5_CRYPT_ENABSHA_CRYPT_MAX_ROUNDSSHA_CRYPT_MIN_ROUNDSYESCRYPT_COST_FACTOR
chpasswd
SHA_CRYPT_MAX_ROUNDSSHA_CRYPT_MIN_ROUNDSYESCRYPT_COST_FACTOR
gpasswd
ENCRYPT_METHODMAX_MEMBERS_PER_GROUPMD5_CRYPT_ENABSHA_CRYPT_MAX_ROUNDSSHA_CRYPT_MIN_ROUNDSYESCRYPT_COST_FACTOR
groupadd
GID_MAXGID_MINMAX_MEMBERS_PER_GROUPSYS_GID_MAXSYS_GID_MIN
groupdel
MAX_MEMBERS_PER_GROUP
groupmems
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
login
CONSOLE_GROUPSDEFAULT_HOMEERASECHARFAIL_DELAYFAKE_SHELLHUSHLOGIN_FILEKILLCHARLOGIN_RETRIESLOGIN_TIMEOUTLOG_OK_LOGINSLOG_UNKFAIL_ENABTTYGROUPTTYPERMTTYTYPE_FILEUSERGROUPS_ENAB
newgrp / sg
SYSLOG_SG_ENAB
newusers
ENCRYPT_METHODGID_MAXGID_MINMAX_MEMBERS_PER_GROUPMD5_CRYPT_ENABHOME_MODEPASS_MAX_DAYSPASS_MIN_DAYSPASS_WARN_AGESHA_CRYPT_MAX_ROUNDSSHA_CRYPT_MIN_ROUNDSSUB_GID_COUNTSUB_GID_MAXSUB_GID_MINSUB_UID_COUNTSUB_UID_MAXSUB_UID_MINSYS_GID_MAXSYS_GID_MINSYS_UID_MAXSYS_UID_MINUID_MAXUID_MINUMASKYESCRYPT_COST_FACTOR
pwck
PASS_MAX_DAYSPASS_MIN_DAYSPASS_WARN_AGE
pwconv
PASS_MAX_DAYSPASS_MIN_DAYSPASS_WARN_AGE
su
CONSOLE_GROUPSDEFAULT_HOMEENV_PATHENV_SUPATHSULOG_FILESU_NAMESYSLOG_SU_ENAB
useradd
CREATE_HOMEGID_MAXGID_MINHOME_MODELASTLOG_UID_MAXMAIL_DIRMAX_MEMBERS_PER_GROUPPASS_MAX_DAYSPASS_MIN_DAYSPASS_WARN_AGESUB_GID_COUNTSUB_GID_MAXSUB_GID_MINSUB_UID_COUNTSUB_UID_MAXSUB_UID_MINSYS_GID_MAXSYS_GID_MINSYS_UID_MAXSYS_UID_MINUID_MAXUID_MINUMASK
userdel
MAIL_DIRMAIL_FILEMAX_MEMBERS_PER_GROUPUSERDEL_CMDUSERGROUPS_ENAB
usermod
LASTLOG_UID_MAXMAIL_DIRMAIL_FILEMAX_MEMBERS_PER_GROUP
๐ BUGS ๐
Okay so, a lot of the functionality that used to be provided by the shadow password suite is now handled by PAM. Which means /etc/login.defs is no longer used by passwd(1), or less used by login(1), and su(1). Please refer to the corresponding PAM configuration files instead. Not us, not our problem, go read the PAM configs bestie ๐ญ๐ซถ
๐ SEE ALSO ๐
login(1), passwd(1), su(1), passwd(5), shadow(5), pam(8).
and that's the whole page!! ๐โจ brought to you by shadow-utils 4.19.3, dated 09/22/2026, filed under LOGIN.DEFS(5) โ go forth and configure responsibly, mwah ๐
๐
๐ฆ where this page comes from
- ubuntu stonking: login.defs 1:4.19.3-2ubuntu2 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms