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

Application example tutorial of key in Vue page rendering

introduction During the front-end project develop...

Tutorial on installing lamp-php7.0 in Centos7.4 environment

This article describes how to install lamp-php7.0...

Docker cleanup environment operation

Start cleaning carefully! List unused volumes doc...

How to install and deploy ftp image server in linux

Refer to the tutorial on setting up FTP server in...

Echarts implements switching different X-axes in one graph (example code)

Rendering If you want to achieve the effect shown...

How to optimize MySQL deduplication operation to the extreme

Table of contents 1. Clever use of indexes and va...

JavaScript MouseEvent Case Study

MouseEvent When the mouse performs a certain oper...

How to create a Django project + connect to MySQL

1: django-admin.py startproject project name 2: c...

Detailed explanation of Vue routing router

Table of contents Using routing plugins in a modu...

Three common uses of openlayers6 map overlay (popup window marker text)

Table of contents 1. Write in front 2. Overlay to...

Instructions for using the meta viewport tag (mobile browsing zoom control)

When OP opens a web page with the current firmwar...

The best explanation of HTTPS

Good morning everyone, I haven’t updated my artic...

MySQL sorting feature details

Table of contents 1. Problem scenario 2. Cause An...