<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>sudo Sergeant 12: Group Management</title><link>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3387/sudo-sergeant-12-group-management</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>sudo Sergeant 12: Group Management</title><link>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3387/sudo-sergeant-12-group-management</link><pubDate>Fri, 18 Jan 2019 16:09:44 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:bbf3be3d-48bc-4979-88e0-a31b7d3e7390</guid><dc:creator>tariq.ahmad</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3387/sudo-sergeant-12-group-management#comments</comments><description>Current Revision posted to Documents by tariq.ahmad on 1/18/2019 4:09:44 PM&lt;br /&gt;
&lt;table cellpadding="0" cellspacing="0" style="padding:0px;margin:0px;background-color:#c4e3ed;width:100%;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td rowspan="3" style="vertical-align:bottom;"&gt;&lt;a href="/e14/assets/legacy/2017/FelixExcLeft1.png"&gt;&lt;img alt="image" class="nolightbox" src="/e14/assets/legacy/2017/FelixExcLeft1.png"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td rowspan="3" style="vertical-align:top;padding:8px 13px 13px 8px;"&gt;&lt;p style="margin:0;font-size:18px;font-weight:bold;padding-bottom:6px;"&gt;&lt;a class="jivecontainerTT-hover-container jive-link-community-small" href="/challengesprojects/element14-presents/benheck/"&gt;element14&amp;#39;s The Ben Heck Show&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding-bottom:6px;line-height:18px;"&gt;&lt;strong&gt;Join the Ben Heck team every week for amazing hacks!&lt;/strong&gt; Watch them build and mod community-inspired projects using electronics!&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="/challengesprojects/element14-presents/benheck/"&gt;Back to The Ben Heck Show homepage &lt;img loading="lazy" alt="image" src="/e14/assets/legacy/gen/LinkArrow.gif"  /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#004156;vertical-align:middle;" width="30%"&gt;&lt;a class="" href="https://www.element14.com/community/community/experts/benheck/sudosergeant?ICID=SS-episodedoc-topban"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;sudo Sergeant&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#005973;vertical-align:middle;"&gt;&lt;a class="" href="https://www.element14.com/community/community/experts/benheck/thelearningcircuit?ICID=SS-episodedoc-topban"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;The Learning Circuit&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#006f91;vertical-align:middle;"&gt;&lt;a class="jive-link-wiki-small" href="/challenges-projects/element14-presents/benheck/ben-heck-exclusive/w/documents/9678/the-ben-heck-show-episode-archive"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;See All Episodes&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="width:80%;display:block;margin:0 auto;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="padding-bottom:12px;"&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=7J6ehxi1pqc"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p style="margin:0;border:1px solid #b8d7e5;background-color:#e9f6fc;padding:8px;max-width:634px;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:justify;"&gt;In this segment Felix shows you how to see what groups are on your system, how to add new groups, how to add users to those groups, how to remove users from those groups, how to remove the groups, and, how to modify the groups.&amp;nbsp; He’ll also dabble in file permissions and file ownership. &lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;Felix talks about managing groups.&amp;nbsp; He starts by checking out what groups are in the system.&amp;nbsp;&amp;nbsp; To check out what groups are in the system use:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ cat /etc/group&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;To create a group you would use:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ sudo groupadd dirshare&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;You’ve now created a group named dirshare that has no members.&amp;nbsp; Now that the group is created, there are a couple of ways you can add members to the group.&amp;nbsp; You can do it through the USERMOD method or through the GPASSWD method.&amp;nbsp; Felix, shows you how to do both, starting with the GPASSWD method:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ sudo gpasswd –a – technician dirshare&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;This adds user technician to the group dirshare. If you type in:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ cat/etc/group&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;It should show you that technician is now part of this group:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;dirshare:x:1006:technician&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;Next, Felix shows you how to add user buckethead to the group through the usermod method.&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ sudo usermod -aG dirshare buckethead&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;If you type in&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ cat/etc/group&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;It shows you that buckethead is now part of the group:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;dirshare: x:1006:technician, buckethead&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;The distinction between the primary group that an account is associated with, and additional groups that an account may have, is that whenever a person goes and creates a document, it’s going to be owned by the person that made the file and the file is going to be associated with the primary group of the account that made the file. Felix goes over an example using a test directory.&amp;nbsp; He uses this to create another directory called share:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ pwd /home/technician/test&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ mkdir share&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;If you type in&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ /bin/ls –la&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;You can see that this directory is owned by technician and it’s in the group technician.&amp;nbsp; Felix attempts to change the group of the shared directory to technician:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ chown&amp;nbsp; -R technician:dirshare ../share/&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;It gives him the error: Operation not permitted This brings him to his next point. When a user is added to a new group, the system doesn’t recognize that the user has been added to that group until the person has logged out and then logged back in. He logs back in and goes into the directory share.&amp;nbsp; He wants to make a file that can be shared between different accounts within a directory that is in a shared group:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ ls file.txt $ pwd /home/technician/share&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;To do this he is going to use a utility called EXA that he’s set up in his bash RC as an alias for LK.&amp;nbsp; EXA is a modern replacement for LS, which is listing the contents of a directory.&amp;nbsp; It basically colorizes everything, puts it in a grid, and makes it human readable.&amp;nbsp; He wants to change the group from technician to dirshare.&amp;nbsp; He’ll need to first check the permissions to make sure that both the owner can read and write and the group can read and write.&amp;nbsp; To do this he’ll need to use two utilities, CHOWN and CHMOD.&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;"&gt;$ chown -Rv technician:dirshare ../share/&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;changed ownership of ‘../share/file.txt’ from technician to technician:dirshare changed ownership of ‘..share/’ from technician to technician:dirshare&lt;/p&gt;&lt;p style="margin:0;margin-bottom:15px;color:#000000;font-family:&amp;#39;Open Sans&amp;#39;, Arial, sans-serif;text-align:left;"&gt;Now, any account that is in the dirshare can write files in this directory.&amp;nbsp; Any account that is in dirshare can also read file.txt but cannot write to it because the write flag is not set.&amp;nbsp;&amp;nbsp; To make this file writeable you would use: $ chmod g+w file.txt Now that the permissions are set and the group is set, Felix opens up another terminal and logs in as Buckethead.&amp;nbsp; He goes over what you need to do to allow Buckethead to write a file to the directory. Because buckethead is in the potatohead group, technician is unable to write to it.&amp;nbsp; To allow technician to write to the file he’ll need to change the group.&amp;nbsp; He goes over this along with what you need to do to remove a user from a group.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: operation not permitted, ls, exa, chown, chmod, shared group, felix gardner, system administration, open source, group permissions, sudosergeant, linux&lt;/div&gt;
</description></item></channel></rss>