Overview of adding sudo permission groups to ubuntu users
groupadd -g 1005 dev
Add a user group and set the gid to 1005.
groupdel dev
Delete user group dev
Add User
adduser mike
The system will automatically prompt you to enter the password.
useradd simael -u 600 -g 1005 -s /bin/bash
-U specifies uid (system retains 0-499)-g specifies user group-s specifies shell used
Then
passwd simael
Set password for user
Delete a user
userdel mike
If you are prompted that you have logged in and logged out of the user through skill
skill -KILL -u mike
Cancel mike user
View all users and user groups:
cat /etc/passwdcat /etc/group
Add permissions for users to use the sudo command
Add the write permission for the sudo file. The command is:
chmod u+w /etc/sudoers
Edit sudoers file
vi /etc/sudoers
Find this line of root ALL = (ALL) ALL, add xxx ALL = (ALL) ALL under it (here xxx is your user name)
Ps: You can add any of the following four lines to sudoers:
youuser ALL=(ALL) ALL%youuser ALL=(ALL) ALLyouuser ALL=(ALL) NOPASSWD: ALL%youuser ALL=(ALL) NOPASSWD: ALL
Line 1: allow the user youuser to execute the sudo command (password required ).
Line 2: Allow users in the user group youuser to execute the sudo command (password required ).
Row 3: allows the user youuser to execute the sudo command without entering the password during execution.
Row 4: Allow users in the user group youuser to execute the sudo command without entering the password during execution.
4. revoke the sudoers file write permission by running the following command:
chmod u-w /etc/sudoers
In this way, general users can use sudo.
--------------------------------------------------------------------------------
Id-u: displays the uid of the current user
Id-g displays the current user's gid
You can also view which group the user belongs:
View the content in/etc/passwd. The first item in each line is groupID, and the fifth item is Usr ID Info, which is similar to the group name. You can use vim, grep, and other methods to quickly find the row of a specified user. Familiar with awk, you can also write a script.
grep mike /etc/passwd|awk -F: '{ print $5}'