cancel
Showing results for 
Search instead for 
Did you mean: 

useradd problem

khilari
Regular Advisor

useradd problem

hi guys i am trying to add a user by using:
useradd –u uid –m –c usercomment -s /usr/bin/sh username

it takes the argument but when i su to the user or try looking for it in the /etc/passwd file its not there.....
what do u guys think
7 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: useradd problem

Hi:

I assume that you are root. This works:

# useradd -u 9999 -m -c "New User" -s /usr/bin/sh someuser

If you echo the return value ($?) this should help discover the problem. The retrun codes are documented in the manpages for 'useradd'.

Regards!

...JRF...
Tingli
Esteemed Contributor

Re: useradd problem

I wonder, that there is no -g for user group and -d for user home directory although you have -m which requires to create a home directory.
UVK
Trusted Contributor

Re: useradd problem

Do this and see if you have NIS configured

#ypwhich

Are you working as root on the machine ?

-uvk
-------------------------------------------
Like it or worked !! Click kudos !!
khilari
Regular Advisor

Re: useradd problem

when i do a echo $? i get 126 but when i use the same command on other server i get a 0 when i do echo $? i am using
useradd -u 5199 -m -d /home/sm29 -c "sam matt" -s /usr/bin/ksh sm29

what do u guys think,, how should this be erectified
Tingli
Esteemed Contributor

Re: useradd problem

What is running on it, nis or ldap?
Taifur
Respected Contributor

Re: useradd problem

Viktor Balogh
Honored Contributor

Re: useradd problem

Try to login with that user. If it works though you don't have any related line in /etc/passwd then you must be using LDAP or NIS for authentication. What is the output of:

# grep ^passwd /etc/nsswitch.conf

if there is an entry like 'nis', you can retrieve the passwd line for that user like this:

# ypcat passwd | grep user

Anyway, I suggest to use the pwget command to retrieve the pw-line for a specific user, it queries the local passwd, the NIS database and also LDAP:

# pwget -n username
****
Unix operates with beer.