• Post Reply Bookmark Topic Watch Topic
  • New Topic

user not getting added on a group  RSS feed

jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12156
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Tim Holloway
Saloon Keeper
Posts: 18799
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!