{"id":36,"date":"2019-11-06T02:52:53","date_gmt":"2019-11-06T02:52:53","guid":{"rendered":"http:\/\/webhostingpune.co.in\/blog\/?p=36"},"modified":"2019-11-06T03:23:30","modified_gmt":"2019-11-06T03:23:30","slug":"how-to-change-file-permissions-in-linux","status":"publish","type":"post","link":"https:\/\/webhostingpune.co.in\/blog\/how-to-change-file-permissions-in-linux\/","title":{"rendered":"How to change file permissions in linux"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Linux File Permissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every file and directory on your Unix\/Linux system is assigned 3 types of owner, given below.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> <strong>Owner <\/strong>is the usually the creator of the files\/folders. In Linux, files or folders that you created in your Home directory are usually owned by you, unless you specifically change the ownership.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li> <strong>Group <\/strong>contains a group of users who share the same permissions and user privilege.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Others <\/strong>means the general public.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Identities<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>u \u2014 the user who owns the file (that is, the owner)<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>g \u2014 the group to which the user belongs<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>o \u2014 others (not the owner or the owner&#8217;s group)<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>a \u2014 everyone or all (u, g, and o)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Permissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"text-align:left\">As for permissions, there are 3 type of actions that you can perform on a file\/folder. You can either read, write or execute.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Read <\/strong>\u2013 You can only view the file, but cannot modify the content of the file. When applied on Folder, you can only view the files in the folder, but you can\u2019t delete from or add files into the folder.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Write <\/strong>\u2013 You can edit and modify the file. For Folders, you can delete and add files into the folder.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Execute <\/strong>\u2013 Execute is mainly used when you need to run the file.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The characters are pretty easy to remember.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>     r = read permission<\/li><li>     w = write permission<\/li><li>     x = execute permission<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Changing file\/directory permissions with &#8216;chmod&#8217; command<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We can use the &#8216;chmod&#8217; command which stands for &#8216;change mode&#8217;. Using the command, we can set permissions (read, write, execute) on a file\/directory for the owner, group and the world.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong><em>Syntax<\/em><\/strong>:    <strong>chmod permissions filename <\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">         <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Absolute Mode:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">How to change permissions in numeric code in Linux, so to do this you use numbers instead of \u201cr\u201d, \u201cw\u201d, or \u201cx\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> 0 = No Permission<br> 1 = Execute<br> 2 = Write<br> 4 = Read<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><em> <\/em><strong><em>Permission numbers are:<\/em><\/strong><em> <br><\/em><br> 0 = ---<br> 1 = --x<br> 2 = -w-<br> 3 = -wx<br> 4 = r-<br> 5 = r-x<br> 6 = rw-<br> 7 = rwx<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>For example:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>chmod 700 foldername<\/strong> &#8211;  will give read, write, and execute permissions for the user only.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Symbolic Mode:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the symbolic mode, you can modify permissions of a specific owner. It makes use of mathematical symbols to modify the file permissions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Actions<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>+  \u2014 adds the permission<\/li><li>&#8211;   \u2014 removes the permission<\/li><li>=  \u2014 makes it the only permission <\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"> <strong>For example:<\/strong> <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong> $  <\/strong> <strong>To check current file permissions<\/strong>  <strong>ls -l admin<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>       -rw-rw-r--    1 home home     150 Mar 19 08:08 admin<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> <strong>$ Set permissions to other users  &#8211;  chmod o=rwx admin<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">      <strong> -rw-rw-rwx    1 home home     150 Mar 19 08:08 admin<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong> $ Add execute permission to usergroup  &#8211;  chod g+x admin<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>       -rw-rwxrwx    1 home home     150 Mar 19 08:08 admin<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong> $ Remove read permission for user  &#8211; chmod u-r admin<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>       --w-rwxrwx    1 home home     150 Mar 19 08:08 admin<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Linux File Permissions Every file and directory on your Unix\/Linux system is assigned 3 types of owner, given below. Owner is the usually the creator of the files\/folders. In Linux, files or folders that you created in your Home directory are usually owned by you, unless you specifically change the ownership. Group contains a group of users who share the same permissions and user privilege. Others means the general public. Identities u \u2014 the user who owns the file (that is, the owner) g \u2014 the group to which the user belongs o \u2014 others (not the owner or the owner&#8217;s group) a \u2014 everyone or all (u, g, and o) Permissions As for permissions, there are 3 type of actions that you can perform on a file\/folder. You can either read, write or execute. Read \u2013 You can only view the file, but cannot modify the content of the file. When applied on Folder, you can only view the files in the folder, but you can\u2019t delete from or add files into the folder. Write \u2013 You can edit and modify the file. For Folders, you can delete and add files into the folder. Execute \u2013 Execute is mainly used when you need to run the file. The characters are pretty easy to remember. r = read permission w = write permission x = execute permission Changing file\/directory permissions with &#8216;chmod&#8217; command We can use the &#8216;chmod&#8217; command which stands for &#8216;change mode&#8217;. Using the command, we can set permissions (read, write, execute) on a file\/directory for the owner, group and the world. Syntax: chmod permissions filename Absolute Mode: How to change permissions in numeric code in Linux, so to do this you use numbers instead of \u201cr\u201d, \u201cw\u201d, or \u201cx\u201d. 0 = No Permission 1 = Execute 2 = Write 4 = Read Permission numbers are: 0 = &#8212; 1 = &#8211;x 2 = -w- 3 = -wx 4 = r- 5 = r-x 6 = rw- 7 = rwx For example: chmod 700 foldername &#8211; will give read, write, and execute permissions for the user only. Symbolic Mode: In the symbolic mode, you can modify permissions of a specific owner. It makes use of mathematical symbols to modify the file permissions. Actions + \u2014 adds the permission &#8211; \u2014 removes the permission = \u2014 makes it the only permission For example: $ To check current file permissions ls -l admin -rw-rw-r&#8211; 1 home home 150 Mar 19 08:08 admin $ Set permissions to other users &#8211; chmod o=rwx admin -rw-rw-rwx 1 home home 150 Mar 19 08:08 admin $ Add execute permission to usergroup &#8211; chod g+x admin -rw-rwxrwx 1 home home 150 Mar 19 08:08 admin $ Remove read permission for user &#8211; chmod u-r admin &#8211;w-rwxrwx 1 home home 150 Mar 19 08:08 admin<\/p>\n","protected":false},"author":1,"featured_media":37,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-36","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":23,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions\/63"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/media\/37"}],"wp:attachment":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}