User group creation management in Linux systems

Source: Internet
Author: User
Tags change settings comments


1, create a group

Groupadd Test

Add a test group

2, modify the group

Groupmod-n test2 Test

Change the name of the test group to Test2

3, delete the group

Groupdel test2

Delete Group Test2

4, view Group

A), view the group groups the currently logged-on user, and view the Apacheuser group groups APAC

One, group operation

1, create a group

Groupadd Test

Add a test group

2, modify the group

Groupmod-n test2 Test

Change the name of the test group to Test2

3, delete the group

Groupdel test2

Delete Group Test2

4, view Group

A), view the group groups the currently logged-on user, and view the Apacheuser group groups Apacheuser

b), view all groups Cat/etc/group

c), some Linux systems do not have/etc/group files, this time look at the following method

CAT/ETC/PASSWD |awk-f [:] ' {print $} ' |sort|uniq | Getent group |awk-f [:] ' {print '} '

Here is a command is getent, you can find the group information through the group ID, if this command does not, it is difficult to find, all the groups in the system.

Second, user action

1, Increase user

View copy print?

[Root@krlcgcms01 mytest]# Useradd–help

Usage:useradd [Options] LOGIN

Options:

-b,–base-dir Base_dir set basic path as user's login directory

-c,–comment comment comments to the user

-d,–home-dir Home_dir Set the user's login directory

-d,–defaults Change settings

-e,–expiredate Expire_date Set the user's expiration date

-f,–inactive The password is invalid after the inactive user expires

-g,–gid Group makes a user belong to only one group

-g,–groups groups enable users to join a group

-h,–help Help

-k,–skel Skel_dir Specifies the other Skel directory

-k,–key key=value Overwrite/etc/login.defs configuration file

-m,–create-home Automatically create login directory

-L, do not add users to the Lastlog file

-M does not automatically create a login directory

-R, set up system account

-o,–non-unique allows the user to have the same UID

-p,–password Password to use encrypted passwords for new users

Shell at the time of-s,–shell shell login

-u,–uid UID assigns a UID to a new user

-z,–selinux-user Seuser use a specific seuser for the SELinux user mapping

[Root@krlcgcms01 mytest]# Useradd--help

Usage:useradd [Options] LOGIN

Options:

-B,--base-dir Base_dir set the basic path as the user's login directory

-C,--comment comment comments to the user

-D,--home-dir Home_dir set the user's login directory

-D,--defaults change settings

-E,--expiredate expire_date set the user's expiration date

-F,--inactive inactive user expires, make password invalid

-G,--gid group makes the user belong to only one group

-G,--groups groups allows users to join a group

-H,--help help

-K,--skel skel_dir specifies the other Skel directory

-K,--key key=value overwrite/etc/login.defs configuration file

-M,--create-home automatically create login directory

-L, do not add users to the Lastlog file

-M does not automatically create a login directory

-R, set up system account

-O,--non-unique allows the user to have the same UID

-p,--password password uses encrypted passwords for new users

-S, shell at the time of--shell shell login

-U,--uid uid specifies a UID for the new user

-Z,--selinux-user seuser use a specific seuser for the SELinux user Mappinguseradd test

passwd test

Add user test, one thing to note, useradd add a user, do not forget to set a password for him, otherwise can not log in.

2, modify the user

usermod-d/home/test-g test2 Test

Change the login directory of test user to/home/test and join Test2 Group, note that this is big G.

Gpasswd-a test test2 Add user test to the Test2 group

gpasswd-d test test2 Remove user test from the Test2 group

3, delete user

Userdel Test

Remove the test user

4, view the user

A), view the currently logged-on user

[Root@krlcgcms01 ~]# W

[Root@krlcgcms01 ~]# who

b), view your own user name

[Root@krlcgcms01 ~]# WhoAmI

c), viewing individual user information

[Root@krlcgcms01 ~]# Finger Apacheuser

[Root@krlcgcms01 ~]# ID Apacheuser

d), viewing user logon Records

[Root@krlcgcms01 ~]# Last view login successful user record

[Root@krlcgcms01 ~]# lastb View logon unsuccessful user record

e), view all users

[Root@krlcgcms01 ~]# cut-d:-F 1/ETC/PASSWD

[Root@krlcgcms01 ~]# cat/etc/passwd |awk-f: ' {print $} '

USERMOD-G group LoginName forcibly set a user's group usermod-g groups loginname to change a user to group (s) usermod-a-G groups loginname to add users to a set ( s) should be used like this? I always use the graphical interface to change the program

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.