How to Change Owner for All Files in a Folder Linux

By | August 6, 2008

A system administrator often needs to deal with file ownership change. This is often related to the ownership of the files created by daemons. Often users don’t have access to the file created by apache. What to do if you need to change ownership of a group of files?

You must be root to perform this operation. The following command will change permissions to all files in the specified folder. This is related to user and group permissions so you don’t need to run chgrp command.

chown -R <user>:<usergroup> <folder>

This will recursively change ownership to the files located in the folder. Note that most web hosting panels create user groups with the same name as users’ so the command will most probably look like chown -R <user>:<user> <folder>. You can use any masks, for example, if you need to change ownership of html files only you need to issue chown -R <user>:<user> <folder>/*.html

This is quite a simple operation, however many people who want to take a look at their servers don’t know this. I hope this article will help you to manage your files