How to add a user in linux and grant root permissions

藏色散人
Release: 2020-09-19 11:10:43
Original
28790 people have browsed it

How to add a user in linux and grant root permissions

How to add a user and grant root permissions in Linux?

How to add a user under Linux and grant root permissions:

1. To add a user, first use the adduser command to add an ordinary user, the command As follows:

#adduser tommy
//添加一个名为tommy的用户
#passwd tommy   //修改密码
Changing password for user tommy.
New UNIX password:     //在这里输入新密码
Retype new UNIX password:  //再次输入新密码
passwd: all authentication tokens updated successfully.
Copy after login

2. Grant root permissions

Method 1:Modify the /etc/sudoers file, find the following line, and change Remove the previous comment (#)

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

and then modify the user so that it belongs to the root group (wheel). The command is as follows:

#usermod -g root tommy
Copy after login

After the modification, you can now log in with the tommy account, and then use the command su – , you can obtain root permissions to operate.

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

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

After the modification, you can now use tommy Log in with your account, and then use the command sudo - to obtain root permissions to operate.

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

tommy:x:0:33:tommy:/data/webroot:/bin/bash
Copy after login

The above is the detailed content of How to add a user in linux and grant root permissions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!