Skip to content

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

class method

File.chown

(::int? owner, ::int? group, *::string | ::_ToPath file_name) -> ::Integer
File.chown(owner_int, group_int, file_name, ...) → integer

Changes the owner and group of the named file(s) to the given numeric owner and group id’s. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file’s group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Returns the number of files processed.

Example
File.chown(nil, 100, "testfile")
See also #chown .chmod .ctime .chardev? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0