How to grant permission to FileSystem.php file I navigate to admin/config/media/file-system in the drupal admin interface. I get this error 


  Warning: mkdir(): Permission denied in Drupal\Core\File\FileSystem->mkdirCall() (line 244 of core/lib/Drupal/Core/File/FileSystem.php) . 


I granted the permission to sites folder using the following commands chown -R www-data:www-data sites and chmod -R g+rw sites.
But still the error appears.

Any advice?
First of all make sure that the files directory (sites/default/files by default) has the right owner and permissions.
And also directory of temporary files, in general /tmp if you don't have create one and give it the right permissions.