1. Add a user. First, use the adduser command to add a common user. The command is as follows:
# Adduser keaising // Add a user named keaising
# Passwd ljl // change the password
Changing password for user keaising.
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 (#). The final result is:
# Allows people in group wheel to run all commands
% Wheel all = (all) All
Then modify the user and make it belong to the root group (wheel). The command is as follows:
# Usermod-g root keaising
After the modification is completed, you can log on with the keaising account and run the Su-command to obtain the root permission.
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
Keaising all = (all) All
After modification, you can log on with the keaising account and then use the commandSu-To obtain the root permission for the operation.
Add:
To avoid entering a password every time you use some commands, You need to modify the above configuration, such:
Keaising all = (all) nopasswd: All
At the same time, because normal users do not configure a path like xxx/sbin, you also need to add the environment variable in the. bash_profile file:
Path = $ path: $ home/bin:/usr/Kerberos/sbin:/usr/local/sbin:/usr/sbin
Method 3:Modify the/etc/passwd file, find the following line, and change the user ID to 0, as shown below:
Keaising: X: 500: 500: keaising:/home/keaising:/bin/bash
After modification
Keaising: X: 0: 500: keaising:/home/keaising:/bin/bash
Save. After logging on with the keaising account, you can directly obtain the permissions of the root account.