Question on bash shell
HI All,
I am trying to learn shell scripting from a book and all I am doing is following few instruction from the book. Now this is what I am doing. I am trying to add a user using the useradd command so I run the following at command prompt root@S8500C_9>useradd ajit. The first time when I add this user I was successful.Later I deleted this suer using the userdel -r ajit command.Now when again I am trying to add this user it gives me following error. useradd: group ajit exists - if you want to add this user to that group, use -g. Now when I try using the -g option with the useradd command it gives we all the set off options avaiable to use along with the useradd command but doesnt create the ajit use Can anyone tell me how can I create the same user after deleting it. Thanks, Ajit |
Remove the group named ajit.
eg: Code:
groupdel ajit Code:
useradd -g ajit ajit |
Quote:
|
Quote:
Code:
useradd -g ajit otheruser |
Quote:
usermod -a -G group1,group2,group3,etc username The -a flag (append) tells it to keep the existing groups and add the new ones |
The only reason I don't typically suggest people use usermod is because its default behavior is destructive. If a new user has setup say 20 people in a specific group and forgets the -a it will replace the group with just the user(s) being added. It's not really an issue if you have good backups (although a bit annoying with tape backups), but the most common problem I see in any operating system is a lack of backups.
|
All times are GMT -5. The time now is 12:26 AM. |