Linux User/user group add Modify Delete (Ubuntu/centos)

Source: Internet
Author: User


One, LINUX (ubuntu/centos) Users add delete Modify 1, build users: [Plain]View PlainCopy
    1. AddUser Web//New Web user
    2. Useradd web-m #添加web Users
    3. passwd Web//Set password for Web users
    4. Useradd web-g Admin-n-m//Create a new Web user and specify the user group as the Admin user group and automatically establish the login directory
    5. passwd Web//Set password for Web users
[Plain]View PlainCopy
    1. Useradd (option) (parameter)
    2. -c< Remarks: Add notes text. Note text is saved in the comment field of passwd;
    3. -d< login Directory;: Specify the starting directory for user login;
    4. -D: Change the preset value;
    5. -e< validity period;: Specify the expiry date of the account;
    6. -f< buffer days;: Specify how many days after the password expires to close the account;
    7. -g< Group;: Specify the group to which the user belongs;
    8. -g< Group;: Specifies the additional group to which the user belongs;
    9. -M: Automatically set up the user's log in directory;
    10. -M: Do not automatically set up the user's log in directory;
    11. -N: Cancels the creation of a group named after the user name;
    12. -R: Establish the system account number;
    13. -S: Specifies the shell to use when the user is logged in;
    14. -U: Specifies the user ID.

2. Increase the Working Group for existing users [Plain]View PlainCopy
    1. Usermod-g Admin Web #Set up admin affiliate user groups for web users
      #Add multiple user groups to user settings
      Usermod-g web-g admin, www web ා set the main user group for web users web group, admin, www affiliated Users Group
      Gpasswd-a web admin sets the admin user group for web users
3, new users at the same time increase the Working group [Plain]View PlainCopy
    1. USERADD-G Admin Web//new Web user and add to admin workgroup


Note::-G belongs to the group-D home Directory-S used by the shell


4. Temporary closure


Method One
The second field (password) of the row that belongs to the user in the/etc/shadow file is preceded by a *. To restore the user, remove the *.
Method Two
To close a user account using a command:


[Plain]View PlainCopy
    1. passwd web–l


Re-release:


[Plain]View PlainCopy
    1. passwd Web–u
5. Permanently delete user account [Plain]View PlainCopy
    1. Userdel Web
    2. Groupdel Web
    3. Usermod–g Web web (forcibly deleting all files and subdirectories in the user's home directory and home directory)
7. Remove users from the group


Edit/etc/group Find User group admin that row, delete user name web
or with a command.


[Plain]View PlainCopy
    1. gpasswd-d A Web
8. Display user Information [HTML]View PlainCopy
    1. ID User
    2. cat/etc/passwd
Ii. User Group LINUX (ubuntu/centos) Add Delete Modify 1, build workgroup [Plain]View PlainCopy
    1. Groupadd Admin//New admin Workgroup
2. Modify user groups [Plain]View PlainCopy
    1. Groupmod-n newadmin Admin #修改admin用户组名称改为newadmin
3. Delete user groups [Plain]View PlainCopy
    1. Groupdel Admin #删除admin用户组
4. View user group information for users




[Plain]View PlainCopy
      1. Groups Web #查看web所有用户组


Linux User/user group add Modify Delete (Ubuntu/centos)


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.