Some time when we are working in the Linux at that time we may face the problem regarding the “File permission” or we might not be able to change the content of the file because we do not belong to the actual owner of that file or we may not belong to the group that have an access to that file or directory.
1>To change the Owner of the File/Directory.
$ chown username file_name
this will change the owner of the “filename” to the “username ” that you have given.
2>To change the Owner and the Group for the File at the same time.
$ chown usename:groupname file_name
this will change the “Owner” and the “Group” of the “file name” that you have given.
3>Change the Owner of the Directory.
$ chown username directory_name
This will change the owner of the Directory, but the owner of the files inside that directory wont change, to do that
we have to use the following command.
$ chown -R username directory_name
this command will help you to change the owner of the directory as well as the owner of the files inside that directory.
“-R” stands for the Recursive, so that will recursively change the owner of the files of the Directory.
I hope this might have helped you to change the ownership as well as the Group of the file, it will be better if you will work with the “sudo”, and then enter the password. it will be easier to work with this.