Linux User & Group Administration

In Linux, User and Group administration is manged by some special files. User related information is always stored in ‘/etc/passwd’ and ‘/etc/shadow’ and Group related information is stored in ‘/etc/group’.

Now lets see what command can be used for the administration of User and Group.

To add a new user

[root@localhost ~]# useradd

To set password for the user

[root@localhost ~]# passwd

Note: By default every user account is locked, when it is created.

To set blank password for user

[root@localhost ~]# passwd -d

To delete user

[root@localhost ~]# userdel -r

Note: If you dont use ‘-r’ option with this command, user entries from ‘/etc/passwd’ and ‘/etc/shadow’ will be removed, but their home directories will be remain exist.

To add a new group

[root@localhost ~]#groupadd

To delete the group

[root@localhost ~]#groupdel

To add user into the group

[root@localhost ~]# usermod -G

To change group of a directory

[root@localhost ~]# chgrp

To change owner of a directory

[root@localhost ~]# chown

Now lets study the files where all the users and groups related information is stored.

1] /etc/passwd

test1 : User name
x : User’s password
501 : User ID [UID]
501 : Group ID [GID]
/home/test1 :User’s home directory
/bin/bash : User shell
2] /etc/shadow

test1 : User name
$1$bwUFnTjD$TUo6GstVovs/Z4iL71c5z0:15063:0:99999:7::: User’s encrypted password

3] /etc/group

test1: User name
x: User’s password
501: Group ID[GID]

These are the command and configuration files that every system administrator should know, in order to properly administrate and manage users and groups.

You can leave a response, or trackback from your own site.

Leave a Reply