You can change ownership of a file in Linux using the ‘chown’ command as shown in the example below. ‘newowner’ is the username of the account that we will hand ownership of the file to. ‘sudo’ may be required if you’re not at a root shell.
sudo chown -c newowner filename
The output should be:
changed ownership of 'filename' from oldowner to newowner
That’s it! Check to see if the command worked by using the ‘ls -l’ command to list the files and their owners as shown below. The output of the command should look something like this:
-rw-r--r-- 1 newowner groupname [date] filename