Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

chmod 777 is not changing the permissions to 777

Writer Andrew Mclaughlin

I'm trying to change the permissions of temp_dir to 777. Why are these commands not accomplishing that? I'm using Linux by the way.

kylefoley@kfoley76:/mnt/disks$ chmod 777 /mnt/disks/temp_dir
kylefoley@kfoley76:/mnt/disks$ stat -c "%a %n" temp_dir
755 temp_dir

I also tried the verbose switch

kylefoley@kfoley76:/mnt/disks$ chmod -v 777 /mnt/disks/temp_dir
mode of '/mnt/disks/temp_dir' changed from 0755 (rwxr-xr-x) to 0777 (rwxrwxrwx)
kylefoley@kfoley76:/mnt/disks$ stat -c "%a %n" temp_dir
755 temp_dir

I also don't understand why I can't use sudo

kylefoley@kfoley76:/mnt/disks/temp_dir$ sudo chmod 777 fix_mistakes
chmod: cannot access 'fix_mistakes': Permission denied

Even when I log in as root user

kylefoley@kfoley76:/mnt/disks/temp_dir$ sudo -i
root@kfoley76:~# sudo chmod 777 /mnt/disks/temp_dir
chmod: cannot access '/mnt/disks/temp_dir': Permission denied

I should also add that this bug must have something to do with the fact that the directory in question is a gcsfuse mounted disk, available from gcloud. Other attempts to change permissions worked fine:

kylefoley@kfoley76:~$ mkdir hey
kylefoley@kfoley76:~$ stat -c "%a %n" hey
755 hey
kylefoley@kfoley76:~$ chmod 777 hey
kylefoley@kfoley76:~$ stat -c "%a %n" hey
777 hey
5

2 Answers

gcsfuse sets file and directory permissions when mounting. Specifically, the options are:

  • file_mode – Permission bits for files, in octal
  • dir_mode – Permissions bits for directories, in octal

Source:

If you do not specify the options, the defaults are dir_mode=0755,file_mode=0644.

Source:

These options apply to all files and directories in the mount. This FUSE file system does not have the capability of changing permissions for specific files or directories, which is why chmod does nothing.


Furthermore, gcsfuse has additional access restrictions that limit access to the user who mounted the file system. Details:

As a security measure, fuse itself restricts file system access to the user who mounted the file system (cf. fuse.txt). For this reason, gcsfuse by default shows all files as owned by the invoking user. Therefore you should invoke gcsfuse as the user that will be using the file system, not as root.

If you know what you are doing, you can override these behaviors with the allow_other mount option supported by fuse and with the --uid and --gid flags supported by gcsfuse. Be careful, this may have security implications!

Source:

This is why you aren't able to access the mount from another user. To allow other users to access the mount, specify allow_other in your mount options.

I was able to solve the problem in the following way: I had to go to Cloud API Access Scopes and verify under the VM configuration that it has read write or full access for storage. This involved pressing edit on the gcloud console which lists my instances. At the bottom of the page, there was the limitation for storage which I changed to 'full'. That did it.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy