{"id":18241,"date":"2022-09-05T12:03:01","date_gmt":"2022-09-05T12:03:01","guid":{"rendered":"https:\/\/linuxways.net\/?p=18241"},"modified":"2022-09-21T10:24:05","modified_gmt":"2022-09-21T10:24:05","slug":"chown-command-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/linux-commands\/chown-command-linux\/","title":{"rendered":"CHOWN Command in Linux"},"content":{"rendered":"<p>The CHOWN command in Linux is used for changing the ownership of a file. This ownership can be at the user level as well as at the group level since a file in Linux always belongs to a certain user and a certain group. This article has been designed to share with you the usage of the CHOWN command in Linux.\u201d<\/p>\n<h2><strong>How to Use the CHOWN Command in Linux?<\/strong><\/h2>\n<p>First of all, before starting to use the CHOWN command in Linux, it is good to have a look at its help manual, which can be done by executing this command:<\/p>\n<pre>\r\n$ chown --help\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"327\" height=\"25\" class=\"wp-image-18248\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-1.png 327w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-1-300x23.png 300w\" sizes=\"auto, (max-width: 327px) 100vw, 327px\" \/><\/strong><\/p>\n<p>The help manual of this command is as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"411\" class=\"wp-image-18251\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-2.png 614w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-2-300x201.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/p>\n<p>Now, you can learn the basic usage of this command by going through the examples that we have crafted for you.<\/p>\n<h2><strong>Example # 1: Change the Ownership of a Single File<\/strong><\/h2>\n<p>In this example, we will attempt to change the ownership of a single file in Linux. For that, we will first list down all the files of our Home directory with the help of the command given below:<\/p>\n<pre>\r\n$ ls \u2013l\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"275\" height=\"25\" class=\"wp-image-18252\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-3.png\" \/><\/strong><\/p>\n<p>The following image shows all the files of our system\u2019s Home directory. We will be changing the ownership of the file named \u201ctestfile.txt\u201d from \u201csystem\u201d to \u201csystem2\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"513\" height=\"412\" class=\"wp-image-18256\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-4.png 513w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-4-300x241.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-4-150x120.png 150w\" sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><\/p>\n<p>For changing the ownership, we will run the command shown below:<\/p>\n<pre>\r\n$ sudo chown system2 testfile.txt\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"477\" height=\"21\" class=\"wp-image-18258\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-5.png 477w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-5-300x13.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/strong><\/p>\n<p>Here, \u201csystem2\u201d represents the name of the new owner.<\/p>\n<p>After running this command, you will not get any output. Therefore to confirm if the ownership of the said file has been changed successfully or not, you will have to run the \u201cls -l\u201d command again. You can verify from the following image that the ownership of the said file has successfully been changed to \u201csystem2\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"412\" class=\"wp-image-18264\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-6.png 579w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-6-300x213.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<h2><strong>Example # 2: Display the Change of Ownership on the Terminal<\/strong><\/h2>\n<p>In this example, we want the change of ownership to be displayed in the output of the CHOWN command. Therefore, we will run it this time as shown below:<\/p>\n<pre>\r\n$ sudo chown \u2013c system2 testfile.txt\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"23\" class=\"wp-image-18267\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-7.png 507w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-7-300x14.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-7-501x23.png 501w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/strong><\/p>\n<p>The following output explicitly displays the change of ownership:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"63\" class=\"wp-image-18269\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-8.png 511w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-8-300x37.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-8-501x63.png 501w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<h2><strong>Example # 3: Change the Group of a Single File<\/strong><\/h2>\n<p>Now, we will be using the CHOWN command for changing the group to which a file belongs in Linux. We will execute the command shown below for this purpose:<\/p>\n<pre>\r\n$ sudo chown \u2013c :system2 testfile.txt\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"23\" class=\"wp-image-18274\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-9.png 510w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-9-300x14.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-9-501x23.png 501w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/strong><\/p>\n<p>This command will change the group ownership of the file named \u201ctestfile.txt\u201d to \u201csystem2,\u201d as shown in the following image:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"64\" class=\"wp-image-18276\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-10.png 548w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-10-300x35.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<h2><strong>Example # 4: Change Both the Ownership as well as the Group of the File at Once<\/strong><\/h2>\n<p>Finally, we will attempt to change both the ownership as well as the group to which the file belongs at once. For that, we will make use of the command shown below:<\/p>\n<pre>\r\n$ sudo chown \u2013c system2:system2 testfile.txt\r\n<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"572\" height=\"24\" class=\"wp-image-18279\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-11.png 572w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-11-300x13.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/strong><\/p>\n<p>This command will change the ownership as well as the group to which the file \u201ctestfile.txt\u201d belongs to \u201csystem2,\u201d as shown in the following image:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"57\" class=\"wp-image-18280\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-12.png 602w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/08\/word-image-18241-12-300x28.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>This article discussed the basic usage of the CHOWN command in Linux. This command serves the purpose of changing the ownership of a file in Linux at the user level as well as at the group level. Once you go through all the examples that have been shared in this article, you will conveniently be able to use this command in Linux.<\/p>","protected":false},"excerpt":{"rendered":"<p>The CHOWN command in Linux is used for changing the ownership of a file. This ownership can be at the user level as well as at the group level.<\/p>","protected":false},"author":3,"featured_media":18424,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049],"tags":[],"class_list":["post-18241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/18241","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=18241"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/18241\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/18424"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=18241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=18241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=18241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}