Local password changes can fail a quality check before the system saves the new password. On Ubuntu 26.04 LTS, the PAM stack for passwd shows which password quality rules apply to local accounts.

PAM services select their own password stacks. For a local change with passwd, the service file usually pulls in a shared stack that lists the modules in the order PAM calls them.

The rules for someone choosing their own password can differ from the rules for an administrator resetting it. A failed quality check can produce a warning during a root-run reset while blocking the same choice for an ordinary user.

Steps to check PAM password quality rules in Linux:

  1. Read the active entries in /etc/pam.d/passwd from a regular user shell.
    $ grep -E '^[[:space:]]*[^#[:space:]]' /etc/pam.d/passwd
    @include common-password

    @include common-password points to /etc/pam.d/common-password. The file reads require no password input.

  2. Locate the quality module in the included /etc/pam.d/common-password stack.
    $ grep -E '^[[:space:]]*[^#[:space:]]' /etc/pam.d/common-password
    password	requisite			pam_pwquality.so retry=3 minlen=16
    ##### snipped #####

    The requisite control stops the change if the quality module returns an error.

    If the fully traced stack has no dedicated quality module, the audit ends there. pam_unix.so can still apply basic checks with obscure.

    The configuration reads apply when the passwd password stack reaches pam_pwquality.so through the shown include, so stop if it uses a different quality module, has untraced password entries, or cannot be read, because the audit is incomplete.

  3. List the drop-ins in /etc/security/pwquality.conf.d/ in filename order.
    $ LC_ALL=C ls -1A /etc/security/pwquality.conf.d/
    20-base.conf
    50-local.conf

    LC_ALL=C matches the module's ASCII filename order. If two drop-ins set the same option, the file later in that order wins. If the directory is missing or has no .conf files, skip the drop-in read. A permission error leaves the audit incomplete.

  4. Read the uncommented settings in the listed .conf drop-ins, substituting their quoted paths in the same order.
    $ grep -HE '^[[:space:]]*[^#[:space:]]' \
        '/etc/security/pwquality.conf.d/20-base.conf' \
        '/etc/security/pwquality.conf.d/50-local.conf'
    /etc/security/pwquality.conf.d/20-base.conf:dcredit = -2
    /etc/security/pwquality.conf.d/50-local.conf:minlen = 12
    /etc/security/pwquality.conf.d/50-local.conf:dcredit = -1

    A read error leaves the audit incomplete. dcredit, ucredit, lcredit, and ocredit apply to digits, uppercase letters, lowercase letters, and other characters. A positive value caps the bonus toward minlen. A negative value requires that many characters of the class. minclass sets the minimum number of classes.

  5. Read the uncommented settings in the main /etc/security/pwquality.conf file.
    $ grep -E '^[[:space:]]*[^#[:space:]]' /etc/security/pwquality.conf
    minlen = 14
  6. Resolve each effective setting from the PAM arguments, main file, and drop-ins.

    The module applies the drop-ins first, the main file next, and the PAM arguments last. In the output above, minlen=16 from PAM and dcredit=-1 from 50-local.conf give a length check of at least 16 bytes and a requirement for at least one digit. A UTF-8 character can count as multiple bytes.

    A readable main file with no uncommented settings adds no overrides. Settings absent from all three layers keep their defaults, including minlen=8 and zero credits. If the main file is unreadable, stop because the audit is incomplete.

    An effective enforcing=0 makes failures warnings. With enforcement enabled, enforce_for_root also makes failures block root-run resets.

Share this guide