One, group operations
1, create a group
Groupadd Test
Add a test group
2, modify Group
Groupmod-n test2 Test changes the name of the test group to Test2
3, deleting a group
Groupdel test2 Delete Group Test2
4, viewing groups
A), view the group groups where the current logged-on user is located, 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 to see the following method
CAT/ETC/PASSWD |awk-f [:] ' {print $4} ' |sort|uniq | Getent group |awk-f [:] ' {print $} '
Here a command is getent, you can find the group information through the group ID, if the command is not, it is difficult to find, all the groups in the system.
Two, user operation
1, increase the user
[Email protected] mytest]# useradd--help usage:useradd [options] Login options:-B,--base-dir Base_dir set basic path as user's login directory -C,--comment comment comment to user-D,--home-dir home_dir set User's login directory-D,--defaults change settings-E,--expiredate expire_date set user's validity period -F,--inactive inactive the user expires, the password is invalid-G,--gid group makes the user belong to a group-G,--groups groups let the user join a group-H,--help help-K,--skel skel_d IR Specify additional Skel directory-K,--key key=value overwrite/etc/login.defs profile-M,--create-home automatically create login directory-L, do not add user to Lastlog file-m, do not automatically create login directory -R, set up the SYSTEM Account-O,--non-unique allows the user to have the same uid-p,--password password for the new user to use the encryption password-s,--shell Shell login time shell-u,--uid uid for the new The user specifies a uid-z,--selinux-user seuser use a specific seuser for the SELinux user mapping
Useradd TESTPASSWD Test
Add user test, one thing to note, useradd add a user, do not forget to set a password for him, otherwise you can not log in.
2, modify the user
usermod-d/home/test-g test2 Test
Change the login directory of the test user to/home/test and join the Test2 group, note that this is the big G.
Gpasswd-a test test2 Add user test to Test2 Group gpasswd-d test test2 Remove user test from Test2 Group
3, delete user
Userdel test deletes the test user
4. View Users
A) to view the currently logged on user
[[email protected] ~]# W[[email protected] ~]# who
b), view your user name
[Email protected] ~]# WhoAmI
c) To view individual user information
[[email protected] ~]# finger apacheuser[[email protected] ~]# ID apacheuser
d) To view user login records
[[email protected] ~]# Last view login successful user record [[email protected] ~]# LASTB View login unsuccessful user record
e), view all users
[[email protected] ~]# cut-d:-F 1/etc/passwd[[email protected] ~]# cat/etc/passwd |awk-f \: ' {print $} '
Reprint: Address: http://blog.51yip.com/linux/1137.html
Add, delete, modify, view users and user groups under Linux