Change Ownership of Files and Folders

To change the ownership of files and folders in a directory. For a plesk httpdocs directory that runs fastcgi. For apache – you will want to change this to apache:apache.

Change directory

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

Find who owns the files and folders.


ls -la
[root@austin httpdocs]# ls -la
total 20
drwxr-xr-x  3 mungoadmin psacln 4096 Jun 11 14:16 .
drwxr-xr-x 22 mungoadmin psacln 4096 Jun 11 14:13 ..
drwxr-xr-x  2 root       root   4096 Jun 11 14:16 anotherdir
-rw-r--r--  1 root       root      6 Jun 11 14:14 test1.txt
-rw-r--r--  1 root       root     10 Jun 11 14:15 test2.php

You see that some files/directories are owned by root:root an some by mungoadmin:psacln. We will want to change this to be the ftp user in plesk – which is mungoadmin:psacln.

To change this run the following (Warning – make sure you are in the directory you want to change all the files/directories in):

[root@austin httpdocs]# chown -R mungoadmin:psacln *

Now – look at the changes

[root@austin test]# ls -la
total 20
drwxr-xr-x  3 mungoadmin psacln 4096 Jun 11 14:16 .
drwxr-xr-x 22 mungoadmin psacln 4096 Jun 11 14:13 ..
drwxr-xr-x  2 mungoadmin psacln 4096 Jun 11 14:17 anotherdir
-rw-r--r--  1 mungoadmin psacln    6 Jun 11 14:14 test1.txt
-rw-r--r--  1 mungoadmin psacln   10 Jun 11 14:15 test2.php