Solved

Adding and Deleting Users

Posted on 2006-06-09
3
1,144 Views
Last Modified: 2012-06-27
There was an existing user called 'newuser' on the system. I wanted to remove the user and add it again so I ran the userdel command. When I went to add the user again I got the message displayed below.

# userdel newuser
UX: userdel: ERROR: newuser does not exist.
# useradd newuser
UX: useradd: ERROR: newuser is already in use.  Choose another.

How can I delete this user?

Please help.
0
Comment
Question by:wilg0005
3 Comments
 
LVL 6

Expert Comment

by:bira
ID: 16872612
   useradd only adds a user definition to the local system.  If
     a  network  nameservice such as NIS or NIS+ is being used to
     supplement  the  local  /etc/passwd  file  with   additional
     entries,  useradd  cannot change information supplied by the
     network  nameservice.   However  useradd  will  verify   the
     uniqueness of the user name and user id and the existence of
     any group names specified against the external nameservice.
0
 
LVL 62

Expert Comment

by:gheist
ID: 16875733
"uname -a" please.
0
 
LVL 6

Accepted Solution

by:
JJSmith earned 500 total points
ID: 16880865
As indicated by the first message from userdel:

UX: userdel: ERROR: newuser does not exist.

This almost certainly means that the user details do not exist locally on the machine from where you issued the userdel command. The fact that the useradd command identified the user exists indicates that the passwd file may be NIS'ed.

Just to confirm after you run the userdel and get the error, try;

echo $?

if it returns the value 6 then you are probably using NIS and need to take a different approach to adding and deleting users .e.g from the NIS server.

What confuses the issue is that userdel will be looking in local config files, when attempting to remove a user and may not find 'newuser'. Similarly useradd has a need to establish password data for a new user and would probably use calls to get(es)pwnam to see if the details already exist - these calls could reference NIS maps (passwd.byname,passwd.byuid), depending on /etc/nsswitch.conf and therefore the 'newuser' might be found 'non-locally' !!

Sorry is it's a little confusing but in summary the combination of userdel and useradd error messages that you are recieving, given that you execute both commands in the same environment, seem to indicate that NIS is part of the game - or even LDAP maybe.

You really need to establish how your user 'database' is held before attempting to delete and add users. It's possible to double up with a 'local' and 'NIS' user for the same user if you're not careful.

TRY:

$ ypwhich    
OR
$ ypwhich -m

If they fail then you may not have NIS up and working or your sessions access point may be on a non bound client.

If they do work then try:

1. $ grep newuser /etc/passwd

2. ypcat passwd | grep newuser

If they both return the same you are in the right place to delete users. Seek further advice from his forum on 'How to delete/add users under NIS'

Cheers
JJ



 

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question