02-B.8: Users: Create, Modify, and Delete - passwd Command

Linux - The Penguin Marches On · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    02-B.8: Users: Create, Modify, and Delete - passwd Command

    The passwd Command

    Changing user password in Linux is quite simple using the passwd command.

    Syntax:

    passwd [ OPTIONS ] username
    

    Command Options:

    Options Meaning
    -u This is the reverse of the -l option - it will unlock the account password by removing the ! prefix. This option is available to root only. By default passwd will refuse to create a passwordless account (it will not unlock an account that has only "!" as a password). The force option -f will override this protection.
    -d This is a quick way to delete a password for an account. It will set the named account passwordless. Available to root only.
    -e This is a quick way to expire a password for an account. The user will be forced to change the password during the next login attempt. Available to root only.

    If a user want to change their current password (assuming the user's id is pbmac), simply run this command in a terminal:

    passwd
    OR
    passwd <username> - where you replace <username> with a valid username to change the password of another user
    

    The system will ask the user to enter their current password and the new password twice.

    The user won’t see anything on the screen while typing the password. This is perfectly normal behavior for Linux.

    $ passwd
    Changing password for pbmac.
    (current) UNIX password: 
    Enter new UNIX password: 
    Retype new UNIX password: 
    passwd: password updated successfully

    Since this is an admin account, the sudo password just got changed without even realizing it.

    If you want to change the password for some other user, you can do that as well with the passwd command. But in this case, you’ll have to use sudo.

    $ sudo passwd santiago
    Changing password for santiago.
    (current) UNIX password:
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully

    This page titled 02-B.8: Users: Create, Modify, and Delete - passwd Command was last modified on Mon, 03 Oct 2022 05:36:10 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Patrick McClanahan.