Skip to content

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

class method

File.umask

File.umask() → integer
File.umask(integer) → integer

Returns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222 would make a file read-only for everyone.

Example
File.umask(0006)   #=> 18
File.umask         #=> 6
See also .truncate .unlink .symlink? .utime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0