Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

File.chmod

File.chmod(mode_int, file_name, ... ) → integer

Changes permission bits on the named file(s) to the bit pattern represented by mode_int. Actual effects are operating system dependent (see the beginning of this section). On Unix systems, see chmod(2) for details. Returns the number of files processed.

Example
File.chmod(0644, "testfile", "out")   #=> 2
See also #chmod .chardev? .chown .blockdev? also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0