CentOS grants sudo permissions to common users
System Environment: centos 7.0
Citation: an account is assigned to everyone on the lab server, but sometimes common users need to use root permissions, such as installing some software. The following describes how to grant sudo Command Permissions to common users.
Prerequisites: sudo installation is complete.
Before configuration, you want to use the sudo command for normal users to temporarily grant root permissions and create a folder. Obviously, it fails because the user has no root permission.
The solution is as follows:
1. Open the sudoers fileSwitch to the root user,cd root
, Runvisudo
Command,visudo
The command is used to edit and modify/etc/sudoers
Configuration File
[root@master ~]# visudo
Open the sudoers file, as shown in.
2. Modify the suduers FileLocate the line marked with the red line, as shown in.
root ALL=(ALL) ALL
Add the sudo permission to liudiwei under the "root ALL = (ALL) ALL" line, and then add a row:
liudiwei ALL=(ALL) ALL
Here, xulei is your current user name, that is, the user name of a common user.:wq
Save and exit!
3. Check whether the test is successful.Switch to normal user
su liudiweicd ~sudo mkdir test
Congratulations! Pass the verification code! : Run The sudo commandmkdir test
The test is created as the root user.
Supplement: if you do not want to verify the password when using sudo in the future, you can do the following in the sudoers file:timestamp_timeout=-1
You only need to verify the password once and the system will automatically remember it later,runasp
The root password is required. If the root password is not added, the password of the Common Account is entered by default.