Manging Command

The easiest way to add a new user is to use the useradd command like this: useradd bart. We have now created a new user called bart. All basic requirements are met at this point. We would probably want to assign a password for that user and this is done with the command passwd bart.

 

An example for add new group: We have only a PC in the Springfield town. We want to create an account for the Simpsons. I will add a new group like this: groupadd simpsons Now, we'll have the Simpsons group in our /etc/group file. We want to add here the users Homer, Marge, Bart, Lisa, Maggie. We do this using the command: useradd -c "The head of the Simpson family" -G simpsons Homer. We’ve just created the Homer username, we’ve added a comment for it and we assigned it in the Simpsons group. Now, we should set a password for Homer. We do this with the passwd Homer command. We should do this for all the members in the Simpson family and then we'll be good to go.

If we made a mistake and want to modify something for a user, we use the command usermod similar to how we use useradd. The difference is that useradd adds users and, if a user already exists, we get an error message. If we want to delete a user we have the command userdel. This allows us to delete a username if it isn't logged on. Similarly, we have: groupmod and groupdel for working with groups.