Linux Method for modifying groups to which users belong

  • 2021-07-22 12:21:58
  • OfStack

Linux Modify the group to which the user belongs

1. Set up a user's group


usermod -g  User group   User name 

Note:-g-gid, modify user's gid, this group 1 definitely exists

2. Add users to a group (s)


usermod -a -G  User group   User name 

Note:

-a--append, appending users to certain groups, using only with-G option 1

-G--groups, appending users to certain groups, using only with-a option 1

Content extension

User management command

useradd Note: Add User
adduser Note: Add User
passwd Note: Set password for user
usermod Note: Modify the user command, you can modify the login name, user's home directory and so on through usermod;
pwcov Note: Synchronize users from/etc/passwd to/etc/shadow
pwck Note: pwck is to verify whether the contents of user profiles/etc/passwd and/etc/shadow are legal or complete;
pwunconv Note: It is the vertical and reverse operation of pwcov, which creates the/etc/passwd from the/etc/shadow and/etc/passwd, and then deletes the/etc/shadow file;
finger Note: View User Information Tool
id Note: View the user's UID, GID and the user group to which they belong
chfn Note: Change User Information Tool
su Note: User Switching Tool
sudo Note: sudo executes commands through another user (execute a command as another user), su is used to switch users, and then complete corresponding tasks through the switched users, but sudo can directly execute commands later, for example, sudo can execute the execution assigned by root without root password, and only root can execute corresponding commands; But it has to be edited by visudo/etc/sudoers.
visudo Note: visodo is the command to edit /etc/sudoers; You can also use vi to edit/etc/sudoers without this command. The effect is 1;
sudoedit Note: It has similar functions to sudo;

The above is the whole content of this introduction. Thank you for your study and support for this site.


Related articles: