1. I am new on Linux, want to change owner/group of files/directory in linux
2. Change the group of the directory recursively.
1. How to change owner of the file/directory
Let’s see the example of a centos directory.
Here owner is “
Remember here I am using sudo user or if you are using root user then do not need to use sudo prefix. To change owner to the new username “unix”, will use the following command with syntax.
#chown new_owner_name directory_name
[arun@localhost ~]$ sudo chown unix centos/
Recursively change owner of directory: To recursively change owner of the directory or file, use this syntax:
# chown -R new_owner_name directory_name
[arun@localhost ~]$ sudo chown -R unix centos/
2. Change group of directory in linux
We are also going to change group of the ‘centos’ directory to group name ‘unix’. The syntax to change the group of file or directory is :
#chgrp new_group_name directory_name
[arun@localhost ~]$ sudo chgrp unix centos/
Recursively change group of directory: Run this command on parent directory and subfolders group name will also changed.
Syntax is: sudo chgrp -R new_group_name directory_name
[arun@localhost ~]$ sudo chgrp -R unix centos/
Perfect !!! You have learned how to change owner and group