jQuery in Action, 2nd edition*
The moose likes Linux / UNIX and the fly likes user not getting added on a group Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "user not getting added on a group" Watch "user not getting added on a group" New topic
Author

user not getting added on a group

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
I am trying to add user on a group, ksusers.

$ useradd -G ksusers shahzama.pathan

Outout Im getting is
ksh: useradd: not found

Then I tried

$ useradd -g ksusers shahzama.pathan

outout is the same
ksh: useradd: not found.

Why am I not able to add user shahzama.pathan to ksusers group ? What shall I do now ?

thanks
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Darn, I wrote all the following without actually noticing the real error. I'll leave it here as an FYI, but I suspect it is all irrelevant to you.
Andrew wrote:Does the ksusers group exist? A simple check would be - if you type: grep ksusers /etc/group does it show up?

Does the user already exist? A similar check would be typing grep shahzama.pathan /etc/passwd and see if it shows up. If it does then you are using the wrong command - to add an existing user to a group you would need to use usermod.

What is your desired result when running this command - should shahzama.pathan belong to the group ksusers and only to group ksusers (in which case you use the -g option); or should they belong to all the default groups plus ksusers (in which case you should use the -G option). I would recommend sticking with only one or the other for the moment.

What is the error code when you run the command? Type the following: useradd -G ksusers shahzama.pathan; echo $? then look at what the error code is in the man pages for useradd. Does that make things any clearer?


So, as to your real problem. The error message you are seeing is "ksh: useradd: not found". At a rough guess, I would suggest that the Korn Shell (ksh) is telling you that the application (useradd) was not found. In which case the problem has nothing to do with anything I wrote above, but instead it is to do with who the computer believes you are and/or what your path is set to.

Second problem first: useradd is probably in /sbin or /usr/sbin, neither of which is usually on the path of the average user. The logic is that executables that everyone should be able to use are likely to be stored in /bin or /usr/bin (or /opt/local/bin, but we wont get into that). System executables - those that you really don't want the average user to play with are stored in /sbin or /usr/sbin to ensure that they are in a common place but out of the way of the average user. For more information, take a look at the linfo page describing this.

To get around your initial problem, try typing /usr/sbin/useradd -G ksusers shahzama.pathan and see what happens. Unless you are logged in as root (which you really should not do), I suspect you will get a brand new error - you will probably be told you don't have permissions to add users.

The next step would be to see if you have sudo privileges to add users. Try typing sudo /usr/sbin/useradd -G ksusers shahzama.pathan and see if that works.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

If your command prompt character is really "$", then you've probably got a more serious problem.

Adding users is an administrator function. That means that either you should be operating as root - which would normally prompt with "#" - or you should be using the sudo program to gain temporary root privileges.

The "useradd" program bot being found is probably a side-effect of that. As a privileged program, it's not something that you'd have in the nonprivileged user's command path.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: user not getting added on a group
 
Similar Threads
how to assign password for a user in shell script
making an executable shell script
Adding users (command line)
Brio Report ReportMartException
J2EE/J2SE JDBC