title: Why chmod 777 not permitted on a rwxrwxrwx file?
body: <p>I have a folder with <code>777</code> access, <code>foo</code> user belongs the <code>pi</code> group, but I cannot change the permissions on <code>foobar</code>. What is the explanation? </p>
  
  <pre><code>$ sudo usermod -a -G pi foo
  $ sudo -u foo touch foobar
  $ ls -al
  total 0
  drwxrwxrwx 2 pi pi 0 Feb 27 19:26 .
  drwxrwxrwx 6 pi pi 0 Feb 26 15:20 ..
  -rwxrwxrwx 1 pi pi 0 Feb 27 19:26 foobar
  $ sudo -u foo chmod 777 foobar
  chmod: changing permissions of ‘foobar’: Operation not permitted
  </code></pre>
  
  <p>It is worth mentioning that the mount is: </p>
  
  <pre><code>//192.168.1.42/test /media/test/ cifs username=pi,password=p,uid=pi,gid=pi,x-systemd.automount 0 0
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p><a href="https://stackoverflow.com/users/6862601/codeforester">codeforester</a> reminded me that <code>foobar</code> is owned by <code>pi</code> so <code>foo</code> cannot change the permissions on it. So the issue is more a <a href="http://xyproblem.info/" rel="nofollow noreferrer">X-Y problem</a> where: </p>
  
  <p>I mounted <code>/media/test/</code> with the generic <code>pi</code> user and group. Daemon users such as <code>foo</code> and <code>bar</code> will require access to this shared folder in <code>rw</code> and they should be able to change the permissions. How can I do it?</p>