Linux notes ... File and Directory Properties Useradd, Userdel, Usermod, passwd

Source: Internet
Author: User
Tags stdin uppercase letter

Adding and removing users

Useradd-u Custom Uid-g Custom gid-d Specify home directory-m do not build home directory-S custom shell

such as: #useradd-u 508-g 500-d/home/user3/-s/bin/nologin user2

#tail-2/etc/passwd

User2:x:508:500::/home/user3/:/bin/nologin

By adding a user to a group, the group cannot be deleted, and the group that owns the user needs to be modified before it can be deleted

Userdel-r Username Delete a user

Delete User's time, do not add-R then delete the user's directory afterwards, can only manually

Rm-rf/home/username/var/spool/mail/username

such as: Userdel-r User3

Userdel:/home/user3 does not belong to User3, so it does not delete

[Email protected] ~]# Rm-rf/home/user3/var/spool/mail/user3


Usermod Modifying user Properties

-U uid-g gid-d Change home directory-S change user shell-g change extension group-l lock User (cannot log on)-U unlock

If the user's extension group is within group, then the group can be deleted.

such as [[email protected] ~] #id aming123

uid=501 (aming123) gid=513 (aming123) group =513 (aming123)

[[email protected] ~]# ID User3

uid=506 (User3) gid=502 (GRP1) group =502 (GRP1), (GRP2)

[Email protected] ~]# Groupdel GRP2

[[email protected] ~]# ID User3

uid=506 (User3) gid=502 (GRP1) group =502 (GRP1)


passwd Modifying user passwords

Change the current user password after passwd not with the user name

MKPASSWD automatically generate passwords

Mkpasswd-l n Specifies a length of n

-S n specifies a special character n

-D n Specifies the number of n

-c n Specifies a lowercase n

-c n specifies an uppercase letter N

#passwd--stdin username to enter the plaintext password for username The shell implementation is required to set the password for the user

If you give: aming123 set the password

#echo "aminglinux.com" |passwd--stdin aming123

Change the password for the user aming123.

PASSWD: All the authentication tokens have been successfully updated.

If no user name is given, the password is changed to root by default


Linux notes ... File and Directory Properties Useradd, Userdel, Usermod, passwd

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.