How to modify the group to which a user belongs in Linux

How to modify the group to which a user belongs in Linux

Modify the group to which a user belongs in Linux

1. Set a user's group

usermod -g user group username

Note: -g|--gid, modify the user's gid, the group must exist

2. Add the user to a group(s)

usermod -a -G usergroup username

Note:

-a|--append, append the user to certain groups, only used with the -G option

-G|--groups, add the user to certain groups, only used with the -a option

Content Extension

User Management Commands

useradd Note: Add a user
adduser Note: Add a user
passwd Note: Set a password for the user
usermod Note: Modify user commands. You can use usermod to modify the login name, user's home directory, etc.
pwcov Note: Synchronize users from /etc/passwd to /etc/shadow
pwck Note: pwck is used to check whether the contents of the user configuration files /etc/passwd and /etc/shadow files are legal or complete;
pwunconv Note: It is the reverse operation of pwcov. It creates /etc/passwd from /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 he belongs
chfn Note: Change User Information Tool
su Note: User switching tool
sudo Note: sudo is to execute a command as another user. su is used to switch users and then complete the corresponding task through the switched user. However, sudo can directly execute commands afterwards. For example, sudo does not require the root password to execute the commands granted by root. Only root can execute the corresponding commands. However, this can be achieved by editing /etc/sudoers through visudo.
visudo Note: visodo is the command to edit /etc/sudoers. You can also use vi to edit /etc/sudoers directly without using this command, and the effect is the same.
sudoedit Note: It has similar functions to sudo;

The above is all the content of this introduction. Thank you for your learning and support for 123WORDPRESS.COM.

You may also be interested in:
  • Summary of common commands for Linux user and group management
  • How to create, modify, and delete users and groups in Linux
  • Solution to Linux cannot use userdel to delete users and groups
  • Linux user and group commands summary and detailed introduction
  • Some examples of linux search filtering and user and group management commands
  • Guide to user and group configuration management in Linux operating system
  • Implementation of effective user groups and initial user groups in Linux
  • Summary of Linux user groups and permissions
  • Summary of 4 ways to add users to groups in Linux
  • Detailed explanation of adding/deleting users and user groups in Linux
  • How to view all users and user groups in Linux (modify user groups)
  • Linux user and group command example analysis [switching, adding users, permission control, etc.]

<<:  Detailed explanation of the use of Vue Smooth DnD, a draggable component of Vue

>>:  MySQL 5.6.37 (zip) download installation configuration graphic tutorial

Recommend

How CSS affects the white screen time during initial loading

Rendering pipeline with external css files In the...

What is ZFS? Reasons to use ZFS and its features

History of ZFS The Z File System (ZFS) was develo...

Some common mistakes with MySQL null

According to null-values, the value of null in My...

Summary of related functions for Mysql query JSON results

The JSON format field is a new attribute added in...

MySQL group query optimization method

MySQL handles GROUP BY and DISTINCT queries simil...

How to enable slow query log in MySQL

1.1 Introduction By enabling the slow query log, ...

Complete step record of Vue encapsulation of general table components

Table of contents Preface Why do we need to encap...

CSS implements the bottom tapbar function

Now many mobile phones have the function of switc...

How to create LVM for XFS file system in Ubuntu

Preface lvm (Logical Volume Manager) logical volu...

How to use vue3 to build a material library

Table of contents Why do we need a material libra...

Native JS to implement hover drop-down menu

JS implements a hover drop-down menu. This is a s...

JavaScript object-oriented class inheritance case explanation

1. Object-oriented class inheritance In the above...

Solution to Linux QT Kit missing and Version empty problem

Currently encountering such a problem My situatio...