Change owner with chown in Linux and know which one to put

The chown command is quite simple to use. But be careful, because when you change the owner of the file, you are not going to put any owner, which can aggravate the problem.

To know the owner that you should put, and also to confirm that this is your problem, look at the owner of a file that you can update with your FTP.

You can find out the owner of your files by doing a: ls -l

In the list you will see two text fields with the owner and the group.

-rw-r–r– 1 apache www 168 Mar 26 2011 examplefile.php

In the file listed above, “apache” is the owner and “www” is the group. If that file can be overwritten from your FTP, you would have to put those same owner + group in your conflicting file.

For example, by going to the directory where the file you want to affect is, you could do it like this.

chown apache:www yourfile\_conflicting.html

Now, imagine that you want to change all the owners of the files in a directory, you could do it like this:

chown myowner:mygroup\*

Of course you should be in the directory where you want to change all the files.

Now, imagine that you want to change the owner and group of all the files in a folder and all its subdirectories, recursively.

chown -R user:group .

As a precaution, always be careful when sending commands that modify all files and all files in all subdirectories!!!

I suggest you look for more information about the chown command on Wikipedia: http://es.wikipedia.org/wiki/Chown

Loading Facebook Comments ...
Loading Disqus Comments ...