Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

File.setuid?

(::path | ::IO file_name) -> bool
File.setuid?(object) → true or false

Returns whether the setuid bit is set in the special bits for the given object, which may be a path or an IO object:

Example
path = '/tmp/t.tmp'
File.write(path, 'foo')
mode = File.stat(path).mode.to_s(8) # => "100664"
File.setuid?(path)                  # => false
File.chmod(0o4644, path)            # Set the bit.
mode = File.stat(path).mode.to_s(8) # => "104644"
File.setuid?(path)                  # => true
File.delete(path)                   # Clean up.
File.setuid?($stdin)                # => false

On Windows, the bit is never set; the method always returns false.

See also .setgid? .size .rename .size? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0