During the use of the Linux system, we usually use common users for routine operations, while the root user is only used for permission assignment and system settings, the password of the root user cannot be disclosed. When a common user executes a system program, he or she needs to temporarily escalate permissions. sudo is a common command. He or she only needs to enter the current user password to temporarily escalate permissions. When using the sudo command, we often encounter prompts that the current user is not in the sudoers file. What if this problem is solved? The following steps can be used to solve the problem easily.
1. Switch to the root user permission
Last login: Tue Sep 24 20:50:51 2013 from 192.168.30.171
[User @ Compile ~] $ Su root
Password:
[Root @ Compile user] #
2. View/etc/sudoers file permissions. If you have read-only permissions, change them to writable permissions.
[Root @ Compile user] # ls-l/etc/sudoers
-R -- r -----. 1 root 4030 September 25 00:57/etc/sudoers
[Root @ Compile user] # chmod 777/etc/sudoers
[Root @ Compile user] # ls-l/etc/sudoers
-Rwxrwxrwx. 1 root 4030 00:57/etc/sudoers
[Root @ Compile user] #
3. Execute the vi command, edit the/etc/sudoers file, and add the user who wants to escalate permissions. Find root in the file.
Root ALL = (ALL) ALL
User ALL = (ALL) ALL
Note: The format is (host in the User Name Network = (target user who executes the command) Command Execution range)
4. Save and exit, and restore the access permission of/etc/sudoers to 440.
[Root @ Compile user] # chmod 440/etc/sudoers
[Root @ Compile user] # ls-l/etc/sudoers
-R -- r -----. 1 root 4030 September 25 00:57/etc/sudoers
[Root @ Compile user] #
5. Switch to a common user to test the User Privilege Escalation function.