Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command passwd

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report