← 返回命令列表

Linux command

login.defs 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Set maximum password age

PASS_MAX_DAYS 90

Set minimum days between password changes

PASS_MIN_DAYS 7

Set warning days before password expiry

PASS_WARN_AGE 14

Set UID range for regular users

UID_MIN 1000

Set password hashing algorithm

ENCRYPT_METHOD SHA512

Set default umask for new users

UMASK 077

说明

login.defs is the configuration file for the shadow password suite, located at /etc/login.defs. It defines default values for user account creation, password aging, and login behavior. Settings affect useradd, usermod, passwd, groupadd, and other shadow utilities. On systems using PAM, some settings (notably PASS_MIN_LEN) may be overridden by PAM modules.

参数

PASS_MAX_DAYS
Maximum days password valid.
PASS_MIN_DAYS
Minimum days between changes.
PASS_MIN_LEN
Minimum password length (ignored if PAM is used; see pam_pwquality instead).
PASS_WARN_AGE
Warning days before expiry.
UID_MIN, UID_MAX
UID range for users.
GID_MIN, GID_MAX
GID range for groups.
UMASK
Default umask.
ENCRYPT_METHOD
Password hash algorithm (DES, MD5, SHA256, SHA512, YESCRYPT).
CREATE_HOME
Create home directory by default (yes/no).
USERGROUPS_ENAB
Enable user private groups (yes/no).
LOGIN_RETRIES
Maximum number of login retries on password failure.
LOGIN_TIMEOUT
Maximum time in seconds for login.

FAQ

What is the login.defs command used for?

login.defs is the configuration file for the shadow password suite, located at /etc/login.defs. It defines default values for user account creation, password aging, and login behavior. Settings affect useradd, usermod, passwd, groupadd, and other shadow utilities. On systems using PAM, some settings (notably PASS_MIN_LEN) may be overridden by PAM modules.

How do I run a basic login.defs example?

Run `PASS_MAX_DAYS 90` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does PASS_MAX_DAYS do in login.defs?

Maximum days password valid.