{"id":79074,"date":"2026-11-17T01:52:50","date_gmt":"2026-11-17T01:52:50","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79074"},"modified":"2026-11-17T01:52:50","modified_gmt":"2026-11-17T01:52:50","slug":"linux-basics-06-permissions","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79074","title":{"rendered":"Linux Basics 06 \u2014 File Permissions and umask"},"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=1990\">Linux Basics category<\/a> \u00b7 Lesson 6 of 8<\/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\">Read a permission string, predict umask results, and choose a minimal permission change.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Permissions are grouped into owner, group, and others. Read, write, and execute are 4, 2, and 1. A directory&#8217;s execute bit is search or traversal permission. Deleting a name normally depends on the parent directory&#8217;s permissions rather than the file&#8217;s write bit. A sticky directory can further restrict deletion.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The site&#8217;s 666 versus 777 example refers to the creation modes a program typically requests for regular files and directories. It is not a hard limit. umask clears requested bits. A parent default ACL can change creation-mode behavior, so use an ordinary lab filesystem for this drill.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reproduce the umask example with fixed settings<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lab=$(mktemp -d)\ncd &quot;$lab&quot; || exit\n( umask 022; touch file1.txt; mkdir dir1 )\nstat -c '%a %A %n' file1.txt dir1\nchmod g+w,o-r file1.txt\nstat -c '%a %A %n' file1.txt\nchmod 640 file1.txt\nstat -c '%a %A %n' file1.txt<\/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>644 -rw-r--r-- file1.txt\n755 drwxr-xr-x dir1\n660 -rw-rw---- file1.txt\n640 -rw-r----- file1.txt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The subshell confines the changed umask. Numeric mode sets all three ordinary groups. A symbolic change can touch only the selected bits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Apply a private creation mask<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>( umask 077; touch private.txt; mkdir private-dir )\nstat -c '%a %n' private.txt private-dir<\/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>600 private.txt\n700 private-dir<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a shareable directory, choose group and traversal access deliberately rather than making it writable by everyone.<\/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>Why do ordinary new text files not execute by default?<\/li>\n\n\n<li>What does chmod g+w change?<\/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>Predict the default regular-file and directory modes for umask 027.<\/li>\n\n\n<li>Give the owner read\/write and the group read access, with no access for others.<\/li>\n\n\n<li>Why might a directory with read but no execute permission list names but not let you open a named file?<\/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>Why do ordinary new text files not execute by default?<\/strong><br><strong>Answer<\/strong> \u2014 The creating program normally requests 0666 rather than 0777.<\/li>\n\n\n<li><strong>What does chmod g+w change?<\/strong><br><strong>Answer<\/strong> \u2014 It adds write permission to the file\u2019s group class without changing other bits.<\/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>Predict the default regular-file and directory modes for umask 027.<\/strong><br><strong>Answer<\/strong> \u2014 The usual results are 640 and 750 when there is no default ACL.<\/li>\n\n\n<li><strong>Give the owner read\/write and the group read access, with no access for others.<\/strong><br><strong>Answer<\/strong> \u2014 chmod 640 file1.txt.<\/li>\n\n\n<li><strong>Why might a directory with read but no execute permission list names but not let you open a named file?<\/strong><br><strong>Answer<\/strong> \u2014 Reading lists names. Search permission is needed to traverse the directory and look up the named entry.<\/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=9585\">\u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8\u0983 \u09ab\u09be\u0987\u09b2 \u09aa\u09be\u09b0\u09ae\u09bf\u09b6\u09a8 \u0993 \u098f\u0995\u09cd\u09b8\u09c7\u09b8 \u09ae\u09cb\u09a1 (Unix \u2013 File Permission \/ Access Modes)<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78686\">Why? Max permissions on a file: 666? what if I give 777?<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78680\">Linux: Regular Permissions (symbolic\/numeric) vs ACL<\/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\">Previous lesson 05 \u2014 Finding Files and Filtering Text. Next lesson 07 \u2014 Processes, Jobs, and Signals.<\/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=1990\">Linux Basics category<\/a> \u00b7 Lesson 6 of 8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Read a permission string, predict umask results, and choose a minimal permission change.<\/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":[1990],"tags":[],"class_list":["post-79074","post","type-post","status-publish","format-standard","hentry","category-linux-basics","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79074,"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":78686,"url":"http:\/\/bangla.sitestree.com\/?p=78686","url_meta":{"origin":79074,"position":1},"title":"Why? Max permissions on a file: 666? what if I give 777?","author":"Sayed","date":"May 30, 2026","format":false,"excerpt":"When people say: Max permissions on a file: 666 they usually mean default maximum permissions when a new regular file is created, not the maximum you can manually set. 1. Default maximum for new files: 666 For a new regular file, Linux normally starts from: 666 = rw-rw-rw- That means:\u2026","rel":"","context":"In &quot;Anything Linux&quot;","block_context":{"text":"Anything Linux","link":"http:\/\/bangla.sitestree.com\/?cat=1976"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79073,"url":"http:\/\/bangla.sitestree.com\/?p=79073","url_meta":{"origin":79074,"position":2},"title":"Linux Basics 05 \u2014 Finding Files and Filtering Text","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Choose find for names, grep for lines, cut for fields, and sed for transforming text.","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":79075,"url":"http:\/\/bangla.sitestree.com\/?p=79075","url_meta":{"origin":79074,"position":3},"title":"Linux Basics 07 \u2014 Processes, Jobs, and Signals","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Identify a process you own, inspect its state, and stop it gracefully.","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":79094,"url":"http:\/\/bangla.sitestree.com\/?p=79094","url_meta":{"origin":79074,"position":4},"title":"Linux Advanced 09 \u2014 MariaDB Service Accounts and Restore Verification","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Check a Linux-hosted MariaDB service, identify least-privilege database roles, and test a logical restore.","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":79069,"url":"http:\/\/bangla.sitestree.com\/?p=79069","url_meta":{"origin":79074,"position":5},"title":"Linux Basics 01 \u2014 Linux, the Shell, and Your First Lab","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Tell the kernel, distribution, terminal, and shell apart, then identify the system you are actually using.","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":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79074","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=79074"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79074\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79074"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}