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.
Once logged in, change the directory to the one where the files/folders are located.
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”
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!








March 29th, 2011 at 4:34 am
I would like to use some code which would enable me to change separately file permissions from folder permissions. The idea is to set FOLDER Permissions to 0755 and FILE Permissions to 0644. How to do that?
June 14th, 2011 at 2:08 pm
Well done, that helped me out. Thanks
July 16th, 2011 at 12:41 am
Where do you find the password for root? Eh?
November 20th, 2011 at 2:23 am
Thanks for this very useful post.
I am always amazed (and a little scared) of how fast commands work in ssh -
This one did the trick for me!
November 22nd, 2011 at 5:47 am
Hello,
I am used this pattern, this pattern changed the group name but not change owner. I am write code here .
$fileName = $root_directory.’user_privileges/user_privileges_’.$userid.’.php’;
exec(“chown employhr $fileName”);
exec(“chgrp -R employhr $fileName”);
exec(”);
Please suggest me how I can do these fo change owner/group.
Regards
Saleem
December 2nd, 2011 at 4:49 am
Hi thanks quick and nice…
to add my little part if you want to change also the group not only the user.
chgrp works pretty much the same way as chown does, except it changes the file’s user group instead of the owner, of course.
$ chgrp usergroup somefile
After issuing this command, the file somefile will be owned by a user group usergroup. Although the file’s group has changed to usergroup, the file’s owner will still be the same.
The options of using chgrp are the same as using chown. So, for example, the -R and -v options will work with it just like they worked with chown:
$ chgrp -Rv usergroup somedir
changed group of ‘somedir/’ to usergroup
changed group of ‘somedir/boringfile’ to usergroup
changed group of ‘somedir/somefile’ to usergroup
Regards,
Eduardo
December 13th, 2011 at 3:22 am
Thanks a lot.. It helped
January 23rd, 2012 at 2:20 pm
is it possible to assign multiple users ownership to a folder? even if they don’t belong to the same user group? or multiple user group ownership to a folder?
January 30th, 2012 at 5:42 am
I did these steps (changing dir owner) for a web sites and all worked well. I did the same for another site on the same server but when i try to get into root directory a message appear “permission denied”. Can anybody help me, please?
Thank you,
ligrex