Log In
← The Export

How to Set a 4-Digit PIN on Ubuntu — The Script That Actually Works

You searched. You tried three different guides. You edited the config file, ran the command, and Ubuntu rejected your PIN anyway. Here's why that keeps happening — and a free script you can download right now that fixes it for real.

⬇ Free Download — Ubuntu 4-Digit PIN Tool One script. Works on Ubuntu 20.04, 22.04, and 24.04. Makes backups before touching anything.
Get it on GitHub →

Why every other guide fails

If you've been Googling "ubuntu set 4 digit pin" or "ubuntu short password," you've probably found the same advice recycled across a dozen forums: edit pwquality.conf, lower the minimum length, then use passwd to set your new PIN. Sounds simple. Doesn't work.

The problem is that Ubuntu doesn't have one password enforcement system — it has several, and they don't fully talk to each other. You can relax the rules in one place and a different layer quietly overrides you. The two biggest culprits are a setting called obscure and another called enforce_for_root. These sit inside a file called common-password and they will reject your short PIN even when you're an administrator, even after you've supposedly turned everything off.

Most guides miss both of them. That's why you keep getting "BAD PASSWORD: The password fails the dictionary check" no matter what you do.

The real fix: Don't use passwd at all. Use chpasswd instead — it writes the password hash directly to the system and completely bypasses the rule-checker. That's the one change that makes everything actually work.

What the script does (in plain English)

The script handles the whole process in one shot. Here's what it does under the hood — no terminal experience required to understand it:

It asks you to confirm before doing anything, lets you pick which user account gets the PIN, and makes you type it twice to confirm. The whole thing takes about 60 seconds.

Is a 4-digit PIN safe on Ubuntu?

Short answer: it's weaker than a normal password, and you should know that going in. A 4-digit PIN has only 10,000 possible combinations. Someone with physical access to your computer could try to brute-force it.

Windows also uses 4-digit PINs for login — but Windows ties the PIN to your specific device using a hardware security chip called TPM. That means the PIN is useless on any other machine. This script does not do that. Your PIN is essentially just a short password, not a hardware-bound credential.

For a personal home computer where convenience matters more than high security, it's a reasonable tradeoff. For a work laptop, a server, or any machine with sensitive data, stick with a strong password.

Which Ubuntu versions does it work on?

The script has been tested and confirmed working on Ubuntu 22.04 LTS and Ubuntu 24.04 LTS. It should also work on Ubuntu 20.04. Linux Mint, Pop!_OS, Kubuntu, and other Ubuntu-based distros will likely work too since they share the same underlying password system — but they haven't been formally tested.

If you're on Fedora, Arch, Manjaro, or another non-Debian-based distro, this script is not for you. Those systems use a different password management stack and the script won't behave correctly.

Not sure what version you're running? Open a terminal and type lsb_release -d — it'll tell you exactly.

One thing to do before you reboot

This is the most important thing in this entire article: test your PIN before you reboot. Once the script finishes, lock your screen with Super + L (the Windows key plus L) and log back in with your new 4-digit PIN. If it works, you're done. If it doesn't, your terminal window is still open and you can run the restore command the script printed — no harm done.

If you skip this step and reboot into a broken login, recovery is possible but it means booting from a USB drive. Just test first. It takes 10 seconds.

How to download and run it

The script is free and hosted on GitHub. You don't need a GitHub account to download it.

The README on the GitHub page has the full step-by-step instructions including what to do if something goes wrong. It's written for people who aren't Linux experts — no jargon, no assumptions.

See our free AI tools →