Skip to main content
Engineering LibreTexts

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

  • Page ID
    26810
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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 is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Patrick McClanahan.