1) Login as root user

2) Run command:
# chattr +i /etc/shadow
Above command will write protect the /etc/shadow file.

3) Now lets test it with user Laurel. Login as laurel:
$passwd
Changing password for user laurel.
Changing password for laurel
(current) UNIX password: OLDPASSWED
New password: NEWPASSWD
Retype new password:NEWPASSWD
passwd: all authentication tokens updated successfully.

4) Now logout and try to login with new password. What you can’t? Yup use the old password you can login now.

5) Get the list of Linux second extended file system using the lsatter command (run as root user :-) )
# lsattr /etc/shadow
—-i——– /etc/shadow

Note:Even root user is not allowed to change password. Before doing this root need to remove the attribute using command:
#chattr –i /etc/shadow
# lsattr /etc/shadow
————- /etc/shadow

Related posts:

  1. Steps to mount remote windows partition under Linux
  2. How to mount ISO image under Linux?