Home                                                                                                                    

* How to add groups in linux

Adding users and groups in linux is very easy. But you need to know what you want to do.

Example: We are creating 3 groups and then add users to particular groups.

system     marketing     network

joel         hardik         dbsolanki
krupesh    sushil          drpanchal

* Add the linux groups to the server.


You can add groups in linux with "groupadd" command

[root@joel root]# groupadd system

[root@joel root]# groupadd marketing

[root@joel root]# groupadd network

* Now add linux users to their particular groups as we made up.

[root@joel root]# useradd -g system joel

[root@joel root]# useradd -g system krupesh

[root@joel root]# useradd -g marketing hardik

[root@joel root]# useradd -g marketing sushil

[root@joel root]# useradd -g network dbsolanki

[root@joel root]# useradd -g network krupesh

Here we have specify -g option. This parameter is for assinging users to particular groups.
If you simple add users without -g option then Redhat will create a group with same username and same groupname.

* How to change passwords

You can change the password with "passwd" command.

[root@joel root]# passwd joel

Changing password for user joel.

New password:

Retype password:

passwd: all authentication tokens updated sucessfully.

* Force users to change their passwords

You can force users to change their passwords the next time they log in with the passwd command's "-f" qualifier. Here we are doing that for user "hardik"

[root@joel root]# passwd -f hardik

Changing password for user hardik.

New password:

Retype password:

passwd: all authentication tokens updated sucessfully.

[root@joel root]#

* Setting a password expiry date

Password lifetimes can be set by using the passwd command's "-x" flag followed by the lifetime of the password in days. Once again we make the password of user "hardik" expire in 90 days.

[root@joel root]# passwd -x 90 hardik

Adjusting aging data for user hardik.

passwd: Sucess

[root@joel root]#

* Disable / Enable user accounts.

The passwd command is used again to this. The "-l" flag locks the account and the "-u" flag unlocks it.

       Lock the Account

First lets lock the account of user "hardik"

[root@joel root]#  passwd -l hardik

Locking password for user hardik.

passwd: Sucess

[root@joel root]#

       Unlock the Account

[root@joel
root]# passwd -u hardik

Unlocking password for user hardik.

passwd: Success.

* Delete users from system.

The userdel command is used. The "-r" flag removes all the contents of users's home directory.

[root@joel root]# userdel -r hardik

* Check which users belong to which groups

Use the "groups" command with username as the argument.

[root@joel root]# groups hardik

hardik : marketing

[root@joel root]#

1