https://script.spoken-tutorial.org/index.php?title=Linux-for-Sys-Ads/C2/Assigning-groups-on-user-creation/English-timed&feed=atom&action=historyLinux-for-Sys-Ads/C2/Assigning-groups-on-user-creation/English-timed - Revision history2024-03-28T17:58:31ZRevision history for this page on the wikiMediaWiki 1.23.17https://script.spoken-tutorial.org/index.php?title=Linux-for-Sys-Ads/C2/Assigning-groups-on-user-creation/English-timed&diff=56033&oldid=prevPoojaMoolya: Created page with "{| border=1 |- || '''Time''' || '''Narration''' |- || 00:01 || Hello and welcome to the spoken tutorial on '''Assigning Groups '''on''' User Creation '''in''' Linux.''' |- |..."2022-09-06T11:46:23Z<p>Created page with "{| border=1 |- || '''Time''' || '''Narration''' |- || 00:01 || Hello and welcome to the spoken tutorial on '''Assigning Groups '''on''' User Creation '''in''' Linux.''' |- |..."</p>
<p><b>New page</b></p><div>{| border=1<br />
|-<br />
|| '''Time'''<br />
|| '''Narration'''<br />
<br />
|-<br />
|| 00:01<br />
|| Hello and welcome to the spoken tutorial on '''Assigning Groups '''on''' User Creation '''in''' Linux.'''<br />
<br />
|-<br />
|| 00:08<br />
|| In this tutorial we will learn about<br />
<br />
Creating a''' user group''' '''/etc/group file'''<br />
<br />
|-<br />
|| 00:17<br />
||Assigning''' groups '''to '''users '''at the time of''' account creation'''<br />
<br />
|-<br />
|| 00:22<br />
||We will do this through some examples.<br />
|-<br />
|| 00:25<br />
|| To record this tutorial, I am using '''Ubuntu Linux 16.04 Operating System'''<br />
|-<br />
|| 00:32<br />
|| To practice this tutorial, <br />
<br />
you should have gone through '''Linux System Administration '''tutorials''' '''on this website.<br />
<br />
|-<br />
|| 00:40<br />
||you must have '''root access''' to your computer.<br />
<br />
|-<br />
|| 00:44<br />
|| What is a '''group '''in''' Linux'''?<br />
<br />
|-<br />
|| 00:47<br />
||We can understand '''group''' as a '''collection of users'''.<br />
<br />
|-<br />
|| 00:51<br />
||In a college system, a '''group '''can be '''different departments''' like '''CSE''', '''Electrical''' etc.<br />
<br />
|-<br />
|| 00:58<br />
||'''Groups''' can also be different clubs like '''music club''',''' sports club, literature club,''' etc.<br />
<br />
|-<br />
|| 01:06<br />
|| '''Linux''' supports two types of '''groups'''.<br />
<br />
'''Primary group '''and''' ''' '''Supplementary group '''<br />
<br />
|-<br />
|| 01:12<br />
|| Every '''user''' must belong to one and only one''' primary group'''.<br />
<br />
|-<br />
|| 01:17<br />
||This is the default''' group''' for the '''user''' when the '''user '''logs in. <br />
<br />
|-<br />
|| 01:22<br />
||For example: a student must belong to one and only one '''department'''.<br />
<br />
|-<br />
|| 01:28<br />
|| A '''user''' can be a member of more than one '''group'''. <br />
<br />
|-<br />
|| 01:32<br />
||Those '''groups '''are called '''supplementary groups'''.<br />
<br />
|-<br />
|| 01:36<br />
||These '''groups '''are assigned to the '''user''', to provide him additional '''access''' to resources.<br />
<br />
|-<br />
|| 01:43<br />
||More on '''access''' mechanism or '''permission''' will be discussed in subsequent tutorials. <br />
|-<br />
||01:50<br />
|| Let’s take an example. '''User radha '''belongs to the '''CSE department'''.<br />
<br />
|-<br />
|| 01:56<br />
||She is also a member of the '''music club '''and '''sports club'''.<br />
<br />
|-<br />
|| 02:01<br />
||In this scenario, '''CSE''' is the '''primary group '''for '''radha'''.<br />
<br />
|-<br />
|| 02:05<br />
||And she is a member of two '''supplementary groups '''- '''music club '''and '''sports club'''.<br />
<br />
|-<br />
|| 02:12<br />
||Let’s create this scenario in our system.<br />
|-<br />
|| 02:16<br />
|| First, we will create '''group CSE'''.<br />
<br />
|-<br />
|| 02:19<br />
||And we will use '''addgroup command '''in order to create this '''group'''.<br />
|-<br />
|| 02:24<br />
|| Open the '''Terminal '''by pressing '''Ctrl, Alt and T '''keys simultaneously on the keyboard.<br />
|-<br />
|| 02:32<br />
|| Now, we should login as '''superuser '''or '''root user'''.<br />
<br />
|-<br />
|| 02:37<br />
||To do so type: '''sudo space su '''and press '''Enter.'''<br />
|-<br />
|| 02:44<br />
|| Type the admin '''password '''and then press '''Enter'''.<br />
|-<br />
|| 02:48<br />
|| Notice, our '''login prompt '''has changed to''' '''a '''hash''' symbol.<br />
<br />
|-<br />
|| 02:53<br />
||This indicates that we are in the '''root user '''mode.<br />
|-<br />
|| 02:57<br />
|| Here onwards, please remember to press the '''Enter''' key after typing each '''command'''.<br />
|-<br />
|| 03:03<br />
|| Now type '''addgroup space cse'''<br />
|-<br />
|| 03:08<br />
|| This will create '''group cse'''.<br />
<br />
|-<br />
|| 03:12<br />
||'''Linux''' automatically allocates a '''Unique ID''' for each '''group''' that is created.<br />
<br />
|-<br />
|| 03:18<br />
||Here, '''GID, '''that is '''Group ID''' is '''1002'''.<br />
|-<br />
|| 03:22<br />
|| Alternatively, we can mention a '''GID '''of our choice.<br />
<br />
|-<br />
|| 03:28<br />
||For this, we need to use '''hyphen gid''' option along with the '''addgroup command'''.<br />
<br />
|-<br />
|| 03:35<br />
||'''GIDs''' in the range of''' 0 '''to''' 999''' are '''reserved''' for the '''system users'''.<br />
<br />
|-<br />
|| 03:42<br />
||So, always choose a number greater than or equal to '''1000''' as '''GID'''<br />
<br />
|-<br />
|| 03:49<br />
|| Let’s us create a '''group Music_club''' with the''' GID 1012.'''<br />
|-<br />
|| 03:55<br />
|| On the '''terminal '''type:<br />
<br />
'''addgroup space hyphen gid 1012 space Music underscore club '''<br />
<br />
|-<br />
|| 04:06<br />
||Here type '''M''' is in '''capital letter.'''<br />
|-<br />
|| 04:10<br />
|| Notice, it is showing some error.<br />
<br />
|-<br />
|| 04:13<br />
||Actually, we should have written '''m '''in '''lowercase '''letter'''.'''<br />
<br />
Let’s try that.<br />
|-<br />
|| 04:19<br />
|| Press the '''Up''' arrow key to get the previously executed command. <br />
|-<br />
|| 04:24<br />
|| Change '''capital M''' to '''m''' in '''lowercase''' letter.<br />
|-<br />
|| 04:30<br />
|| The '''command''' is working now.<br />
<br />
|-<br />
|| 04:32<br />
||So, always remember to use '''lowercase '''letters while writing '''group '''names. <br />
|-<br />
|| 04:38<br />
|| Similarly let’s create another '''group sports underscore club'''.<br />
<br />
|-<br />
|| 04:43<br />
||This time no need to mention the '''GID'''.<br />
|-<br />
|| 04:48<br />
|| Now we have three groups '''cse, music underscore club '''and''' sports underscore club'''.<br />
|-<br />
|| 04:55<br />
|| How can we check the details of the created '''group'''?<br />
<br />
Type '''cat space /etc/group'''<br />
|-<br />
|| 05:05<br />
|| There will be an entry in this file for every '''user''' on the '''system.'''<br />
|-<br />
|| 05:11<br />
|| Each line has four '''fields''' separated by a '''colon '''symbol.<br />
<br />
|-<br />
|| 05:16<br />
||The first '''field''' is the name of the '''group.'''<br />
<br />
|-<br />
|| 05:19<br />
||The second '''field''' is the '''encrypted password''' for the '''group'''.<br />
<br />
|-<br />
|| 05:24<br />
||Third '''field''' shows the '''GID '''as a number.<br />
|-<br />
|| 05:28<br />
|| Fourth '''field''' contains the list of '''users''' that belong to that '''group '''separated by '''commas'''.<br />
<br />
|-<br />
|| 05:35<br />
||This list contains all '''users''' who have this '''group''' as a '''secondary group.'''<br />
|-<br />
|| 05:41<br />
|| We can see the entries for '''cse, music underscore club''' and '''sports underscore club groups.'''<br />
<br />
|-<br />
|| 05:49<br />
||Notice, '''music underscore club''' has '''Gid 1012 '''which we mentioned during '''group '''creation.<br />
<br />
|-<br />
|| 05:57<br />
||Here, the fourth '''field '''is empty for all the '''groups'''.<br />
<br />
|-<br />
|| 06:02<br />
||This is because there are no members in these '''groups''', as of now.<br />
<br />
|-<br />
|| 06:07<br />
||The '''password field '''is '''x'''. <br />
<br />
|-<br />
|| 06:10<br />
||We will discuss about the '''password field '''and list of members '''field '''in detail, in a separate tutorial on '''groups'''.<br />
|-<br />
|| 06:18<br />
|| Now, how can we specify the '''primary '''and''' supplementary groups''' while creating the '''user'''?<br />
<br />
Let us see an example.<br />
|-<br />
|| 06:26<br />
|| To specify that '''user radha '''belongs to the '''primary group cse''', type:<br />
<br />
'''adduser space hyphen ingroup space cse space radha '''<br />
|-<br />
|| 06:40<br />
|| Type the '''password '''as '''pass underscore radha''' and press '''Enter.'''<br />
<br />
|-<br />
|| 06:46<br />
||Retype the same password and press '''Enter.'''<br />
<br />
|-<br />
|| 06:50<br />
||Type name as '''Radha''' with '''capital R'''.<br />
<br />
And proceed as we have done before.<br />
|-<br />
|| 06:59<br />
|| We have successfully created '''user radha''' with '''primary group cse'''.<br />
|-<br />
|| 07:05<br />
|| So, you should use '''ingroup option''' to specify''' primary group'''’s name while creating the '''user'''.<br />
|-<br />
|| 07:13<br />
|| As we know, '''radha''' is a member of '''music underscore club'''.<br />
<br />
|-<br />
|| 07:17<br />
||So '''music underscore club''' will be the '''supplementary group''' for the '''user radha.'''<br />
<br />
|-<br />
|| 07:23<br />
||Type '''adduser space radha space music underscore club'''<br />
|-<br />
|| 07:31<br />
|| Remember. <br />
<br />
To add '''supplementary groups''' using '''adduser command''', you should have an existing '''user'''.<br />
|-<br />
|| 07:38<br />
|| Here, we have first created the '''user radha.''' Then added '''radha''' to the '''supplementary group''' using '''adduser command.'''<br />
|-<br />
||07:46<br />
|| If you need to specify that '''radha''' is also a member of '''sports club '''type: <br />
<br />
'''adduser space radha space sports underscore club'''<br />
|-<br />
|| 07:59<br />
|| Let’s check '''user radha'''’s details using '''id command'''.<br />
<br />
|-<br />
|| 08:04<br />
||Type '''id space radha'''<br />
|-<br />
|| 08:08<br />
|| Notice, '''User radha''' is in group '''cse''' which has '''GID''' 1002<br />
<br />
|-<br />
|| 08:15<br />
||That is the''' primary group''' for '''radha'''.<br />
<br />
|-<br />
|| 08:19<br />
||Next, there is the list of '''groups''', where '''user radha '''is member of.<br />
<br />
|-<br />
|| 08:25<br />
||Along with '''primary group cse, radha''' is also a member of two '''supplementary groups music underscore club''' and '''sports underscore club.'''<br />
|-<br />
|| 08:35<br />
|| Now let’s check our '''/etc/group file''' for the entry of '''radha'''<br />
<br />
|-<br />
|| 08:42<br />
||Type: '''grep space radha space /etc/group'''<br />
|-<br />
|| 08:49<br />
|| Notice, you can see '''user radha''' is the member of '''groups music underscore club''' and '''sports underscore club'''<br />
<br />
|-<br />
|| 08:58<br />
||But not as a member of the '''primary group''' that is '''cse'''.<br />
<br />
|-<br />
|| 09:03<br />
||So the '''group file''' will list only the''' supplementary groups''' in which the '''user''' is associated.<br />
|-<br />
|| 09:10<br />
|| Check the '''/etc/passwd file''' for the details of the '''username radha.'''<br />
<br />
|-<br />
|| 09:17<br />
||Type '''grep space radha space /etc/passwd'''<br />
|-<br />
|| 09:25<br />
|| Notice, the fourth '''field''' is '''1002'''<br />
<br />
|-<br />
|| 09:29<br />
||It is the '''GID''' for the '''group cse'''.<br />
<br />
|-<br />
|| 09:33<br />
||It is the '''primary group''' for '''radha.'''<br />
|-<br />
|| 09:36<br />
|| So, remember '''/etc/passwd''' shows '''primary group ID '''for a '''user'''<br />
<br />
|-<br />
|| 09:43<br />
||'''/etc/group file''' shows list of '''usernames''' who have the''' group '''as a '''supplementary group'''<br />
<br />
|-<br />
|| 09:51<br />
|| Command '''id space username''' shows the details of both''' primary '''and''' supplementary groups'''<br />
|-<br />
|| 09:59<br />
|| You can also specify the '''group id''' instead of''' group'''’s name while creating the '''user'''.<br />
<br />
|-<br />
|| 10:05<br />
||Let us create a '''user suraj''' and assign him to the '''group cse''' using the '''gid'''.<br />
<br />
|-<br />
|| 10:12<br />
||We know''' group cse''' has '''GID 1002''' <br />
|-<br />
|| 10:17<br />
|| So type: '''adduser space hyphen gid space 1002 space suraj'''<br />
<br />
|-<br />
|| 10:26<br />
||You should use '''hyphen gid option''' to specify the '''group ID'''.<br />
<br />
|-<br />
|| 10:32<br />
||Use '''pass underscore suraj''' as the '''password'''<br />
<br />
|-<br />
|| 10:37<br />
||Retype the '''password'''<br />
<br />
Full Name as '''Suraj''' with '''S''' in capital letter.<br />
<br />
|-<br />
|| 10:45<br />
||Proceed as we have done for the previous '''users'''.<br />
|-<br />
|| 10:49<br />
|| We have successfully created '''user suraj '''with '''primary group cse.'''<br />
|-<br />
|| 10:55<br />
|| To exit from the '''root user access''', type '''exit'''<br />
|-<br />
|| 11:00<br />
|| This brings us to the end of this tutorial.<br />
<br />
Let us summarize.<br />
|-<br />
|| 11:05<br />
|| In this tutorial we learnt about-<br />
<br />
Creating''' primary group'''<br />
|-<br />
|| 11:10<br />
||Assigning '''user '''to the '''primary group'''<br />
<br />
|-<br />
|| 11:13<br />
||Assigning''' user '''to the '''supplementary group''' '''/etc/group file'''<br />
<br />
|-<br />
|| 11:19<br />
||Assigning''' groups '''to''' users '''at the time of''' account creation'''<br />
<br />
|-<br />
|| 11:24<br />
|| As an assignment- Create two '''groups: ''' '''cultural ''', '''literature'''<br />
<br />
|-<br />
||11:30<br />
||Now create a''' user ajay''' with '''Home directory''' as '''/home/ajay underscore dir '''<br />
<br />
|-<br />
|| 11:39<br />
||'''User id '''as''' 1090'''<br />
<br />
|-<br />
|| 11:42<br />
||'''Primary group '''as '''cultural'''<br />
<br />
|-<br />
|| 11:45<br />
||'''Supplementary group '''as '''literature'''<br />
<br />
|-<br />
|| 11:49<br />
||Add '''comments "Native: Mumbai"'''<br />
|-<br />
|| 11:52<br />
|| Use the '''command id''' to check the '''user '''details<br />
<br />
|-<br />
|| 11:56<br />
|| Check the details of '''user ajay '''in '''/etc/passwd '''and '''/etc/group files'''<br />
|- <br />
|| 12:05<br />
|| The video at the following link summarises the Spoken Tutorial project.<br />
<br />
Please download and watch it.<br />
|- <br />
|| 12:13<br />
|| The Spoken Tutorial Project team conducts workshops and gives certificates.<br />
<br />
For more details, please write to us.<br />
|-<br />
|| 12:23<br />
|| Please post your timed queries in this forum.<br />
|- <br />
||12:27<br />
|| Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.<br />
<br />
|- <br />
|| 12:33<br />
|| The script has been contributed by Antara and this is Praveen from IIT Bombay signing off.<br />
<br />
Thank you for joining.<br />
|-<br />
|}</div>PoojaMoolya