LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   (RHEL5) Not able to delete/add user : unable to lock group/password file (https://www.linuxquestions.org/questions/linux-newbie-8/rhel5-not-able-to-delete-add-user-unable-to-lock-group-password-file-4175493924/)

sakshi.garg23 02-06-2014 06:03 AM

(RHEL5) Not able to delete/add user : unable to lock group/password file
 
Hi,

Can anyone please guide me in the following situation :

I am trying to delete a user and getting error : [B]userdel: unable to lock group file

and while trying to add user, getting error :
useradd: unable to lock password file

Below is the exact commands and output i am getting :
[root@hostname ~]#userdel -r <username>
userdel: unable to lock group file
[root@hostname ~]# useradd <username>
useradd: unable to lock password file


I googled for this, and found suggestions to remove /etc/passwd.lock, /etc/shadow.lock, /etc/gshadow.lock files, but i could not find any files by these names in my server.

However i found /etc/shadow- , /etc/passwd-, /etc/gshadow- files.

Please suggest.

myatthu 02-06-2014 06:10 AM

Can you try ls -al?
You might see .swp

sakshi.garg23 02-06-2014 06:20 AM

I tried but got the following :

ls -al /etc |grep passwd*
-rw-r--r-- 1 root root 1935 Sep 16 14:17 passwd
-rw-r--r-- 1 root root 1935 Sep 16 14:16 passwd-

myatthu 02-06-2014 06:29 AM

What account you use to run useradd command?
Is it normal user account?

chrism01 02-06-2014 11:47 PM

Possibly they've been set immutable; try
Code:

lsattr /etc/passwd

lsattr /etc/group

lsattr /etc/shadow

http://linux.die.net/man/1/lsattr
http://linux.die.net/man/1/chattr

sakshi.garg23 02-07-2014 12:21 AM

thanks chrism01, but I haven't actually got u, that how it can resolve my issue. I checked the links, and found that I can list and change the attributes of a file with these commands.

sakshi.garg23 02-07-2014 12:23 AM

Hi Myathu, i login with a normal user and then take sudo of root privileges, with which i am giving these commands.

myatthu 02-07-2014 12:53 AM

In case, looks like your sudo config had issue. Why don't you try with another user account? If you are root administrator, try with root account.
So that we can make sure password files itself no issue.
Later you need to review your sudoer config.

sakshi.garg23 02-07-2014 04:20 AM

I tried with root also. Below is the detailed commands and outputs.:


[user@hostname ~]$ su -
Password:
[user@hostname ~]# useradd -g admin bijayinee
useradd: unable to lock password file
[user@hostname ~]# userdel -r nishant
userdel: unable to lock password file


Earlier i logged in with a user who had sudo access, but this time i Logged in with user and did su and gave root password, but still the same result.

myatthu 02-07-2014 04:30 AM

In case, can you try chrism01 suggestion with lsattr command to see what is the output?

sakshi.garg23 02-07-2014 06:20 AM

Below is the output for Chris1's suugestion :


[user@hostname ~]$ su -
Password:
[root@hostname ~]# lsattr /etc/passwd
------------- /etc/passwd
[root@hostname ~]# lsattr /etc/group
------------- /etc/group
[root@hostname ~]# lsattr /etc/shadow
------------- /etc/shadow
[root@hostname ~]#

myatthu 02-07-2014 06:34 AM

(RHEL5) Not able to delete/add user : unable to lock group/password file
 
sorry.how abt mount output

sakshi.garg23 02-07-2014 06:38 AM

[user@hostname ~]$ mount
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda9 on /home type ext3 (rw)
/dev/sda7 on /opt type ext3 (rw)
/dev/sda6 on /var type ext3 (rw)
/dev/sda5 on /usr type ext3 (rw)
/dev/sda3 on /tmp type ext3 (rw)
/dev/sda2 on /orahome type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

TB0ne 02-07-2014 08:55 AM

Quote:

Originally Posted by sakshi.garg23 (Post 5113109)
thanks chrism01, but I haven't actually got u, that how it can resolve my issue. I checked the links, and found that I can list and change the attributes of a file with these commands.

...and we were asking for the output, so we knew what to tell you. And please spell out your words.

Look for ANY files in /etc with a .lock extension ("ls /etc/*.lock"). They *CAN* be passwd.lock...or pwck.lock...or pwd.lock. They can also be HIDDEN files, such as .passwd.lock, so be sure to look for those as well. And have you done a "ps -ef | grep passwd" on the system, to see if you have another user that has that command running in a terminal? If so, they may be 'locking' it manually.

TB0ne 02-07-2014 09:02 AM

Quote:

Originally Posted by myatthu
Can you try ls -al? You might see .swp

An "ls -al" in which directory? And you do realize that a .swp file (from VI being used...which it ISN'T with the useradd program), would be HIDDEN, right? So an "ls -al" wouldn't show a .swp file, and even if it did...that does NOT address the lock file symptom. So what's the point?
Quote:

Originally Posted by myatthu (Post 5113118)
In case, looks like your sudo config had issue. Why don't you try with another user account? If you are root administrator, try with root account. So that we can make sure password files itself no issue. Later you need to review your sudoer config.

What, exactly, did the OP post to make you think there is any problem with their sudo config? NOTHING they said indicated a problem, so telling them this is just confusing the issue.
Quote:

Originally Posted by myatthu
sorry.how abt mount output

Why would the output of the mount command be helpful here? If the system was mounted read-only, then NOTHING much would work at all...adding a user would be the least of the OP's problems.

These things should be very obvious to someone who has 'certifications'....


All times are GMT -5. The time now is 05:26 PM.