Use of Linux passwd command

Use of Linux passwd command

1. Command Introduction

The passwd command is used to set the user's authentication information, including user password, account lock, password expiration, etc.

System administrators can use it to manage the passwords of system users. Only administrators can specify user names, and ordinary users can only change their own passwords.

2. Command format

passwd [OPTIONS] [USERNAME]

Running passwd directly without any options or parameters means changing the current user's login password, which is also the most common usage of passwd.

3. Option Description

Note that required arguments for long options are also required for short options.

-k, --keep
Keep authentication tokens from expiring -d, --delete
Delete the password of the named account (root user only)
-l, --lock
Locks the password of the specified account (root user only). Locking is to add ! in front of the password encryption string so that the password verification fails. Note that the account is not completely locked, the user can still log in via other authentication methods, such as ssh public key authentication -u, --unlock
Unlock the password of the specified account (only for root user)
-e, --expire
Terminate the password of the specified account (root user only)
-f, --force
Force operation -x, --maximum=DAYS
Maximum password validity period (for root user only)
-n, --minimum=DAYS
Minimum password validity period (for root user only)
-w, --warning=DAYS
How many days before password expiration to start reminding the user (only for root user)
-i, --inactive=DAYS
How many days after the password expires will the account be disabled (only for root users)
-S, --status
Report the password status of the named account (root user only)
--stdin
Read token from standard input (root user only)
-?, --help
Display help information and exit --usage
Display brief usage information

4. Common Examples

(1) Change the password of the currently logged in account.

passwd

Please note that when setting user passwords, you must comply with the password standards of "complexity, memorability, and timeliness". Simply put, the password should be longer than 8 characters, contain uppercase and lowercase letters, numbers and special symbols, and be easy to remember and change regularly.

(2) To modify other user passwords, administrator privileges are required.

passwd USERNAME

(3) Lock the password of the specified account so that the user cannot log in using the password. Requires administrator privileges.

passwd -l USERNAME

(4) Unlock the password of the specified account. Requires administrator privileges.

passwd -u USERNAME

(5) Terminate the password of the specified account, forcing the user to change the password the next time he logs in. Requires administrator privileges.

passwd -e USERNAME

(6) Clear the login password so that users can log in without a password. Requires administrator privileges, is extremely risky, and is not recommended.

passwd -d USERNAME

(7) Query the password status of the account.

passwd -S dablelv
dablelv PS 2020-03-08 0 90 7 -1 (Password set, SHA512 crypt.)

Displays account status information. There are 7 fields in total, namely login name, password, last modification time, password modification interval (0), password validity period (90), warning time (7), and password does not expire (-1). The unit is day.

(8) Set the minimum and maximum number of days the password is valid.

passwd -x 100 -n 30 dablelv

#Check whether the setting is successful: passwd -S dablelv
dablelv PS 2020-03-08 30 100 7 -1 (Password set, SHA512 crypt.)

(9) How many days before password expiration should the user be reminded?

passwd -w 7 dablelv

The above is the detailed content of the use of Linux passwd command. For more information about Linux passwd command, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Linux gzip command compression file implementation principle and code examples
  • gzip command in linux
  • Usage of Linux userdel command
  • Use of Linux date command
  • How to run Linux commands in the background
  • Use of Linux ls command
  • Use of Linux read command
  • Use of Linux chkconfig command
  • Use of Linux usermod command
  • Use of Linux ln command
  • Linux cut command explained
  • Use of Linux gzip command

<<:  MySQL paging query method for millions of data volumes and its optimization suggestions

>>:  How to apply TypeScript classes in Vue projects

Recommend

Native JavaScript implementation of progress bar

The specific code for JavaScript to implement the...

Detailed explanation of MySQL database index

Table of contents 1. Introduction to MySQL Index ...

In-depth explanation of environment variables and configuration files in CentOS

Preface The CentOS environment variable configura...

HTML+CSS to create a top navigation bar menu

Navigation bar creation: Technical requirements: ...

Native JS to implement click number game

Native JS implements the click number game for yo...

In-depth explanation of Set and WeakSet collections in ES6

Table of contents Set is a special collection who...

Upgrade MySQL 5.1 to 5.5.36 in CentOS

This article records the process of upgrading MyS...

Detailed explanation of how to manually deploy a remote MySQL database in Linux

1. Install mysql Run the following command to upd...

Getting Started with CSS3 Animation in 10 Minutes

Introduction Animation allows you to easily imple...

XHTML tags have a closing tag

<br />Original link: http://www.dudo.org/art...

Docker container orchestration implementation process analysis

In actual development or production environments,...

Detailed explanation of using INS and DEL to mark document changes

ins and del were introduced in HTML 4.0 to help au...

Example of converting JS one-dimensional array into three-dimensional array

Today I saw a friend asking a question in the Q&a...