Overview of adding sudo permission groups to ubuntu users

Source: Internet
Author: User

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}'


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.