Skip to content

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

instance method

File#chown

file.chown(owner_int, group_int ) → 0

Changes the owner and group of file 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. Follows symbolic links. See also File#lchown.

Example
File.new("testfile").chown(502, 1000)
See also .chown #chmod #ctime #birthtime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0