LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-06-2014, 07:03 AM   #1
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Rep: Reputation: Disabled
(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.
 
Old 02-06-2014, 07:10 AM   #2
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
Can you try ls -al?
You might see .swp
 
Old 02-06-2014, 07:20 AM   #3
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
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-
 
Old 02-06-2014, 07:29 AM   #4
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
What account you use to run useradd command?
Is it normal user account?
 
Old 02-07-2014, 12:47 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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
 
Old 02-07-2014, 01:21 AM   #6
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-07-2014, 01:23 AM   #7
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi Myathu, i login with a normal user and then take sudo of root privileges, with which i am giving these commands.
 
Old 02-07-2014, 01:53 AM   #8
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
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.
 
Old 02-07-2014, 05:20 AM   #9
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-07-2014, 05:30 AM   #10
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
In case, can you try chrism01 suggestion with lsattr command to see what is the output?
 
Old 02-07-2014, 07:20 AM   #11
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
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 ~]#
 
Old 02-07-2014, 07:34 AM   #12
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
(RHEL5) Not able to delete/add user : unable to lock group/password file

sorry.how abt mount output
 
Old 02-07-2014, 07:38 AM   #13
sakshi.garg23
LQ Newbie
 
Registered: Feb 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
[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)
 
Old 02-07-2014, 09:55 AM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,324

Rep: Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471
Quote:
Originally Posted by sakshi.garg23 View Post
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.
 
Old 02-07-2014, 10:02 AM   #15
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,324

Rep: Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471
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 View Post
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'....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to edit PAM DB of VSFTPD (..add user, delete user, change user password ) jsaravana87 Linux - Server 1 10-02-2012 09:49 AM
groupadd: unable to lock group file?! macagent Linux - Newbie 6 07-08-2007 06:31 PM
useradd: unable to lock password file shivadk Linux - Networking 1 12-13-2005 03:20 AM
userdel: unable to lock password file asc3ndant Linux - General 1 06-20-2003 02:07 PM
unable to lock password file beefyd Linux - Security 3 09-08-2002 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration