Linux prohibits ordinary users from changing passwords, and prohibits ordinary users from changing root passwords with Sudo

1.vi /etc/sudoers #Edit the sudoers file with root authority, and add the content liuqingfeng at the end as a normal user

liuqingfeng ALL=/usr/sbin/,/sbin/,/usr/bin/*,!/bin/chattr,!/bin/passwd,!/usr/sbin/visudo,!/usr/sbin/useradd,!/ usr/sbin/userdel

2. Add the i attribute to all files or folders that start with sudo (do not change the file or directory arbitrarily):

chattr +i /etc/sudo.conf

chattr +i /etc/sudoers

chattr +i /etc/sudoers.d/

chattr +i /etc/sudo-ldap.conf

insert image description here
#Unlock file restore operation!

chattr -i /etc/sudo.conf

chattr -i /etc/sudoers

chattr -i /etc/sudoers.d/

chattr -i /etc/sudo-ldap.conf

Guess you like

Origin blog.csdn.net/wangyuhong2267/article/details/125241886