Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

File#chmod

file.chmod(mode_int) → 0

Changes permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2) for details. Follows symbolic links. Also see File#lchmod.

Example
f = File.new("out", "w");
f.chmod(0644)   #=> 0
See also .chmod #birthtime #chown #atime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1