Skip to content

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

class method

File.umask

(?::int umask) -> ::Integer
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.3 · 3.2 · 3.1 · 3.0