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

Can CSS be used like this? The art of whimsical gradients

In the previous article - The charm of one line o...

How to update Ubuntu 20.04 LTS on Windows 10

April 23, 2020, Today, Ubuntu 20.04 on Windows al...

HTML unordered list bullet points using images CSS writing

Create an HTML page with an unordered list of at l...

SSH port forwarding to achieve intranet penetration

The machines in our LAN can access the external n...

Example code for implementing a pure CSS pop-up menu using transform

Preface When making a top menu, you will be requi...

Do you know the difference between empty value and null value in mysql

Preface Recently I found that my friend's met...

How to use union all in MySQL to get the union sort

Sometimes in a project, due to some irreversible ...

Detailed explanation of flex and position compatibility mining notes

Today I had some free time to write a website for...

MySQL exposes Riddle vulnerability that can cause username and password leakage

The Riddle vulnerability targeting MySQL versions...

Detailed explanation of several ways to create objects and object methods in js

This article is the second article about objects ...

Detailed explanation of filters and directives in Vue

Table of contents vue custom directive Global Dir...

Super detailed tutorial to implement Vue bottom navigation bar TabBar

Table of contents Project Introduction: Project D...