Skip to main content

Command Palette

Search for a command to run...

Cheatsheet & Examples: passwd

Updated
2 min read
H

I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)

Change Password for Current User

Example Usage:
passwd

What it does:
Changes the password for the current user.

Command-line Arguments Explained:

  • --stdin (optional): Reads password from standard input (not recommended for security).
  • --show (optional): Displays the password in a simplified format (e.g., *).
  • --no-e (optional): Disables password expiration.
  • --no-s (optional): Disables showing password in simple format.
  • --help (optional): Displays help information.
  • --version (optional): Displays version information.

Lock Account

Example Usage:
passwd -l

What it does:
Locks the current user account to prevent unauthorized access.

Command-line Arguments Explained:

  • -l (required): Locks the account.

Unlock Account

Example Usage:
passwd -u

What it does:
Unlocks a locked account.

Command-line Arguments Explained:

  • -u (required): Unlocks the account.

Set Password Expiration Date

Example Usage:
passwd -e

What it does:
Sets the password expiration date for the current user.

Command-line Arguments Explained:

  • -e (required): Sets the expiration date.
  • -x (optional): Sets the number of days until the password expires.
  • -n (optional): Sets the number of days before the password expires.

Delete Previous Password

Example Usage:
passwd -d

What it does:
Deletes the previous password and prompts for a new one.

Command-line Arguments Explained:

  • -d (required): Deletes the previous password.

Use Standard Input for Password

Example Usage:
passwd -stdin

What it does:
Reads the password from standard input (not recommended for security).

Command-line Arguments Explained:

  • -stdin (optional): Reads password from standard input.

Show Password in Simple Format

Example Usage:
passwd -s

What it does:
Displays the password in a simplified format (e.g., *).

Command-line Arguments Explained:

  • -s (optional): Shows password in simple format.

Change Password for Another User

Example Usage:
passwd -u <username>

What it does:
Changes the password for a specified user.

Command-line Arguments Explained:

  • -u (required): Specifies the user to change the password for.
  • <username> (optional): The username of the target user.

Set Password Expiration Days

Example Usage:
passwd -x <days>

What it does:
Sets the number of days until the password expires.

Command-line Arguments Explained:

  • -x (required): Sets the number of days until the password expires.
  • <days> (optional): The number of days.

Set Password Expiration Before Next Date

Example Usage:
passwd -n <days>

What it does:
Sets the number of days before the password expires.

Command-line Arguments Explained:

  • -n (required): Sets the number of days before the password expires.
  • <days> (optional): The number of days.

More from this blog

Hong's Tech Blog

110 posts

The blog is older than you know. I prefer counting from the emergence of one integral anomaly to the emergence of the next, in which case this is the forth version.