{"id":3327,"date":"2014-06-26T18:32:29","date_gmt":"2014-06-26T18:32:29","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/06\/26\/chown-command\/"},"modified":"2014-06-26T18:32:29","modified_gmt":"2014-06-26T18:32:29","slug":"chown-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/","title":{"rendered":"chown command"},"content":{"rendered":"<p>Another commonly used linux command is the <em>chown<\/em> command. &#8216;<em>chown<\/em>&#8216; is short for <em>change owner<\/em>. It allows users to change the owner and group associated with a file.<\/p>\n<p><strong>Command: <\/strong>chown<br \/> <strong>Synopsis: <\/strong> chown [OPTION]&#8230; [OWNER][:[GROUP]] FILE&#8230; <\/p>\n<div><strong>Options: <\/strong><\/div>\n<table class=\"article_table\">\n<tr>\n<th>Option<\/th>\n<th>Long option name<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>-c<\/td>\n<td>&#8211;changes<\/td>\n<td>Operates like verbose (-v) but report only when a change is made.<\/td>\n<\/tr>\n<tr>\n<td>-h<\/td>\n<td>&#8211;no-dereference<\/td>\n<td>affect each symbolic link instead of any referenced file (useful only on systems that can change  the               ownership of a symlink).<\/td>\n<\/tr>\n<tr>\n<td>-v<\/td>\n<td>&#8211;verbose<\/td>\n<td>Outputs a diagnostic for every file processed.<\/td>\n<\/tr>\n<tr>\n<td>-f<\/td>\n<td>&#8211;silent &#8211;quiet<\/td>\n<td>Suppresses most error messages.<\/td>\n<\/tr>\n<tr>\n<td>-R<\/td>\n<td>&#8211;recursive<\/td>\n<td>Operate on files and directories recursively.<\/td>\n<\/tr>\n<\/table>\n<h2>Examples using chown.<\/h2>\n<p>For the following examples, assume the file test.txt starts out with only &#8216;Read&#8217; permissions (r) for all three groups (user, group, and other). It will appear as the following: <\/p>\n<pre class=\"cli\">   # <span style=\"color:red\">ls -l test.txt<\/span>   -r--r--r--  1 root    root     29K Jun 17 12:01 test.txt <\/pre>\n<\/p>\n<h3>Changing the owner of a file<\/h3>\n<p><strong>chown [OWNER] FILE&#8230;<\/strong> &#8211; This is one of the most basic ways to use the command. In this example, we simply change the <em>test.txt<\/em> file, which is originally owned by the <em>root<\/em>  user, to be owned by the user named <em>test<\/em>. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown test test.txt<\/span> # <span style=\"color:red\">ls -l<\/span> -rw-r--r-- 1 test root 29K Jun 17 12:01 test.txt <\/pre>\n<\/p>\n<h3>Changing the group of a file<\/h3>\n<p><strong>chown [:GROUP] FILE&#8230;<\/strong> &#8211; Much like the previous example, we are using no options. We will be changing just the group of the file to <em>test<\/em>. It is almost the same syntax except you must precede the group name with a colon :. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown :test test.txt<\/span> # <span style=\"color:red\">ls -l<\/span> -rw-rw-rw- 1 root test 29K Jun 17 12:01 test.txt <\/pre>\n<\/p>\n<h3>Changing both owner and group at once.<\/h3>\n<p><strong>chown [OWNER][:[GROUP]] FILE&#8230;<\/strong> &#8211; Combining the method of the previous two examples, we will change the owner and group of the <em>test.txt<\/em> file from <em>root<\/em> to <em>test<\/em>. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown test:test test.txt<\/span> # <span style=\"color:red\">ls -l test.txt<\/span> -rw-r-xr-- 1 test test 29433 Jun 17 12:01 test.txt <\/pre>\n<\/p>\n<h3>Using the  verbose option.<\/h3>\n<p><strong>chown [OPTION]&#8230; [OWNER][:[GROUP]] FILE&#8230;.<\/strong> &#8211; We now will demonstrate one of the most common options, <em>-v<\/em>, or <em>verbose<\/em>. This will display the changes that were made as the command is run. As you can see, we do not have to use the &#8216;<em>ls<\/em>&#8216; command afterwards in order to see how the permissions ended up. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown -v test:test test.txt<\/span> changed ownership of `test.txt' to test:test <\/pre>\n<\/p>\n<h3>Changing the ownership\/group of a directory.<\/h3>\n<p><strong>chown [OWNER][:[GROUP]] [DIR]<\/strong> &#8211; Working with directories is very much the same as a file. Below we will be changing the <em>image<\/em> directory to use the owner and group named <em>test<\/em>. The only thing different is that we name a directory instead of a file. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown test:test images<\/span> # <span style=\"color:red\">ls -l<\/span> drwxr-xr-x  2 root    root   4096 Jun 26 14:13 images\/ <\/pre>\n<\/p>\n<h3>Change all files in a directory recursively<\/h3>\n<p><strong>chown [OPTION]&#8230; [OWNER][:[GROUP]] [DIR]<\/strong> &#8211; If you need all files within a directory changed to the same owner or group, you will want to use the -R, or recursive option. This saves time over doing each one separately. Be warned that this will change all files and directories within the named directory including the named directory. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">chown -R test:test images<\/span> # <span style=\"color:red\">ls -l<\/span> drwxr-xr-x 2 test test 4096 Jun 26 14:13 .\/ drwxr-xr-x 3 root root 4096 Jun 26 14:04 ..\/ -rw-r--r-- 1 test test    0 Jun 26 14:13 file1.png -rw-r--r-- 1 test test    0 Jun 26 14:13 file2.png -rw-r--r-- 1 test test    0 Jun 26 14:13 file3.png <\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another commonly used linux command is the chown command. &#8216;chown&#8216; is short for change owner. It allows users to change the owner and group associated with a file. Command: chown Synopsis: chown [OPTION]&#8230; [OWNER][:[GROUP]] FILE&#8230; Options: Option Long option name Description -c &#8211;changes Operates like verbose (-v) but report only when a change is made.<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\"> Read More ><\/a><\/p>\n","protected":false},"author":8,"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":[4308],"tags":[],"class_list":["post-3327","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>chown command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn to use the Linux chown command.\" \/>\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\/server\/linux\/chown-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"chown command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn to use the Linux chown command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\" \/>\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=\"2014-06-26T18:32:29+00:00\" \/>\n<meta name=\"author\" content=\"Scott Mitchell\" \/>\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=\"Scott Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"chown command\",\"datePublished\":\"2014-06-26T18:32:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\"},\"wordCount\":446,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\",\"name\":\"chown command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-06-26T18:32:29+00:00\",\"description\":\"Learn to use the Linux chown command.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"chown command\"}]},{\"@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\/d850efb28ef3573db7d24b0d8fa9eaed\",\"name\":\"Scott Mitchell\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"chown command | InMotion Hosting","description":"Learn to use the Linux chown command.","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\/server\/linux\/chown-command\/","og_locale":"en_US","og_type":"article","og_title":"chown command | InMotion Hosting","og_description":"Learn to use the Linux chown command.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-06-26T18:32:29+00:00","author":"Scott Mitchell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Scott Mitchell","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"chown command","datePublished":"2014-06-26T18:32:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/"},"wordCount":446,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/","name":"chown command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-06-26T18:32:29+00:00","description":"Learn to use the Linux chown command.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/chown-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"chown command"}]},{"@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\/d850efb28ef3573db7d24b0d8fa9eaed","name":"Scott Mitchell","url":"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3327","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\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3327"}],"version-history":[{"count":0,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3327\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}