Linux : Change file/folder owner

On a Unix based system, all files and folders belong to a group and a owner. Or rather, an owner and a group has specific permissions to read, write and execute files. So you might need to change the owner of certain files and folders so that you’ll be able to open them, edit them and write to them again.

I’ll show you how to do this via SSH. You’ll need a login and password in order to access the shell.

ssh -lroot

Once logged in, change the directory to the one where the files/folders are located.

cd /var/www/vhosts/

Then you might want to recursively change the owner for all files and folders inside that directory to another user. Lets set the owner of the files and folders to “peter”

chown -R peter *

That is all there is to it. You have just changed the owner of all files and folders recursively inside the specified directory to “peter”. You can now open the files (for example via FTP), edit them and write back to them again. Good luck!