Commands for Group Management(Part-01)

 


Commands for Group Management

*** To add a group  name  'danger':

            groupadd   danger


           We can see that group from  /etc/group file as we know all group's info are kept in this file.

            grep   danger   /etc/group

            We can see, our command has been executed successfully  by " echo $? "  command


                                                        



Another example for better understanding.Suppose a group "noc" was created previously.If again we want to create "noc" group, then an error will be shown.  



Each user and group has a unique numerical identification number called a userid (UID) and a groupid (GID) respectively.

Now, we have to know about Group ID. We know that there are 2 types of groups

(1) System Group                                =  Minimum  GID = 201  &  Maximum GID = 999

(2) Regular/Standard Group

     [Primary & Secondary Group]     =  Minimum  GID = 1000  &  Maximum GID =60000


So, when we create a group, it's ID will start from 1000. Right? After GID 1000, all are regular/standard group.

  


ID of   'danger' group is 1703. So it is not a system group. It is a standard group. This ID is generated automatically when we use only 'groupadd' command without any option.

We can create a group with specific ID. As like, we want to crate a group named 'engineer' whose GID will be 2000. We can create it by -g option. Here g means group ID.

groupadd   -g    2000    engineer


If we want to create a another group  name designer with a same ID 2000, we will use -o

If you do not use -o option, you will get an error where system will say that- ID 2000 already is exist.


Now, if we want to change the name of 'designer' group to 'database' group, we will use -n option.

groupmod   -n   new_groupname    previous_groupname

groupmod  -n  designer  database

Here, we are seeing  our previous designer group has been changed to database group name. No designer group name are exist.

Now, we want to change the GID of database group, we will use -g option with groupmod cmdlet.

groupmod  -g   3000  database

Here, we are seeing GID has been changed to 3000 of database group.

Now, we have 3 users account - mamun, saad, imran. We have created these accounts by 'useradd' command  


Now, we will create a group named - 'network-team'  by 'groupadd' command

Now, we will take mamun user account to 'network-team'  group  by  gpasswd  command  and -a option 

gpasswd  -a  mamun  network-team


Now, if we want to add multiple user accounts into network-team, we will use -M option

gpasswd  -M  saad,imran   network-team 


But see carefully - previous  user "mamun" are not exist.

So, if you want to add these 3 users into "network-team"  group

Now, we are seeing all 3 users are in "network-team" group

If we want to remove a user named mamun from our "network-team" we will use -d option

gpasswd  -d  mamun  network-team


Here- mamun is not present in "network-team"

***********************************************************************************

Please go to Second Part of it:

Link of 2nd Part:

https://itbd-training.blogspot.com/2020/11/blog-post.html




























Comments

Post a Comment

Popular posts from this blog

Some Questions for MTCNA Exam

ডিপ্লোমা লেভেল এর ইন্ডাস্ট্রিয়াল এটাচমেন্ট এ আসার পূর্বে একটু ভেবে আসার অনুরোধ রইলো