Solved: passwd: Libuser error at line: 425 – Error removing stale lock `/etc/passwd.lock’: Permission denied.

Today in this post we will look how to solve an error message that i recently faced root password was expired on one of the server.

It comes when we try to set root password expiry to “never expire”.

Lets see the error and its solution.

I. Error Scenario: Try to set root password to never expire on server

### Password reset works fine on the server.
[root@ngelinux01~]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@ngelinux01~]#

### However getting error while trying to set password not to expire.
[root@ngelinux01~]# passwd -x -1 root
Adjusting aging data for user root.
passwd: Libuser error at line: 425 - Error removing stale lock `/etc/passwd.lock': Permission denied.
passwd: Error

### Also tried chage command.
[root@ngelinux01~]# chage -M -1 root
chage: /etc/passwd.lock: Permission denied
chage: cannot lock /etc/passwd; try again later.

 

II.  Solution
a. First check the lock file if exists.

[root@ngelinux01~]# ls -l /etc/passwd.lock
-rw-------. 1 root root 6 Jun 10 19:06 /etc/passwd.lock

So the permissions are fine for the file, no attribute is set.

b. Verify the filesystem is not mounted with noexec/readonly option.

[root@ngelinux01~]# df -h /etc
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv 3.9G 934M 2.7G 26% /

[root@ngelinux01~]# cat /etc/fstab
# /etc/fstab
# Created by anaconda on Thu Jan 14 15:50:53 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rootvg-rootlv / ext4 defaults 1 1
UUID=6e0c70af-e811-492f-9c98-eea0d2d83ecc /boot ext4 defaults 1 2
UUID=85BB-0733 /boot/efi vfat defaults,uid=0,gid=0,umask=0077,shortname=winnt 0 0
/dev/mapper/rootvg-homelv /home ext4 defaults 1 2
/dev/mapper/rootvg-metronlv /home/metron ext4 defaults 1 2
/dev/mapper/rootvg-tmplv /tmp ext4 defaults 1 2
/dev/mapper/rootvg-usrlv /usr ext4 defaults 1 2
/dev/mapper/rootvg-SElv /usr/SE ext4 defaults 1 2
/dev/mapper/rootvg-twslv /usr/tws ext4 defaults 1 2
/dev/mapper/rootvg-stdlistlv /usr/tws/TWS/stdlist ext4 defaults 1 2
/dev/mapper/rootvg-varlv /var ext4 defaults 1 2
/dev/mapper/rootvg-varloglv /var/log ext4 defaults 1 2
/dev/mapper/rootvg-varauditlv /var/log/audit ext4 defaults 1 2
/dev/mapper/rootvg-swap01lv swap swap defaults 0 0
/dev/mapper/datavg-ngemaplv /ngemap ext4 defaults 1 2

 

c. Check out the process using the passwd file and which has locked it.

[root@ngelinux01~]# cat /etc/passwd.lock
25254
[root@ngelinux01~]# ps -ef | grep -i 25254
root 21563 20810 0 13:48 pts/1 00:00:00 grep --color=auto -i 25254

So there is no process using this file.
It means we can remove it and there is no impact.
In case any process exists, then we need to kill or let it complete before removing this file to avoid any file corruption.

d. Now remove this lock file.

[root@ngelinux01~]# rm /etc/passwd.lock
rm: remove regular file ‘/etc/passwd.lock’? y

 

e. Now set the root password to never expire.

[root@ngelinux01~]# passwd -x -1 root
[root@ngelinux01~]# 

And this time its ran without any error.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments