User account creation

Posted on 2005-04-29
Last Modified: 2010-04-20
How would I create a user from the command line with a password that will never expire?
Question by:traderhank1
    LVL 9

    Expert Comment

    Type the following at command prompt to see the details of the command for adding users:
    # man useradd

    Author Comment

    that wasn't "exactly" helpfull.
    LVL 1

    Expert Comment


    You can set the password aging limits  by editing /etc/login.defs

    You can set the perons's expiry to the maximum with

    # passwd -x <username>

    LVL 38

    Expert Comment

    By default,
    useradd <username>
    passwdd <username>
    as root, the password of <username> won't expire unless you enforce on pam.d or /etc/login.defs.

    Author Comment

    I don't see anything relating to expiration in login.defs , I don't know anything about pam.d
    everytime I create a new user I have to fire-up X and uncheck enable password expiration.
    LVL 1

    Accepted Solution

    The "chage" command will change the expiration of a specific user.

    /etc/login.defs defines the default max password age, PASS_MAX_DAYS

    When you do adduser, the default password expiry is set to that value.  Change that value to be 99999 for the maximum lenght - I trust your user won't live to be 273years old.

    useradd only takes the values in the form of a date, e.g

    useradd -e 2299-01-01 bob

    would add a user named bob who would expire on January 1st, 2229

    I think you really just want to set PASS_MAX_DAYS and you'll be all set.  You might need to reset all the other users in your system if they haven't been all set not to expire..You can do that with

    for m in `cat /etc/passwd|awk -F: {'print $1'}`;do chage -M 99999 $m;done

    Best Regards,

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now