Add sudo user

Source: Internet
Author: User

Method 1: Add a sudo user

When you install Ubuntu, it automatically adds the first user to The sudo group, allowing this user to obtain the root identity by entering his/her own account password. However, the system will not automatically add other users to The sudo group. If you want to grant some super user privileges to someone on your shared system, you must grant them sudo rights.

To add a new user to sudo, the simplest way is to use the usermod command. Run
$ Sudo usermod-G admin Username
This is what you want to do. However, if the user is already a member of another group, you need to add the-A option, as shown in the following figure:
$ Sudo usermod-a-g admin Username

If you prefer the graphic interface to operate these operations, use "system-> Management-> users and groups ". Select the user you want to add to the sudo group and click "properties". In the user permission area, select the "Execute system management tasks" option.


Method 2:
Add the user to the sudo group without entering the password

Sometimes we only need to execute a command with the root permission to Su to the root, isn't it inconvenient? In this case, we can use sudo instead.
The Default User Created by fedora is not in The sudo group. You need to edit the/etc/sudoers file to add the user. The file can only use the mongodo command. First, you need to switch to the root
Su-(Note that there is-, which is different from Su. When the "Su" command is used, the system only switches to root, but does not pass the root environment variable, or the currently used environment variable. Use the "Su-" command to bring the environment variable together, just like root login)
Then
Mongodo
This is the same as VI usage. As some people may be unfamiliar with VI, let's take a brief look at the steps.
Move the cursor to the last line, press a, and enter the append mode.
Your_user_name all = (all)
Press ESC, enter W to save the file, and then exit Q.
In this way, you can add yourself to the sudo group and use the sudo command.
If you find it troublesome to enter the password during sudo, replace the entered password with the following content:
Your_user_name all = (all) nopasswd: All
As for security issues, I think this is also acceptable for individual users.

If, for some reason, the following error occurs when trying to use sudo, sudo:/etc/sudoers is mode 0777, shocould be 0440. This is because the read and write permissions of the sudoers configuration file are incorrect. The following is a solution from a foreign website.

Jasongroome

When I try to use the sudo command in terminal I get the following error message:

Sudo:/etc/sudoers is mode 0777, shocould be 0440

Any help with this wocould be greatly appreciated.

Gowrann

The privileges of this file are incorrect they shocould be owner = read group = read and everyone = nothing, this translates to 440 at the moment you have 777 which gives owner/Group & everyone
Read/write and execute privileges.

To change the privileges log in as root;

[Localhost:/users/neilgowr] root # cd/etc
[Localhost:/etc] root # chmod 440 sudoers
[Localhost:/etc] root # ls-l sudoers
-R -- r ----- 1 root wheel 315 Sep 3 2001 sudoers

This will fix it for you.

Jasongroome

Thanks a lot, it worked a treat.


Note: You must log in with the root user to change the password of the root user. If you do not know the root user, you can change the password of the root user through the user with the sudo permission. The command is sudo passwd root, you will be prompted to enter the current user password and the new root user password twice. After the password is changed, you can switch to the root user through the Su-root command to execute all the above operations.

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.