Summary of how to add root permissions to users in Linux

Summary of how to add root permissions to users in Linux

1. Add a user . First, use the adduser command to add a common user. The command is as follows:

#adduser tommy
//Add a user named tommy
#passwd tommy //Change password
Changing password for user tommy.
New UNIX password: //Enter the new password here
Retype new UNIX password: //Enter the new password again
passwd: all authentication tokens updated successfully.

2. Grant root permissions

Method 1 : Modify the /etc/sudoers file, find the following line, and remove the comment (#) in front of it

## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL

Then modify the user to belong to the root group (wheel), the command is as follows:

#usermod -g root tommy

The modification is complete. You can now log in with the tommy account and use the command su - to obtain root privileges to perform operations.

Method 2 : Modify the /etc/sudoers file, find the following line, and add a line below root as shown below:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
tommy ALL=(ALL) ALL

The modification is complete. You can now log in with the tommy account and use the command su - to obtain root privileges to perform operations.

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

tommy:x:500:500:tommy:/home/tommy:/bin/bash

After modification, it is as follows

tommy:x:0:500:tommy:/home/tommy:/bin/bash

Save, and log in with the tommy account to directly obtain the permissions of the root account.

Friendly reminder: Although method three seems simple and convenient, it is generally not recommended. Method two is recommended.

How to add root permissions to a user in Linux

## Allow root to run any commands anywhere

root ALL=(ALL) ALL

tommy ALL=(ALL) ALL

After the modification is completed, you can now log in with the tommy account.

Then use the command su to obtain root privileges to perform operations.

The above are all the relevant knowledge points introduced this time. Thank you for your learning and support for 123WORDPRESS.COM.

You may also be interested in:
  • How to use sudo su to add root permissions to ordinary users in Linux

<<:  Mysql online recovery of undo table space actual combat record

>>:  Example of how to adapt the Vue project to the large screen

Recommend

Vue implements partial refresh of the page (router-view page refresh)

Using provide+inject combination in Vue First you...

MySQL 8.0.19 installation and configuration tutorial under Windows 10

I will be learning MySQL next semester. I didn...

Detailed explanation of the installation and use of Vue-Router

Table of contents Install Basic configuration of ...

How to use Nginx to solve front-end cross-domain problems

Preface When developing static pages, such as Vue...

CSS3 uses transform to create a moving 2D clock

Now that we have finished the transform course, l...

WeChat applet implements search box function

This article example shares the specific code for...

How to determine if the Linux system is installed on VMware

How to determine whether the current Linux system...

XHTML Web Page Tutorial

<br />This article is mainly to let beginner...

mysql 5.7.11 winx64.zip installation and configuration method graphic tutorial

Install and configure the MySql database system. ...

Some tips for using less in Vue projects

Table of contents Preface 1. Style penetration 1....

MySQL date and time addition and subtraction sample code

Table of contents 1.MySQL adds or subtracts a tim...

Detailed tutorial on VMware installation of Linux CentOS 7.7 system

How to install Linux CentOS 7.7 system in Vmware,...

Common commands for mysql authorization, startup, and service startup

1. Four startup methods: 1.mysqld Start mysql ser...