Enter Useradd create a new user
[Email protected] ~]# useradd zhengqi[[email protected]passwd Zhengqi
passwd is the command to modify the user password, here will be prompted to enter the password two times, the password is invisible.
Then modify the user belongs to the group, Wheel group is an administrator group, joined the wheel group, is equivalent to the user has been given administrator rights.
sudo usermod-g wheel Yaoqi
However, this setting requires a password for each use of the root permission, and you can modify the/etc/sudoers configuration file to set the root permission operation without entering the password.
Go to the root user, modify the/etc/sudoers profile, and first check the root permissions on this file:
[Email protected] ~]$ ll/etc/sudoers14187:/etc/ Sudoers
The root user only has Read permission on the file and needs to write to the root user.
chmod +w /etc/sudoers[[email protected]-devenv ~]# ll/etc/sudoers1 4188 Jul 7 /etc/sudoers
Executing chmod +w/etc/sudoers is the right to add write to the/etc/sudoers file for the current user. Then use VIM to modify the file.
vim/etc/ in Group wheel to run all commands%wheel all=(All) %wheel all= ( All) Nopasswd:all
The # #Same thing without a password the next line of comments removed, you can set the root permission to do not enter the password when the operation (the note is very clear).
After the operation is complete, remember to recover root permissions.
chmod -w /etc/sudoers[[email protected]-devenv ~]# ll/etc/sudoers1 4187 - :/etc/sudoers
The new user is then logged in, although the Administrator user group is added, and sudo is required before the command to perform root operations.
For example: After logging into a newly created user, try vim/etc/sudoers to see nothing, sudo vim/etc/sudoers to see the contents of the profile.
Linux new user and assign Administrator privileges