Solved

Adding and Deleting Users

Posted on 2006-06-09
3
1,116 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 61

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now