Add a sudo user under CentOS
I. sodo usage 1.1 about how sudo Sudo is a linux system in which non-root users can escalate their permissions to execute some special commands, it allows common users to temporarily obtain the root permission without knowing the superuser password.
Generally, when you execute a special command, you only need to add sudo to a Special Command (such as yum) and enter your user password. in the next five minutes, when you use a special command again, you do not need to enter the user password again.
At the same time, sudo provides powerful log management, which records in detail what each user has done.
Sudo user management is stored in files:/etc/sudoers. That is to say, if you want to add a user to The sudo user group, you need to configure the file by yourself. When reading and writing this file, you need the root permission.
2.1 Add a user to sudo if "xxx is not in thesudoers file" appears when using sudo. this incident will be reported "indicates that the current user name: xxx has no permission to use sudo. In This case, we need to modify/etc/sudoers to add sudo permissions to the current user xxx.
- Run the "su-" command to enter the super user, and enter the etc directory "cd/etc"
- Add write permission to the sudoers file: Use the command "chmod u + w sudoers"
- Run the "vim sudoers" command, press "I" to enter the editing mode, find "rootALL = (ALL) ALL", and add "xxxALL = (ALL) ALL "(here xxx is your user name), click" Esc "to exit the editing, enter" wq "(write quit), and then exit sudoers.
- Enter "chmod u-v sudoers" To unwrite the file.
- Switch back to your username through "su xxx", and then use the sudo command.