{"id":78686,"date":"2026-05-30T23:43:21","date_gmt":"2026-05-30T23:43:21","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=78686"},"modified":"2026-05-30T23:43:21","modified_gmt":"2026-05-30T23:43:21","slug":"why-max-permissions-on-a-file-666-what-if-i-give-777","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=78686","title":{"rendered":"Why? Max permissions on a file: 666? what if I give 777?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When people say:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Max permissions on a file: 666<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">they usually mean <strong>default maximum permissions when a new regular file is created<\/strong>, not the maximum you can manually set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Default maximum for new files: <code>666<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a new <strong>regular file<\/strong>, Linux normally starts from:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>666 = rw-rw-rw-\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That means:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>owner  = read + write\ngroup  = read + write\nothers = read + write\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">No execute permission by default.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why? Because most new files are <strong>text files, data files, documents, config files<\/strong>, etc. They should not automatically be executable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>touch file1.txt\nls -l file1.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You may see something like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-rw-r--r-- 1 user user file1.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The actual permission is affected by the <strong>umask<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. Default maximum for directories: <code>777<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a new <strong>directory<\/strong>, Linux normally starts from:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>777 = rwxrwxrwx\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Why? Because directories need <code>x<\/code> permission to be entered or searched.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir dir1\nls -ld dir1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You may see:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>drwxr-xr-x 2 user user dir1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Again, the final permission is affected by the <strong>umask<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. What if I give a file <code>777<\/code>?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can manually give a file <code>777<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 777 file1.txt\nls -l file1.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-rwxrwxrwx 1 user user file1.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This means:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>owner  = read + write + execute\ngroup  = read + write + execute\nothers = read + write + execute\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So <strong>everyone can read, modify, and execute the file<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. Is <code>777<\/code> allowed?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, it is allowed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But it is usually <strong>not safe<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a regular file, <code>777<\/code> means any user can change the file and possibly run it as a program or script.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, this is risky:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 777 script.sh\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">because any user may be able to modify the script and then execute it.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. Better permissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a normal text\/config\/data file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 644 file.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Meaning:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>owner can read\/write\ngroup can read\nothers can read\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a private file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 600 file.txt\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a script that only the owner should run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 700 script.sh\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a script others can read and execute but not modify:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 755 script.sh\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Simple summary<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>666 = normal maximum default for new files\n777 = normal maximum default for new directories\n777 on a file is possible, but usually unsafe\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Slide-friendly version:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Linux does not give execute permission to new regular files by default. New files start from a maximum of <code>666<\/code>, while directories start from <code>777<\/code> because directories need execute permission to be entered. A file can be changed to <code>777<\/code> manually, but this gives everyone read, write, and execute access, which is usually insecure.<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">REF: AI Tools\/ChatGPT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: That means: No execute permission by default. Why? Because most &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=78686\">Continue reading<\/a><\/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":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1976],"tags":[],"class_list":["post-78686","post","type-post","status-publish","format-standard","hentry","category-anything-linux","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":78680,"url":"http:\/\/bangla.sitestree.com\/?p=78680","url_meta":{"origin":78686,"position":0},"title":"Linux: Regular Permissions (symbolic\/numeric) vs ACL","author":"Sayed","date":"May 30, 2026","format":false,"excerpt":"Linux has two main permission layers: 1. Traditional permissions: user \/ group \/ others (UGO) 2. ACL permissions: extra permission rules for specific users\/groups 1. Traditional UGO permissions UGO means: u = user owner g = group owner o = others Example: chmod ugo+x script.sh means: Give execute permission to\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":78678,"url":"http:\/\/bangla.sitestree.com\/?p=78678","url_meta":{"origin":78686,"position":1},"title":"Linux: ACL vs Selinux","author":"Sayed","date":"May 30, 2026","format":false,"excerpt":"ACL vs SELinux ACL and SELinux both control access, but they work at different levels. FeatureACLSELinuxFull nameAccess Control ListSecurity-Enhanced LinuxMain purposeGive extra file permissions to specific users\/groupsEnforce system-wide security policyAccess modelDAC: Discretionary Access ControlMAC: Mandatory Access ControlControlled byFile owner\/rootSELinux policy\/rootWorks onFiles\/directoriesFiles, processes, ports, services, usersCommon commandsgetfacl, setfaclgetenforce, ls -Z, semanage,\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":78684,"url":"http:\/\/bangla.sitestree.com\/?p=78684","url_meta":{"origin":78686,"position":2},"title":"Define and describe Selinux in general terms","author":"Sayed","date":"May 30, 2026","format":false,"excerpt":"SELinux stands for Security-Enhanced Linux. It is a Linux security system that adds an extra layer of protection to the operating system. It controls what users, programs, services, and processes are allowed to do. A simple definition: SELinux is a security feature in Linux that enforces strict rules about which\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":78682,"url":"http:\/\/bangla.sitestree.com\/?p=78682","url_meta":{"origin":78686,"position":3},"title":"Linux: setfacl remove a user completely","author":"Sayed","date":"May 30, 2026","format":false,"excerpt":"To remove a specific user completely from ACL permissions, use setfacl -x. Remove a user ACL from a file setfacl -x u:username filename Example: setfacl -x u:john report.txt Check: getfacl report.txt Remove a user ACL from a directory setfacl -x u:username directoryname Example: setfacl -x u:john projectdir If the directory\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":78688,"url":"http:\/\/bangla.sitestree.com\/?p=78688","url_meta":{"origin":78686,"position":4},"title":"Special Permissions: SUID, SGID, sticky bit","author":"Sayed","date":"May 31, 2026","format":false,"excerpt":"Linux Special Permissions: SUID, SGID, and Sticky Bit Linux normally uses three permission groups: u = user\/owner g = group o = others And three basic permissions: r = read w = write x = execute Example: ls -l file.txt Output: -rwxr-xr-- But Linux also has special permissions: SUID =\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":14036,"url":"http:\/\/bangla.sitestree.com\/?p=14036","url_meta":{"origin":78686,"position":5},"title":"Users and Groups management in Linux (Redhat\/CentOS\/Fedora)","author":"Sayed","date":"December 25, 2017","format":false,"excerpt":"Users and Groups management in Linux (Redhat\/CentOS\/Fedora) Target Audience: Technical people who knew or already know (to some extent) - just wanna review Yes, from my history 622 echo \"dec 25th, 2017 - sayed\" \u00a0 User and password related files 623 cat \/etc\/passwd 624 cat \/etc\/shadow 625 cat \/etc\/group 626\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78686","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=78686"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78686\/revisions"}],"predecessor-version":[{"id":78687,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78686\/revisions\/78687"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78686"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}