{"id":932,"date":"2022-08-24T02:26:52","date_gmt":"2022-08-24T02:26:52","guid":{"rendered":"http:\/\/shijuvarghese.com\/?p=932"},"modified":"2022-08-24T02:29:36","modified_gmt":"2022-08-24T02:29:36","slug":"umask-in-linux","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=932","title":{"rendered":"Umask in Linux"},"content":{"rendered":"<p><strong>What is it?<\/strong><\/p>\n<p>Umask in Linux is a Linux command that is used to assign the default file permission sets that will be assigned when a file or a directory will be created by a user.<br \/>\nFor example, all files created by a specific user created a file, by default a specific file permission gets assigned to it such as r w &#8211; r &#8211; &#8211; r &#8211; &#8211; . This is because of the umask value that is set for the user.<\/p>\n<p><strong>How to find the umask set for a user?<\/strong><\/p>\n<p>Running the below command helps to find the umask value set for a user<br \/>\n<em>[root@localhost ~]# umask<\/em><br \/>\n<em>0022<\/em><\/p>\n<p><strong>Where is the umask value configured?<\/strong><\/p>\n<p>The umask value for all users in general is configured in either:<br \/>\n\/etc\/profile<br \/>\n\/etc\/bashrc<br \/>\nThis value is overridden by values configures in below file in user\u2019s home folder:<br \/>\n~\/.bash_profile<br \/>\n~\/.bashrc<\/p>\n<p><strong>How to calculate the permissions system will be assigning to files and folders based on the umask value?<\/strong><\/p>\n<p>One umask value configured determines the permissions that will be set for both files and directories created by a user.<br \/>\nIf the umask value is 002, the newly created file\u2019s permission will be the obtained by reducing each bit of <strong>666<\/strong> by each bit of 002. That is:<br \/>\n6-0 = 6<br \/>\n6-0 = 6<br \/>\n6-2 = 4<\/p>\n<p>Therefore the default file permission will be r w &#8211; r w &#8211; r- &#8211;<\/p>\n<p>If the umask value is 002, the newly created folder\u2019s permission will be the obtained by reducing each bit of <strong>777<\/strong> by each bit of 002. That is:<br \/>\n7-0 = 7<br \/>\n7-0 = 7<br \/>\n7-2 = 5<\/p>\n<p>Therefore the default file permission will be r w x r w x r- x<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>What is it? Umask in Linux is a Linux command that is used to assign the default file permission sets that will be assigned when <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=932\" title=\"Umask in Linux\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":252,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-932","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=932"}],"version-history":[{"count":4,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/932\/revisions"}],"predecessor-version":[{"id":936,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/932\/revisions\/936"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/252"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}