{"id":14521,"date":"2011-03-09T11:45:31","date_gmt":"2011-03-09T09:45:31","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=14521"},"modified":"2011-03-09T11:45:31","modified_gmt":"2011-03-09T09:45:31","slug":"chmod-text-modes","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2011\/03\/09\/chmod-text-modes\/","title":{"rendered":"chmod text modes"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across <a href=\"http:\/\/www.catonmat.net\/blog\/chmod-symbolic-modes-are-more-powerful\">this blog<\/a> post which praises text modes for <em>\/bin\/chmod<\/em>.<\/p>\n<blockquote><p>There are two ways you can change file permissions in Unix &#8211; one is using\u00a0<code>chmod<\/code>&#8216;s symbolic (text) modes (like\u00a0<code>chmod ug+x file<\/code>), the other is using the octal modes (like\u00a0<code>chmod 0660 file<\/code>). It turns out that symbolic modes are more powerful because you can mask out the permission bits you want to change! Octal permission modes are absolute and can&#8217;t be used to change individual bits. Octal modes are also sometimes called absolute because of that.<\/p><\/blockquote>\n<p>I have to agree, they are superior. \u00a0However I feel like the article needs more examples. \u00a0So here we go.<\/p>\n<p>Use &#8220;u&#8221; for user, &#8220;g&#8221; for group, &#8220;o&#8221; for others, and &#8220;a&#8221; for all, or you can use a combination of letters, similar to how you do for access rights:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n$ chmod ug+rw *.php\r\n\r\n<\/pre>\n<p>This will make all .php files in current directory readable and writable by both user and group.<\/p>\n<p>Use several permission changes within one command. \u00a0Just separate them by comma.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n$ chmod a-rwx,ug+rw,o+r *.php\r\n\r\n<\/pre>\n<p>The above will reset permissions on all .php files to readable by all and writable only by user and group.<\/p>\n<p>And my favorite and most used example, which would be tricky with octal permissions is the &#8220;X&#8221;. \u00a0In recursive change mode, &#8220;X&#8221; will affect executable bit only on directories. \u00a0Difference by illustration:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n$ chmod -R a+x \/some\/path\r\n\r\n<\/pre>\n<p>The above will add executable bit to all files and folders under \/some\/path.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n$ chmod -R a+X \/some\/path\r\n\r\n<\/pre>\n<p>But the above will add executable bit only to folders under \/some\/path. \u00a0The files will remain as they are.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across this blog post which praises text modes for \/bin\/chmod. There are two ways you can change file permissions in Unix &#8211; one is using\u00a0chmod&#8216;s symbolic (text) modes (like\u00a0chmod ug+x file), the other is using the octal modes (like\u00a0chmod 0660 file). It turns out that symbolic modes are more powerful because you can &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2011\/03\/09\/chmod-text-modes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">chmod text modes<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,6,133,62],"tags":[1960,616,74],"keyring_services":[],"class_list":["post-14521","post","type-post","status-publish","format-standard","hentry","category-general","category-linux","category-sysadmin","category-technology","tag-command-line","tag-filesystem","tag-tips"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":7828,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/08\/22\/color-scheme-generator\/","url_meta":{"origin":14521,"position":0},"title":"Color scheme generator","author":"Leonid Mamchenkov","date":"August 22, 2004","format":false,"excerpt":"There are plenty color scheme generators on the web. Static, dynamic, Flash, JavaScript, simple, advanced... for any size and taste. Well, I have found the one that fits my tastes. Check it out here. It is written in JavaScript, has nice interface, supports hue\/saturation\/brightness, and can switch between different modes\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14768,"url":"https:\/\/mamchenkov.net\/wordpress\/2011\/04\/18\/command-line-php\/","url_meta":{"origin":14521,"position":1},"title":"Command line PHP","author":"Leonid Mamchenkov","date":"April 18, 2011","format":false,"excerpt":"I've discovered two things about command line PHP today. \u00a0I'll share them here just in case you missed them too. First, the \"-f\" parameter is optional. \u00a0I'm not sure when the change happened, but I'm pretty sure back when I started using it, it was required. \u00a0Now, instead of \"php\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2011\/04\/php-interactive-shell.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":12811,"url":"https:\/\/mamchenkov.net\/wordpress\/2010\/07\/26\/on-browser-compatibility\/","url_meta":{"origin":14521,"position":2},"title":"On browser compatibility","author":"Leonid Mamchenkov","date":"July 26, 2010","format":false,"excerpt":"Here is a quote for you on browser compatibility from an excellent book Diving Into HTML 5, which is available online. The last time I tried to count, there were 5 doctypes that triggered \u201calmost standards mode,\u201d and 73 that triggered \u201cquirks mode.\u201d But I probably missed some, and I\u2019m\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2010\/07\/ie8-mode1-500x417.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":27292,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/05\/things-every-hacker-once-knew\/","url_meta":{"origin":14521,"position":3},"title":"Things Every Hacker Once Knew","author":"Leonid Mamchenkov","date":"February 5, 2017","format":false,"excerpt":"Eric Raymond goes over a few things every hacker once knew. One fine day in January 2017 I was reminded of something I had half-noticed a few times over the previous decade. That is, younger hackers don\u2019t know the bit structure of ASCII and the meaning of the odder control\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22136,"url":"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/06\/github-contributions-graph\/","url_meta":{"origin":14521,"position":4},"title":"GitHub contributions graph","author":"Leonid Mamchenkov","date":"July 6, 2014","format":false,"excerpt":"After reading Mark Story's \"Coding every day\" post, I started checking my own GitHub contributions chart once in a while. \u00a0Until today, I haven't noticed that the chart has two different modes. \u00a0One is your public contributions, seen by people who are not part of your organization's and private projects.\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"github public contributions","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2014\/07\/github-public-contributions-500x198.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8014,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/10\/07\/creative-anniversary-calculator\/","url_meta":{"origin":14521,"position":5},"title":"Creative Anniversary Calculator","author":"Leonid Mamchenkov","date":"October 7, 2004","format":false,"excerpt":"Some people just love to celebrate every and any date. One of the favourite dates to celebrate is usually a birthday. Or a mark of some period since some important event. I came across an excellent Create Anniversary Calculator, which allows one to celebrate a lot more birthdays than usual.\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/14521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=14521"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/14521\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=14521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=14521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=14521"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=14521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}