Get the App
SLTechnology News&Howtos  ›  Servers  › 

The usage of the Linux basic command passwd

Shulou Source: shulou.com Published: 2022-06-01 12:43:29 09月12日 Update

This article introduces the "Linux basic command passwd usage" knowledge, in the actual case of the operation process, many people will encounter such a dilemma, then let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

passwd

Change user password, super user can change all user passwords, ordinary users can only change their own passwords. This task is accomplished by calling Linux PAM and Libuser API. Essentially, it initializes itself as a "passwd" service using Linux PAM and authenticates and updates the user's password with a configured password module.

This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

passwd [options] user

passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i inactivedays] [-S] [--stdin] [username]

2. Option list

option

description

--help

Show Help Documentation

--version

Show command version

-d

Delete user password, only root user can use

-e

Invalidates user password, forces user to change password next time login, only root user can use

-n

Set the minimum valid password time, only root user can use it

-x

Set the maximum valid password time, only root user can use it

-S

Displays a short password message that can only be used by root

-l

Lock user, only root user can use

-u

Unlock user, only root user can use

-k

The option-k indicates that the update applies only to expired authentication tokens (passwords); the user wants to keep their unexpired tokens as before.

-i

This sets the number of days that expired passwords for this account will be considered inactive, and the user account should be disabled if it supports password lifetime. Available only to root users.

-w

This sets the number of days users will start receiving warnings that their passwords will expire if their account supports password lifetime. Available only to root users.

--stdin

This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.

3. Examples

1) Lock the user, after locking, you cannot log in

[root@localhost david]# passwd -l david //lock user

Lock user david's password.

passwd: Operation successful

[root@localhost david]# passwd -u david //Unlock user

Unlock user david's password.

passwd: Operation successful

2) Delete user password

[root@localhost david]# passwd -d david //Clear user david password

Clear user password david.

passwd: Operation successful

[root@localhost david]# su weijie //Switch to ordinary Hu Yong weijie

[weijie@localhost david]$su david //Switch from ordinary user weijie to ordinary user david, no password required

[david@localhost ~]$

"Linux basic command passwd usage" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: User password only command normal account success base valid token content days lifetime indication time more knowledge identity switching support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Microsoft NVidia OPPO Reno