Create User Group | Add User To The Group As Secondary Group | Remove The Interactive Login Shell

Now first I add the three user john, alex, and ajay using passwd Linux UNIX command I set the password to the specified user. I create group as system then I add the first two user john and alex to group system as a secondary group using –G option with usermod linux and unix command. Finally I remove interactive shell for ajay using –s option in usermod command Using useradd command add the three user john alex and ajay. Passwd command is used to set password.Last one create /common/system directory group ownership permission is system. . File created /common/system automatically have group ownership permission set to the system group
Add the user and group
[root@rhel5 ~]# useradd john
[root@rhel5 ~]# passwd john
Changing password for user john.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@rhel5 ~]# useradd alex
[root@rhel5 ~]# passwd alex
Changing password for user alex.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@rhel5 ~]# useradd ajay
[root@rhel5 ~]# passwd ajay
Changing password for user ajay.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
Then I create new group as sytem
[root@rhel5 ~]# groupadd system
Then I add john and alex belongs to the system group as a secondary group
Add User To The Group System As Secondary Group using usermod -G
[root@rhel5 ~]# usermod -G system john
[root@rhel5 ~]# usermod -G system alex
Remove the interative shell for the user ajay. Using usermod –s option.
[root@rhel5 ~]# usermod -s /sbin/nologin ajay
[root@rhel5 ~]# su - ajay
This account is currently not available.
Create the folder system using mkdir –p command
Change group ownership permission to the system using chgrp command
[root@rhel5 ~]# mkdir -p /common/system
[root@rhel5 ~]# chgrp system /common/system/
When file create automatically have group ownership set the system group
[root@rhel5 ~]# chmod g+s /common/system
[root@rhel5 ~]# su - alex
[alex@rhel5 ~]$ cd /common/system
[alex@rhel5 folder]$ touch file
[alex@rhel5 folder]$ ll
total 4
-rw-rw-r-- 1 alex system 0 Oct 13 09:20 file
Adding the User to the Particular Group with Group id
groupadd -g GUID Groupname
Example
#groupadd -g 550 Linux
-g For Groupid for new Group
18)Adding the user to the particular group
useradd -u UID -g GID username
#useradd -u 1001 -g 550 Red hat
Here Redhat user add to the group 550

Related post