Management of accounts and groups for Linux commands

Source: Internet
Author: User
Tags stdin root access

The management of the account and group by the Linux system is realized by ID number, the user ID is called UID, and the group ID is called GID. Where the UID is 0, which represents the super administrator, the root account. A component is a basic group and an additional group, and a user can have only one base group at a time, but multiple additional groups may be added. By default, when you create a user, a group with the same name is created and is a basic group.

Create a user and group:

1 Useradd: Create a new account

Option:-C account description information, generally full name

-D Set home directory, default to/home/user name

-e Set the expiration date of the account in the format 2017-10-30

-G Set the basic group of Accounts

-G Sets the additional group for the account, if multiple are separated by commas

-M does not create a user's home directory

-S sets the login shell for the account, which is bash by default

-U Specify account UID

[Email protected] ~]# useradd-c administrator-d/home/admin-e 2017-10-10-g root-g bin,adm,mail Admin

[Email protected] ~]# useradd-s/sbin/nologin-m ABC #创建无法登陆系统且无家目录的用户abc


2 Groupadd: Create a group account

Option:-G set Group ID number

[Email protected] ~]# groupadd-g ZWJ


3 ID: View user information

[[email protected] ~]# ID ABC

uid=502 (ABC) gid=502 (ABC) groups=502 (ABC)


Two modify accounts and groups

1 passwd: Update account authentication information

Usage: passwd [options] Account name

Option:-L lock account, root access

-U Unlock Account

-D clears the account password and requires root access

--stdin reading a password from a file or pipe

[Email protected] ~]# passwd ABC #为用户abc指定密码

[Email protected] ~]# echo "ABCDEFG" | passwd--stdin ABC #设置密码的另一种方式

[Email protected] ~]# passwd-d ABC #清空密码

[Email protected] ~]# passwd-l cc #锁住账户

[Email protected] ~]# passwd-u cc #解锁账户


2 Usermod: Modify account information

Usage: usermod [options] Account name

Option:-D to modify home directory, directory must exist

-E Modify Expiration date

-G Modify the basic group of accounts (already present)

-a-g modify additional groups if no-a overrides the previous group

-S Modify Login shell

-U Modify user uid

[Email protected] home]# usermod-d/home/cc admin #修改admin的家目录

[Email protected] home]# usermod-g root cc #修改cc的基本组

[Email protected] home]# usermod-e 2017-12-30 cc #修改cc的有效期

[Email protected] home]# usermod-a-G Mail cc #为cc添加附加组mail


Three delete accounts and groups

1 Userdel: Delete Account

Option:-r Delete account and related files

[Email protected] home]# userdel-r cc #删除账户及相关文件

[Email protected] home]# Userdel CCC #删除账户


2 Groupdel: Delete a group account

[Email protected] home]# Groupdel cc


This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1916784

Management of accounts and groups for Linux commands

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.