{"id":9181,"date":"2021-08-13T11:21:27","date_gmt":"2021-08-13T11:21:27","guid":{"rendered":"https:\/\/linuxways.net\/?p=9181"},"modified":"2021-08-13T11:21:27","modified_gmt":"2021-08-13T11:21:27","slug":"umask-command-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/umask-command-in-linux\/","title":{"rendered":"Umask Command in Linux"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>UMASK in a Linux system stands for User Mask. It is the default permission of a file or directory when they are created in your Linux machine.<\/p>\n<p>Most Linux distros have a default value of UMASK is 022.<\/p>\n<p>This article will show you the detail of the UMASK and the way to use it.<\/p>\n<h2>Calculate the value of UMASK<\/h2>\n<p>The minimum and maximum values of umask for a directory are 000 and 777 respectively. The minimum and maximum values of umask for a file are 000 and 666 respectively. The following table describes some of the common values:<\/p>\n<table>\n<thead>\n<tr>\n<th>0<\/p>\n<p>1<\/p>\n<p>2<\/p>\n<p>3<\/p>\n<p>4<\/p>\n<p>5<\/p>\n<p>6<\/p>\n<p>7<\/th>\n<th>Read, Write &amp; Execute<\/p>\n<p>Read &amp; Write<\/p>\n<p>Read &amp; Execute<\/p>\n<p>Read Only<\/p>\n<p>Write &amp; Execute<\/p>\n<p>Write Only<\/p>\n<p>Execute Only<\/p>\n<p>No Permissions<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<p>To get a better understanding of how to use UMASK in Linux, let\u2019s analyze the following example:<\/p>\n<p>If the value of umask is 077, it means:<\/p>\n<p>0 &#8211; the Owner has Read, Write and Execute permission<\/p>\n<p>7 &#8211; the Group has no Permissions<\/p>\n<p>7 &#8211; Others have no Permissions<\/p>\n<pre>$ umask 077<\/pre>\n<pre>$ mkdir new-folder<\/pre>\n<pre>$ touch new-file<\/pre>\n<pre>$ ls -ld new-folder new-file<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1170\" height=\"258\" class=\"wp-image-9182\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-193.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-193.png 1170w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-193-300x66.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-193-1024x226.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-193-768x169.png 768w\" sizes=\"auto, (max-width: 1170px) 100vw, 1170px\" \/><\/p>\n<h2>Get the current umask value<\/h2>\n<p>You can get the current value of umask by simply running the command:<\/p>\n<pre>$ umask<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1086\" height=\"76\" class=\"wp-image-9183\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-194.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-194.png 1086w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-194-300x21.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-194-1024x72.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-194-768x54.png 768w\" sizes=\"auto, (max-width: 1086px) 100vw, 1086px\" \/><\/p>\n<h2>Another way to set the umask value<\/h2>\n<p>Besides the method of using numeric value for umask, you can configure the umask by alphabetic value as:<\/p>\n<p>r &#8211; Read<\/p>\n<p>w &#8211; Write<\/p>\n<p>x &#8211; Execute<\/p>\n<p>u &#8211; User ownership<\/p>\n<p>g &#8211; Group ownership<\/p>\n<p>o &#8211; other ownership<\/p>\n<p>For instance:<\/p>\n<pre>$ umask u=rw<\/pre>\n<pre>$ mkdir test-folder<\/pre>\n<pre>$ touch file-test<\/pre>\n<pre>$ ls -ld test-folder file-test<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1178\" height=\"146\" class=\"wp-image-9184\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-195.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-195.png 1178w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-195-300x37.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-195-1024x127.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-195-768x95.png 768w\" sizes=\"auto, (max-width: 1178px) 100vw, 1178px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>You\u2019ve already gone through the details of how to use UMASK in the Linux system.<\/p>\n<p>Thanks for reading. If you have any concerns, feel free to leave your comment and let me know.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction UMASK in a Linux system stands for User Mask. It is the default permission of a file or directory when they are created in your Linux machine.&hellip;<\/p>","protected":false},"author":1,"featured_media":9277,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[477],"class_list":["post-9181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-umask-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=9181"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9181\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/9277"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=9181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=9181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=9181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}