-1
 chown -Rf www-data.www-data /var/www/html/test/
 ls -l  /var/www/html/test
total 192
-rwxr-xr-x  1 root root   418 Mar 17 21:31 index.php
-rwxr-xr-x  1 root root 19930 Mar 17 21:31 license.txt
-rwxr-xr-x  1 root root  7360 Mar 17 21:31 readme.html
-rwxr-xr-x  1 root root  5035 Mar 17 21:31 wp-activate.php
drwxr-xr-x  9 root root  8192 Mar 17 21:31 wp-admin
-rwxr-xr-x  1 root root   271 Mar 17 21:31 wp-blog-header.php
-rwxr-xr-x  1 root root  1369 Mar 17 21:31 wp-comments-post.php
-rwxr-xr-x  1 root root  2866 Mar 17 22:10 wp-config.php
-rwxr-xr-x  1 root root  2853 Mar 17 21:31 wp-config-sample.php
drwxr-xr-x  6 root root  4096 Mar 17 21:31 wp-content
-rwxr-xr-x  1 root root  3286 Mar 17 21:31 wp-cron.php
drwxr-xr-x 16 root root 16384 Mar 17 21:31 wp-includes
-rwxr-xr-x  1 root root  2380 Mar 17 21:31 wp-links-opml.php
-rwxr-xr-x  1 root root  3316 Mar 17 21:31 wp-load.php
-rwxr-xr-x  1 root root 33770 Mar 17 21:31 wp-login.php
-rwxr-xr-x  1 root root  7887 Mar 17 21:31 wp-mail.php
-rwxr-xr-x  1 root root 13021 Mar 17 21:31 wp-settings.php
-rwxr-xr-x  1 root root 28594 Mar 17 21:31 wp-signup.php
-rwxr-xr-x  1 root root  4035 Mar 17 21:31 wp-trackback.php
-rwxr-xr-x  1 root root  3061 Mar 17 21:31 xmlrpc.php

 df   /var/www/html/test
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sda7        4869120 56812   4812308   2% /var/www/html
 blkid 
 #some info ommitted
/dev/sda7: UUID="   " TYPE="vfat" PARTUUID="   "
sudo chown -R  www-data.www-data /var/www/html/test/
chown: changing ownership of ‘/var/www/html/test/’: Operation not permitted
cat /etc/fstab
# /var/www/html was on /dev/sda7 during installation
UUID=3E3D-09A6  /var/www/html  vfat   defaults  0    0

id
uid=0(root) gid=0(root) groups=0(root)

mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=488907,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=785640k,mode=755)
/dev/sda3 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
/dev/sda7 on /var/www/html type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)
/dev/sda6 on /win7_d type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,utf8,errors=remount-ro)
/dev/sda1 on /win7_c type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
/dev/sda2 on /home type ext4 (rw,relatime,data=ordered)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/109 type tmpfs (rw,nosuid,nodev,relatime,size=392820k,mode=700,uid=109,gid=118)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=392820k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

It is so strange for the fact ,i am root user,why no permission? Why chown command can't take effect?
How to fix it?

showkey
  • 342

1 Answers1

4

Based on your edits provided, your /var/www/html/ folder resides on an external device, /dev/sda7. Based on the information provided, we can infer that the partition is a FAT/FAT32 partition (type='vfat').

FAT/FAT32/exFAT partitions do not support UNIX-style permissions. This is why you cannot chmod or chown the files sanely.

To make this work, you have to provide additional mount options in your /etc/fstab to automatically mount the partition to where it needs to be and to mount it with the permissions schema you need.

In this case, you should add to the existing mount options the following options, which will set the entire directory to be owned www-data:www-data and all files/folders with 755 permissions. This should be added to any existing mount options, and NOT used as a replacement for existing options:

uid=33,gid=33,umask=0022

Additional details on mounting Windows-style partitions may be found on the Ubuntu Help Pages on "Mounting Windows Partitions".


As a system administrator, I STRONGLY urge you to NOT use FAT/FAT32/Windows-style partitions for storing your website data. There's no way to apply the same security permissions and schemas and settings to these types of partitions that can be done in a UNIX filesystem. I will not go into detail on how to create such filesystem here, as you will need to have downtime and a lot more work to create such a filesystem to work with, as well as reloading data after the fact.

Thomas Ward
  • 74,764