Set and change passwd password in linux

Source: Internet
Author: User

In linux, the passwd command is used to modify the user password and set the user password. Let's take a closer look at the passwd password modification and setting the instance.

For the sake of system security, in Linux, each user has a user name and password. Therefore, when you use the useradd command to add a new user, you also need to use the passwd command to set a password for each new user. Later, you can use the passwd command to change your password at any time.

The common format of this command is passwd [user name]. The user name is the user name that needs to change the password. Only super users can use "passwd User Name" to modify passwords of other users. Common users can only use passwd commands without parameters to modify their own passwords.

Passwd syntax structure:

First of all, you must know what a man says is very responsible ". Let's take a look at what a man says about this passwd. Er, this command is not available in the man Manual's Chinese package, so everyone is familiar with the favorite english. Haha.

NAME
Passwd-update a user's authentication tokens (s)

SYNOPSIS
Passwd [-k] [-l] [-u [-f] [-d] [-n mindays] [-x maxdays] [-w warndays] [-I inactivedays] [-S]
[-- Stdin] [username]

Passwd parameters:

The passwd command also has many parameters. The Last User Name does not need to be mentioned. The following describes some of the main parameters that are found on the Internet, however, my simple translation should be like this.

Main Parameters

-L: the name of the named account is locked and can only be used by users with super user permissions.

-U: Unlock the account lock status. Only users with Super User Permissions can use it.

-X, -- maximum = DAYS: maximum Password usage time (DAYS). Only users with Super User Permissions can use it.

-N, -- minimum = DAYS: minimum Password usage time (DAYS). Only users with Super User Permissions can use the password.

-D: Delete the user's password. Only users with Super User Permissions can use it.

-S: Check the password authentication type of a specified user. Only users with Super User Permissions can use the password.

Passwd usage rules:

As we all know, in Linux, the "root" account is definitely a big BOSS and has the highest power. Haha. We also saw yesterday that the new account was created with the root permission, so we don't have to say that if the user's password is lost, we can ask the root user to help change the password, root does not need to know your original password. In addition, only the root user can set a password, even if the password does not meet the system password requirements.

In addition, you can change your password. In this case, passwd does not need to be followed by the user name. However, common users must follow certain rules. The password creation rule file is/etc/pam. d/passwd, which sets some rules for setting the Linux User Password.

Generally, the entered password must meet the following requirements:

• The password cannot be the same as the account name
• Do not use strings in the dictionary of English words as much as possible.
• The password must exceed 8 characters

The password should contain at least six (preferably eight) characters;

Passwords should contain uppercase/lowercase letters, punctuation marks, and numbers.


Example of passwd:

Without saying anything, I also set a password for several junk accounts I created yesterday. Haha.

[Cc lang = 'bash']
# Create a password for the root user. You can change the password directly without following any rules.
[Simaopig @ xiaoxiaozi pam. d] $ su
Password:
[Root @ xiaoxiaozi pam. d] # passwd chongpig
Change the password of the user chongpig.
New password:
Re-enter the new password:
Invalid password: it is based on dictionary words
Invalid password: Too simple
Passwd: All authentication tokens have been successfully updated.
[Root @ xiaoxiaozi pam. d] # passwd chongpig
Change the password of the user chongpig.
New password:
Re-enter the new password:
Invalid password: it is based on dictionary words
Invalid password: Too simple
Passwd: All authentication tokens have been successfully updated.
[Root @ xiaoxiaozi pam. d] # grep chongpig/etc/shadow
Chongpig: $6 $ mVu5nBAo $ assets/2HCcsHwKRoRpxGLCJ. wA.1QLgG. rXuhw/: 14447: 0: 99999: 7 :::
[/Cc]

Although it is too simple to tell me the password, even though it is based on words, what do I fear? This is root. You can check the column. Now, the chongpig account can be logged on with a password, and the password column in/etc/shadow has a value, not anymore !!

[Cc lang = 'bash']
# Change the current user password, Not A roto account
[Simaopig @ xiaoxiaozi ~] $ Passwd
Change the password of your simaopig.
Change the STRESS password for simaopig.
(Current) UNIX password:
New password:
Re-enter the new password:
Password not changed
Password not changed
Password not changed
Password:
Passwd: the maximum number of service retries has been exceeded.

[Simaopig @ xiaoxiaozi ~] $ Passwd
Change the password of your simaopig.
Change the STRESS password for simaopig.
(Current) UNIX password:
New password:
Re-enter the new password:
Invalid password: too similar to the old password
Invalid password: too similar to the old password
Invalid password: too similar to the old password
Password:
Passwd: the maximum number of service retries has been exceeded.

[Simaopig @ xiaoxiaozi ~] $ Passwd
Change the password of your simaopig.
Change the STRESS password for simaopig.
(Current) UNIX password:
New password:
Re-enter the new password:
Passwd: All authentication tokens have been successfully updated.
[/Cc]

As you can't see, the treatment for common users is different, and there are various restrictions and troubles. But you 'd better change your password.


The process for a superuser to modify the password of another user (xxq) is as follows,

The Code is as follows: Copy code

# Passwd root

New UNIX password:

Retype new UNIX password:

Passwd: all authentication tokens updated successfully

#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.