Add users to sudoers in CentOS
Environment: VMware12, CentOS7
Background: After Entering terminal, the default value is normal. Previously, you can use the Ubutu series to directly increase user permissions. However, in CentOS, the following message is displayed: the user is not in the sudoers file, therefore, you must add the user to the sudoers file.
Operation:
1. First enter root
Command: su root
2. You can then directly modify the permissions of the/etc/sudoers file.
Command: chmod 777/etc/sudoers
Ls-l/etc/sudoers
3. Use vim to edit the/etc/sudoers file.
Command: vim/etc/sudoers
4. Find the line of "root ALL = (ALL) ALL" in the file and add a line below: [your username/username] ALL = (ALL) ALL
Note: 1. It seems that it cannot be edited at the beginning. Press a to enter the editing status.
2. Here I use spaces to separate fields. The editing is to use the tab key.
3. Press esc to exit the editing status after editing.
5. Enter the wq command to save and exit.
Note: 1. There is a colon
2. If the exit fails, enter wq! Command to force exit
6. Restore the access permission of/etc/sudoers
Command: chmod 440/etc/sudoers
7. switch back to normal user
Command: su [user name/username]