1. Add a user
First use the adduser
command to add an ordinary user. The command is 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.
Free video tutorial Recommended: linux video tutorial
2. Grant root permissions
Method 1: Modify the /etc/sudoers
file, find the following line, and change the previous Remove the comment (#)
## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL
and then modify the user so that it belongs to the root group (wheel). The command is as follows:
#usermod -g root tommy
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, add a line under root, as shown below:
## Allow root to run any commands anywhere root ALL=(ALL) ALL tommy ALL=(ALL) ALL
After the modification, you can now use tommy Log in with your account, and then use the command su -
to obtain root permissions to operate.
Related article tutorial sharing: linux tutorial
The above is the detailed content of How to add a user in linux and give the user root permissions. For more information, please follow other related articles on the PHP Chinese website!