{"id":79077,"date":"2026-11-17T01:54:28","date_gmt":"2026-11-17T01:54:28","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79077"},"modified":"2026-11-17T01:54:28","modified_gmt":"2026-11-17T01:54:28","slug":"linux-intermediate-01-accounts","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79077","title":{"rendered":"Linux Intermediate 01 \u2014 Users, Groups, sudo, and Special Permissions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1991\">Linux Intermediate category<\/a> \u00b7 Lesson 1 of 9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inspect identity records, understand sudo, and build a group-inheriting directory in a disposable VM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">UIDs and GIDs identify users and groups. Primary and supplementary groups can both matter. Query through getent instead of assuming every account lives in \/etc\/passwd. Never display or copy \/etc\/shadow into a report. Use sudo for a scoped task instead of working in a root shell. Administrative group policy differs by distribution, commonly sudo on Ubuntu and wheel on Red Hat-family systems. Verify the real sudo policy with sudo -l.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SUID on eligible executables can change the effective UID. Inspect it read-only on system programs. SGID on a directory makes new entries inherit the directory&#8217;s group. The sticky bit limits who can delete or rename entries in a shared writable directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inspect the current identity and special bits without changing privileges<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>id\ngetent passwd &quot;$(id -un)&quot; | cut -d: -f1,3,4,6,7\nstat -c '%a %A %n' \/tmp\nstat -c '%a %A %n' &quot;$(command -v passwd)&quot;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uid=1000(learner) gid=1000(learner) groups=1000(learner),27(sudo)\nlearner:1000:1000:\/home\/learner:\/bin\/bash\n1777 drwxrwxrwt \/tmp\n4755 -rwsr-xr-x \/usr\/bin\/passwd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This illustrates common layouts. Do not change \/tmp or the passwd binary. Lowercase s or t means the corresponding execute bit is also set.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Verify SGID group inheritance on a directory you own<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lab=$(mktemp -d)\nmkdir &quot;$lab\/shared&quot;\nchgrp &quot;$(id -gn)&quot; &quot;$lab\/shared&quot;\nchmod 2770 &quot;$lab\/shared&quot;\ntouch &quot;$lab\/shared\/report.txt&quot;\nstat -c '%a %A %G %n' &quot;$lab\/shared&quot; &quot;$lab\/shared\/report.txt&quot;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2770 drwxrws--- learner \/tmp\/tmp.ABC\/shared\n644 -rw-r--r-- learner \/tmp\/tmp.ABC\/shared\/report.txt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Actual paths, modes, and groups vary. SGID controls group inheritance, not guaranteed group write access. A directory inside this private temporary parent is not reachable by other users. Use an explicit ACL or a suitable group-owned parent in a shared lab.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>What does getent do that reading a single local file might not?<\/li>\n\n\n<li>Does SGID on a directory make every new file writable by the group?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Why is -a important if a lab admin runs usermod -aG project labuser?<\/li>\n\n\n<li>What special bit often appears on \/tmp, and what does it restrict?<\/li>\n\n\n<li>How would you verify the identity and policies of a newly authorized lab admin without exposing password data?<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>What does getent do that reading a single local file might not?<\/strong><br><strong>Answer<\/strong> \u2014 It consults the configured name service, which may include nonlocal account records.<\/li>\n\n\n<li><strong>Does SGID on a directory make every new file writable by the group?<\/strong><br><strong>Answer<\/strong> \u2014 No. Group ownership inheritance and file write permission are separate.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Why is -a important if a lab admin runs usermod -aG project labuser?<\/strong><br><strong>Answer<\/strong> \u2014 It appends to supplementary groups rather than replacing the existing list. Existing sessions may need a fresh login.<\/li>\n\n\n<li><strong>What special bit often appears on \/tmp, and what does it restrict?<\/strong><br><strong>Answer<\/strong> \u2014 The sticky bit limits deletion or renaming to authorized cases such as the entry owner, directory owner, or a privileged process.<\/li>\n\n\n<li><strong>How would you verify the identity and policies of a newly authorized lab admin without exposing password data?<\/strong><br><strong>Answer<\/strong> \u2014 Start a fresh session as the lab user. Use id and sudo -l to confirm groups and authorized commands.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=14036\">Users and Groups management in Linux (Redhat\/CentOS\/Fedora)<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78457\">Create an administrative user in Ubuntu 24<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78688\">Special Permissions: SUID, SGID, sticky bit<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78691\">Q &amp; A:  Linux: Switch Users, Boot Process, File System<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson 02 \u2014 Access Control Lists and Shared Directories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1991\">Linux Intermediate category<\/a> \u00b7 Lesson 1 of 9<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspect identity records, understand sudo, and build a group-inheriting directory in a disposable VM.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1991],"tags":[],"class_list":["post-79077","post","type-post","status-publish","format-standard","hentry","category-linux-intermediate","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79077,"position":0},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79089,"url":"http:\/\/bangla.sitestree.com\/?p=79089","url_meta":{"origin":79077,"position":1},"title":"Linux Advanced 04 \u2014 Firewall Zones and Runtime Rules","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Identify the active zone and compare a timed runtime firewall rule with permanent policy.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79087,"url":"http:\/\/bangla.sitestree.com\/?p=79087","url_meta":{"origin":79077,"position":2},"title":"Linux Advanced 02 \u2014 NFS and On-Demand Mounting with AutoFS","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Create an indirect AutoFS map and distinguish a running automounter from a successful NFS mount.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79095,"url":"http:\/\/bangla.sitestree.com\/?p=79095","url_meta":{"origin":79077,"position":3},"title":"Linux Advanced 2 01 \u2014 Hardening a systemd Service","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Run a small systemd service with a dedicated dynamic identity and a narrow writable directory.","rel":"","context":"In &quot;Linux Advanced 2&quot;","block_context":{"text":"Linux Advanced 2","link":"http:\/\/bangla.sitestree.com\/?cat=1993"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79086,"url":"http:\/\/bangla.sitestree.com\/?p=79086","url_meta":{"origin":79077,"position":4},"title":"Linux Advanced 01 \u2014 LVM and Controlled Filesystem Growth","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Create and expand an isolated LVM stack without touching the system disk.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79093,"url":"http:\/\/bangla.sitestree.com\/?p=79093","url_meta":{"origin":79077,"position":5},"title":"Linux Advanced 08 \u2014 Apache Virtual Hosts and HTTPS","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Test Apache name-based routing locally and verify HTTPS with certificate and renewal checks.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79077"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79077\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79077"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}