{"id":1910,"date":"2023-10-31T11:26:15","date_gmt":"2023-10-31T05:56:15","guid":{"rendered":"https:\/\/www.veeble.org\/kb\/?p=1910"},"modified":"2025-03-10T10:28:58","modified_gmt":"2025-03-10T04:58:58","slug":"managing-file-ownership-and-group-ownership-in-linux","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/managing-file-ownership-and-group-ownership-in-linux\/","title":{"rendered":"Managing File Ownership and Group Ownership in Linux"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259.png\" target=\"_blank\" rel=\"noopener\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-1024x523.png\" alt=\"\" class=\"wp-image-2345\" style=\"width:756px;height:auto\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-1024x523.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-300x153.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-768x392.png 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-1536x785.png 1536w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Firefly-managing-File-Ownership-5259-2048x1046.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>File ownership and group ownership are fundamental concepts in the Linux operating system. Properly managing these attributes is essential for controlling access to files and directories. Here we will explore how to change file ownership and group ownership in Linux. We have already discussed <a href=\"https:\/\/www.veeble.org\/kb\/linux-file-permissions\/\" target=\"_blank\" rel=\"noopener\">File permissions<\/a>, another crucial aspect of <a href=\"https:\/\/linux-kernel-labs.github.io\/refs\/heads\/master\/lectures\/fs.html\" target=\"_blank\" rel=\"noopener\">Linux file management.<\/a><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"file-ownership\">File Ownership<\/h3>\n\n\n<p>In Linux, each file and directory is associated with an owner. The owner has full control over the file, including the ability to modify, delete, and set permissions. To change the file ownership, use the chown command.<\/p>\n\n\n\n<p><strong>chown [new_owner] [file_or_directory]<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest home]# chown ervin file1<\/code><\/pre>\n\n\n\n<p>&nbsp;To view the owner of a file, you can use the ls command with the -l option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest home]# ls -li file1<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/ownership.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"726\" height=\"120\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/ownership.png\" alt=\"file ownership\" class=\"wp-image-1911\" style=\"aspect-ratio:6.05;width:512px;height:auto\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/ownership.png 726w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/ownership-300x50.png 300w\" sizes=\"(max-width: 726px) 100vw, 726px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"group-ownership\">Group Ownership<\/h3>\n\n\n<p>In addition to the file owner, every file and directory also has a group associated with it. The group is a collection of users who share similar permissions for the file. To change the group ownership, use the <strong><a href=\"https:\/\/www.geeksforgeeks.org\/chgrp-command-in-linux-with-examples\/\" target=\"_blank\" rel=\"noopener\">chgrp<\/a><\/strong> command.<\/p>\n\n\n\n<p><strong>        chgrp [new_group] [file_or_directory]<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest home]# chgrp systemadmin file1\n&#91;root@ervintest home]# ls  -l file1\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/group-ownership.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"764\" height=\"124\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/group-ownership.png\" alt=\"group ownership\" class=\"wp-image-1912\" style=\"aspect-ratio:6.161290322580645;width:528px;height:auto\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/group-ownership.png 764w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/group-ownership-300x49.png 300w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-change-both-file-owner-and-group-owner-of-a-file\">How to change both file owner and group owner of a file<\/h3>\n\n\n<p>If you want to change both the owner and group that a file belongs to, specify both the user and group options separated by a full colon as shown in the syntax below. Be sure that there are no spaces between the options and the colon.<\/p>\n\n\n\n<p><strong>chown [new_owner] [new_group] [file_or_directory]<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest home]# chown ervin:systemadmin file1\n&#91;root@ervintest home]# ls -li file1\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/group-ownership-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"124\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/group-ownership-1.png\" alt=\"both ownerships\" class=\"wp-image-1915\" style=\"aspect-ratio:6.161290322580645;width:474px;height:auto\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/group-ownership-1.png 764w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/group-ownership-1-300x49.png 300w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-recursively-change-file-ownership\">How to recursively change file ownership<\/h3>\n\n\n<p>When applying permissions to directories, you might want to apply changes recursively i.e make the ownership changes to descend and apply to files and sub-directories. To achieve this, use the recursive option -R or \u2013recursive directive.<\/p>\n\n\n\n<p><strong>chown -R [user]:[group]&nbsp; [directoryname]<\/strong><\/p>\n\n\n\n<p>For example, the command below assigns all files and folders in the \/home\/adminfiles directory ownership to the systemadmin group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest home]# chown -R ervin:systemadmin  \/home\/adminfiles\n&#91;root@ervintest home]# ls -l \/home\/\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/recursive-ownership.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"262\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/recursive-ownership.png\" alt=\"recursive ownership\" class=\"wp-image-1913\" style=\"aspect-ratio:3;width:542px;height:auto\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/recursive-ownership.png 786w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/recursive-ownership-300x100.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/recursive-ownership-768x256.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>chmod, chown and chgrp commands are powerful tool that is used for managing file and directory ownership and <a href=\"https:\/\/www.veeble.org\/kb\/linux-file-permissions\/\" target=\"_blank\" rel=\"noopener\">permissions<\/a>.<\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:35px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-a4305585 wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Experience the Veeble VPS Difference<\/h3><p class=\"uagb-cta__desc\">Unlock the potential of your website with Veeble VPS. Experience powerful hosting without the hassle. Get started today!<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/managed-vps\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Explore Plans<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>File ownership and group ownership are fundamental concepts in the Linux operating system. Properly managing these attributes is essential for controlling access to files [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":7958,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1910","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Managing-File-Ownership-and-Group-Ownership-in-Linux.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Nayana Nair","author_link":"https:\/\/www.veeble.com\/kb\/author\/nayana\/"},"uagb_comment_info":0,"uagb_excerpt":"File ownership and group ownership are fundamental concepts in the Linux operating system. Properly managing these attributes is essential for controlling access to files [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=1910"}],"version-history":[{"count":9,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1910\/revisions"}],"predecessor-version":[{"id":7763,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1910\/revisions\/7763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/7958"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=1910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=1910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=1910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}