Ubuntu Add sudo user

Source: Internet
Author: User

The first method: add sudo user

When you install Ubuntu, it automatically adds the first user to the Sudo group, allowing the user to type in their own account password to gain superuser (root) status. However, the system will no longer automatically add other users to the sudo group. If you want to grant someone some super user privileges on your shared system, you must give them sudo rights.

The simplest way to add a new user to sudo is to use the Usermod command. Run
$sudo usermod-g Admin Username
That's what you're going to do, however, if the user is already a member of another group, you need to add the-a option, like this
$sudo usermod-a-G admin username

If you prefer the graphical interface to manipulate these, use manage-as users and groups. Select the users you want to add to the sudo group, click "Properties", and in the area of user rights, select the "Perform System administration tasks" box.


The second method:
Add a user to the sudo group without entering a password

Sometimes we just need to execute a root command and Su to root, is it inconvenient? This can be replaced with sudo.
Fedora default new user is not in the Sudo group, need to edit the/etc/sudoers file to join the user, the file can only use the Visudo command, first need to switch to root
Su-(note there--this is different from Su, when using the command "SU" only switch to root, but not the root environment variable passed, or the current environment variable, with the "Su-" command to bring the environment variables with the past, as with the root login)
And then
Visudo
This is the same as VI usage, because people may be less familiar with VI, so briefly say the steps
Move the cursor to the last line, press A, enter append mode, type
Your_user_name all= (All)
Then press ESC, then enter: W Save the file, and then: Q exit
This will add yourself to the sudo group and you can use the sudo command.
If you feel that you entered the password in sudo trouble, just replace the input as follows:
Your_user_name all= (All) Nopasswd:all
As for the safety issue, I think this is also possible for the general individual user.

If, for some reason, the following error occurred while trying to use sudo, sudo:/etc/sudoers is mode 0777, should was 0440. This is due to a problem with the read and write permissions of the sudoers configuration file. Here are the workarounds found on the website from abroad.

Jasongroome

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

sudo:/etc/sudoers is mode 0777, should be 0440

Any and this would is greatly appreciated.

Gowrann

The privileges of this file is incorrect they should be owner=read group=read and everyone=nothing, this translates to 44 0 at the moment are 777 which gives Owner/group & everyone read/write and execute privileges.

The privileges log in as root;

[LOCALHOST:/USERS/NEILGOWR] root# cd/etc
[Localhost:/etc] root# chmod sudoers
[Localhost:/etc] root# ls-l sudoers
-r--r-----1 root Wheel 315 SEP 3 2001 Sudoers

This would fix it for you.

Jasongroome

Thanks a lot, it worked a treat.


Note: The above must be logged in with the root user can be modified, if you do not know that root can be changed through the current user with sudo permissions to change the root user password, the corresponding command: sudo passwd root, will prompt you to enter the current user password and two times the root user new password After modifying the password, you can switch to the root user to perform all of the above actions via the Su-root command.

Ubuntu Add sudo user

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.