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

Summary of several implementations of returning to the top in HTML pages

Recently, I need to make a back-to-top button whe...

About Tomcat combined with Atomikos to implement JTA

Recently, the project switched the environment an...

Vue uses Amap to realize city positioning

This article shares the specific code of Vue usin...

Mysql some complex sql statements (query and delete duplicate rows)

1. Find duplicate rows SELECT * FROM blog_user_re...

Linux uses iptables to limit multiple IPs from accessing your server

Preface In the Linux kernel, netfilter is a subsy...

JavaScript to achieve a simple carousel effect

What is a carousel? Carousel: In a module or wind...

How to install elasticsearch and kibana in docker

Elasticsearch is very popular now, and many compa...

Detailed explanation of three ways to cut catalina.out logs in tomcat

1. Log4j for log segmentation 1) Prepare three pa...

Detailed explanation of HTML area tag

The <area> tag defines an area in an image ...

Some experience sharing on enabling HTTPS

As the domestic network environment continues to ...

How to choose and use PNG, JPG, and GIF as web image formats

So which one of these formats, GIF, PNG, and JPG,...

Notes on the MySQL database backup process

Today I looked at some things related to data bac...

Display special symbols in HTML (with special character correspondence table)

Problem Reproduction When using HTML for editing,...

Detailed explanation of JQuery selector

Table of contents Basic selectors: Level selector...