Linux : Change file/folder owner

Wed, Feb 20, 2008

Server

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 domain.com

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

cd /var/www/vhosts/domain.com/httpdocs/myfolder/

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!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • Ping.fm
  • StumbleUpon
  • Print this article!
  • Reddit
  • TwitThis
, , , , , , , ,
scriptlancebannerpng

This post was written by:

Antonie Potgieter - who has written 52 posts on Lost-In-Code.

I (Antonie Potgieter) am a software engineer/web developer located in South Africa. My full-time work is the management of Tribulant Software and the development of its software packages.

Contact the author

Leave a Reply