Linux instruction detailed useradd groupadd passwd chpasswd chage Password modification

Source: Internet
Author: User
Tags stdin

Create a user, set a password, modify a user, delete a user:

Useradd testuser Create user TestUser

passwd TestUser set a password for the created user TestUser

Description: The newly created user will create a user directory under/home TestUser

Usermod--help Modify user parameters for this command

Userdel testuser Delete User testuser

RM-RF testuser Delete the directory where the user testuser is located


The above commands can only be used by the root account, if you do not know where the command above your system can use the following command to find its path:


Locate Useradd


When a new user is created, the information about the new user is added to the passwd file in the ETC directory.

Description: In order to, I used the tail-3 passwd command here, only the last 3 lines of the file (and the information I'm concerned about) are displayed.

Linux create users, set passwords, modify users, delete users

User Switching between command-line windows:

SU User name

Description: SU is an abbreviation for switch user, indicating

Enter "Exit" from the new user state to return to the user state you just made


Add and remove user groups:

Groupadd Adding a testgroup group

GROUPADD-G 201 Sales Increase Group ID number is 201 for sales group

Usermod-a-G sales username adds username to 1 new group sales, preserving the original group.

Groupdel Removal of Testgroup Group

Note: the addition and deletion information of the group is reflected in the groups file of the ETC directory.


/etc/login.defs set up a user's default environment, the default setting is 9,999 days

echo Password | passwd--stdin username Set the password password to username

passwd the--stdin parameter Ubuntu does not support, Debian does not support this


1, passwd simple description;


We have learned how to add users, so we also have to learn to set or modify the user's password, passwd command is also a lot of usage, we only select the following parameters to illustrate; For more information, please refer to man passwd or passwd--help;



passwd [OPTION ...]


passwd as a normal user and superuser can run, but as a normal user can only change their user password, but the premise is not locked by the root user, if the root user run passwd, you can set or modify any user's password;


The passwd command does not follow any parameters or user names, which means to modify the current user's password, see the following example;

[[email protected] ~]# passwd Note: No user, I am the root user to execute the passwd means to modify the root user's password;

Changing password for user root.

New UNIX Password: NOTE: Please enter the password;

Retype new UNIX Password: note: Verify the password;

Passwd:all authentication tokens updated successfully. Note: The root password is changed successfully;


If the ordinary user executes passwd can only modify their own password;


If you want to create a password for a new user after creating a new user, use the passwd user name, and note that you want to create it with the root user's permission;


[Email protected] ~]# passwd Beinan Note: Change or create a password for the Beinan user;

Changing password for user Beinan.

New UNIX Password: NOTE: Please enter the password;

Retype new UNIX Password: note: Enter again;

Passwd:all authentication tokens updated successfully. Note: success;


If the ordinary user wants to change their own password, run passwd directly, for example, the user of the current operation is Beinan;


[Email protected] ~]$ passwd

Changing password for user Beinan. Note: Change the password of the Beinan user;

(current) UNIX Password: NOTE: Please enter the current password;

New UNIX Password: NOTE: Please enter the password;

Retype new UNIX Password: note: confirm the password;

Passwd:all authentication tokens updated successfully. Note: The change was successful;



2, passwd a few more important parameters;


[Email protected] beinan]# passwd--help

USAGE:PASSWD [OPTION ...] <accountName>

-K,--keep-tokens keep non-expired authentication tokens

Note: Retention of expiring users can still be used after the expiry date;

-D,--delete delete the password for the named account (root only)

Note: Delete user password, only can operate with root permission;

-L,--lock lock the named account (root only)

Note: The locked user does not have the right to change his or her password, only through root permission;

-U,--unlock unlock the named account (root only)

Note: Unlock the lock;

-F,--force Force operation

Note: Force operation; Only the root permission is required to operate;

-X,--maximum=days Maximum password lifetime (root only) Note: two times the maximum number of password corrections, followed by the number; only root operation;

-N,--minimum=days Minimum password lifetime (root only) Note: two times the minimum number of password modifications, followed by numbers, only the root permission to operate;

-W,--warning=days number of days warning users receives before note: Remind the user to change the password at the distance of the day, only the root permission operation;

Password expiration (root only)

-I,--inactive=days number of days after password expiration if an note: After the password expires, the user is banned and can only be operated as root;

Account becomes disabled (root only)

-S,--status report password status in the named account (Root Note: Query the user's password status, only the root user can operate;

only)

--stdin read new tokens from stdin (root only)


For example, we let a user cannot change the password, you can use the-l parameter to lock:


[[email protected] ~]# passwd-l Beinan Note: Lock user Beinan cannot change password;

Locking password for user Beinan.

Passwd:success Note: The lock is successful;

[[email protected] ~]# su Beinan NOTE: Switch to Beinan user via su;

[[email protected] ~]$ passwd Note: Beinan to change the password;

Changing password for user Beinan.

changing password for Beinan

(current) UNIX Password: Note: Enter the current password for Beinan;

Passwd:authentication Token manipulation Error Note: Failed, cannot change password;



One more example:


[[email protected] ~]# passwd-d Beinan Note: Clear the Beinan user password;

Removing password for user Beinan.

Passwd:success Note: Clear success;

[[email protected] ~]# passwd-s Beinan Note: Query Beinan user password status;

Empty password. Note: Empty password, that is, no password;


Note: When we clear a user's password, login without password;




Linux Instructions chpasswd Bulk modification of user passwords

Syntax:
1:# echo User name: password | chpasswd
2:# chpasswd < Doiido.txt
Parameters:
-E: If the-e option is used, the password will only beEncryptionthe way to pass
If the-e option is not used, the password is passed as clear text

Precautions
1: The user name must beSystemusers that already exist on
2: Normal user does not have permission to use this command
3: If the input file is passed unencrypted, please encrypt the file appropriately.
4: Command file cannot have blank line

1, directly modify the Doiido user's password is Helloboy

Echo Doiido:helloboy |chpasswd

2. Use the user name password in doiido.txt to modify the password of the corresponding user in bulk
2.1: First build the instruction file Doiido.txt (in the format [USERNAME:PASSWD])
# VI Doiido.txt
Doiido1:helloboy
Doiido2:hellogirl

2.2: Transfer the contents of Doiido.txt to the chpasswd instruction to modify the corresponding user's password
# chpasswd < Doiido.txt

3, let ordinary users use CHPASSWD
The default normal user does not have CHPASSWD permissions, but can modify the command file permissions by modifying the
# chmod 4755/USR/SBIN/CHPASSWD
so that ordinary users can use CHPASSWD to modify the password


Chage command

function: Modify the expiration date of the account and password
usage: chage[-l][-m mindays][-m maxdays][-i inactive][-e expiredate][-w warndays][-d lastdays]username
Parameters:
- L: Lists the user's and password expiration dates
-M: Minimum number of days to change password
-M: Maximum number of days to change password
-I : number of days to lock account after password expires
-D: Specify the date the password was last modified
-E: valid, 0 means immediate expiration, 1 means never expires
-W: Start warning days before password expires

CHAGE-M username Change Password is valid for 30 days

Chage-d 2012-01-01 username user must change password at next logon


SSH [email protected] SSH analog login authentication password


This article is from the "@ Fast unblocked @" blog, make sure to keep this source http://speediness.blog.51cto.com/760841/1783661

Linux instruction detailed useradd groupadd passwd chpasswd chage Password modification

Related Article

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.