Several methods of creating users and assigning permissions under Linux

The KPI for the new year is to master the key points of performance testing. No, for learning, I entered a lightweight cloud server and shared it with my bro.

As a result, I haven’t adjusted Linux for a long time, and I forgot the command to set permissions 0.0, so hurry up to unify the culture, and change user permissions while learning~~

1. First, create a user and set a password:

sudo useradd -m bxh

Create a user named bxh

-m: Automatically create the user's login directory

sudo is a tool that allows system administrators to let ordinary users execute root commands (obtain permissions)

Here you will need to enter the password of the administrator (not the password you want to set for the new user!!!)

sudo passwd bxh

Enter the password for user bxh

2. The next step is to set user permissions , mainly to grant root permissions . The following are the two methods I learned:

sudo vi /etc/sudoers

(1) Modify the /etc/sudoers file, find the following line, and add a line under root, as follows:

## Allow root to run any commands anywhere

root ALL=(ALL) ALL

bxh ALL=(ALL) ALL

After the modification, you can now log in with the bxh account, and then use the command sudo – to obtain root privileges for operations.

(2) Modify the /etc/sudoers file, find the following line, and remove the previous comment (#)

## 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 bxh

After modification, you can now log in with the bxh account, and then use the command su – to obtain root authority for operations.

The above is my humble opinion. If you have any questions, please comment below~~Come on, family members, three grams of oil and three grams of oil~~Thank you here! ! !

Guess you like

Origin blog.csdn.net/xiaolu_z/article/details/128897537