Home >Operation and Maintenance >CentOS >What should I do if the ROOT permissions are insufficient when creating a new user under CentOS 7?

What should I do if the ROOT permissions are insufficient when creating a new user under CentOS 7?

coldplay.xixi
coldplay.xixiOriginal
2020-07-29 10:04:145399browse

The solution to the problem of insufficient ROOT permissions when creating a new user under CentOS 7: first modify the [/etc/sudoers] file and use tom to log in; then use the s[udo su -] or [sudo] command and enter tom Password; finally use exit to exit the root user mode.

What should I do if the ROOT permissions are insufficient when creating a new user under CentOS 7?

Solution to the problem of insufficient ROOT permissions when creating a new user under CentOS 7:

Step 1: Add user

Command:

#adduser tom    <!--此处以用户tom为例-->

Step 2: Change password

Command:

#passwd tom

Enter according to the prompts Enter the password twice to complete the password setting.

Step 3: Set user permissions

Method 1: Modify the /etc/sudoers file (recommended method)

Command:

    #visudo    <!--找到下面一行,并在其后新增一行,如下所示:-->
    ## Allow root to run any commands anywhere
    root    ALL=(ALL)     ALL
    tom    ALL=(ALL)     ALL    <!--新增行-->

Save and exit, use tom to log in, then use sudo su - or sudo command, enter tom's password, you can obtain root permissions to execute the command; use exit to exit the root user mode.

Method 2: Add the user to the root group

Command:

    #usermod -g root tom

Use su - to obtain root permissions; use exit to exit root user mode.

Method 3: Modify the /etc/passwd file, find the following line, change the user ID to 0

    tom:x:1000:1000::/home/tom:/bin/bash

Change to:

    tom:x:0:0::/home/tom:/bin/bash

Related tutorial recommendations: centos tutorial

The above is the detailed content of What should I do if the ROOT permissions are insufficient when creating a new user under CentOS 7?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn