{"id":342,"date":"2011-12-14T20:55:37","date_gmt":"2011-12-14T20:55:37","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2011\/12\/14\/changing-permissions-and-ownership\/"},"modified":"2021-08-16T23:48:53","modified_gmt":"2021-08-17T03:48:53","slug":"changing-permissions-and-ownership","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/","title":{"rendered":"How to change file permissions and ownership settings while in SSH"},"content":{"rendered":"<p>In this tutorial, we&#8217;ll show you how you can <strong>edit file permissions<\/strong> and <strong>adjust file ownership settings while in SSH<\/strong>. This is not the only way to change permissions settings however, it can be done <a href=\"\/support\/\">within your cPanel&#8217;s File Manager<\/a> as well.<\/p>\n<h2>Changing File Permissions<\/h2>\n<p>The chmod command is used to change file permissions. The basic syntax is:<\/p>\n<p class=\"code_block\"><strong>chmod ### file\/folder<\/strong><\/p>\n<p>We&#8217;ll now show you the command in action. We&#8217;ll first <a href=\"\/support\/server\/ssh\/how-to-login-ssh\/\">log into our account via SSH<\/a> and use the pwd command to see which folder we&#8217;re in. We&#8217;ll then run the ls command to see the current files and their permissions, run the chmod command to edit permissions, and then finally use ls again to see that the permissions have been changed.<\/p>\n<p class=\"cli\"><em>user5@example.com [~\/testa]#<\/em> <strong>pwd<\/strong><br \/>\n\/home\/user5\/testa<\/p>\n<p><em> user5@example.com [~\/testa]#<\/em><strong> ls -alh<\/strong><br \/>\ntotal 8.0K<br \/>\ndrwxr-xr-x   2 user5 user5 4.0K Dec  7 18:43 .\/<br \/>\ndrwx&#8211;x&#8211;x  10 user5 user5 4.0K Dec  6 08:16 ..\/<br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file1.txt<br \/>\n<span style=\"color: #ff0000;\"><strong>-rw-r&#8211;r&#8211;<\/strong> 1 user5 user5    0 Dec  7 18:43 file2.txt<\/span><br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file3.txt<\/p>\n<p><em> user5@example.com [~\/testa]#<\/em> <strong>chmod 755 file2.txt<\/strong><\/p>\n<p><em> user5@example.com [~\/testa]#<\/em> <strong>ls -alh<\/strong><br \/>\ntotal 8.0K<br \/>\ndrwxr-xr-x   2 user5 user5 4.0K Dec  7 18:43 .\/<br \/>\ndrwx&#8211;x&#8211;x  10 user5 user5 4.0K Dec  6 08:16 ..\/<br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file1.txt<br \/>\n<span style=\"color: #ff0000;\"><strong> -rwxr-xr-x<\/strong> 1 user5 user5    0 Dec  7 18:43 file2.txt*<\/span><br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file3.txt<\/p>\n<p>As you can see, file2.txt was changed from 644 to 755.<\/p>\n<h2>Changing File Ownership Settings<\/h2>\n<p>The chown command is used to change file ownership settings. The basic syntax is:<\/p>\n<p class=\"code_block\"><strong>chown user:user file\/folder<\/strong><\/p>\n<p>The act of changing permissions is much more common than changing ownership. One reason is that most of the time you&#8217;ll need root access to use chown, and root access is not given by default to accounts.<\/p>\n<p>In the example below, we&#8217;ll log into our account via SSH and change the ownership settings from user5:user5 to user5:nobody for the file file2.txt.<\/p>\n<p class=\"cli\"><em>root@example.com [\/home\/user5\/testa]#<\/em> <strong>pwd<\/strong><br \/>\n\/home\/user5\/testa<\/p>\n<p><em> root@example.com [\/home\/user5\/testa]#<\/em> <strong>ls -alh<\/strong><br \/>\ntotal 8.0K<br \/>\ndrwxr-xr-x   2 user5 user5 4.0K Dec  7 18:43 .\/<br \/>\ndrwx&#8211;x&#8211;x  10 user5 user5 4.0K Dec  6 08:16 ..\/<br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file1.txt<br \/>\n<span style=\"color: #ff0000;\"> -rwxr-xr-x   1 <strong>user5 user5<\/strong> 0 Dec  7 18:43 file2.txt*<\/span><br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5    0 Dec  7 18:43 file3.txt<\/p>\n<p><em> root@example.com [\/home\/user5\/testa]#<\/em> <strong>chown user5:nobody file2.txt<\/strong><\/p>\n<p><em> root@example.com [\/home\/user5\/testa]# ls -alh<\/em><br \/>\ntotal 8.0K<br \/>\ndrwxr-xr-x   2 user5 user5  4.0K Dec  7 18:43 .\/<br \/>\ndrwx&#8211;x&#8211;x  10 user5 user5  4.0K Dec  6 08:16 ..\/<br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5     0 Dec  7 18:43 file1.txt<br \/>\n<span style=\"color: #ff0000;\"> -rwxr-xr-x   1 <strong>user5 nobody<\/strong> 0 Dec  7 18:43 file2.txt*<\/span><br \/>\n-rw-r&#8211;r&#8211;   1 user5 user5     0 Dec  7 18:43 file3.txt<\/p>\n<p>There are many more ways you can use chown and chmod other than the basic examples we&#8217;ve listed above. Usually if you need a way to get something done, there are additional options you can use to get it done. If you need assistance, feel free to post in the comments and we&#8217;ll show you how you may be able to do it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we&#8217;ll show you how you can edit file permissions and adjust file ownership settings while in SSH. This is not the only way to change permissions settings however, it can be done within your cPanel&#8217;s File Manager as well. Changing File Permissions The chmod command is used to change file permissions. The<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\"> Read More ><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4299],"tags":[],"class_list":["post-342","post","type-post","status-publish","format-standard","hentry","category-security"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to change file permissions and ownership settings while in SSH | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this tutorial we&#039;ll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to change file permissions and ownership settings while in SSH | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this tutorial we&#039;ll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2011-12-14T20:55:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:48:53+00:00\" \/>\n<meta name=\"author\" content=\"Brad Markle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad Markle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"How to change file permissions and ownership settings while in SSH\",\"datePublished\":\"2011-12-14T20:55:37+00:00\",\"dateModified\":\"2021-08-17T03:48:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\"},\"wordCount\":488,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\",\"name\":\"How to change file permissions and ownership settings while in SSH | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2011-12-14T20:55:37+00:00\",\"dateModified\":\"2021-08-17T03:48:53+00:00\",\"description\":\"In this tutorial we'll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to change file permissions and ownership settings while in SSH\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\",\"name\":\"Brad Markle\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to change file permissions and ownership settings while in SSH | InMotion Hosting","description":"In this tutorial we'll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/","og_locale":"en_US","og_type":"article","og_title":"How to change file permissions and ownership settings while in SSH | InMotion Hosting","og_description":"In this tutorial we'll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.","og_url":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2011-12-14T20:55:37+00:00","article_modified_time":"2021-08-17T03:48:53+00:00","author":"Brad Markle","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Brad Markle","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"How to change file permissions and ownership settings while in SSH","datePublished":"2011-12-14T20:55:37+00:00","dateModified":"2021-08-17T03:48:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/"},"wordCount":488,"commentCount":8,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/","url":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/","name":"How to change file permissions and ownership settings while in SSH | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2011-12-14T20:55:37+00:00","dateModified":"2021-08-17T03:48:53+00:00","description":"In this tutorial we'll show you how to use the chown and chmod commands to change file permissions and ownership settings while in SSH.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/changing-permissions-and-ownership\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to change file permissions and ownership settings while in SSH"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf","name":"Brad Markle","url":"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4299,"name":"Security","slug":"security","link":"https:\/\/www.inmotionhosting.com\/support\/security\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":3,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"predecessor-version":[{"id":86432,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/342\/revisions\/86432"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}