FileUtils.chmodを利用するとファイルのパーミッションを変更することができます。
require "fileutils"が必要になります。
require "fileutils" f = File.open("hello.sh", "w") f.puts("#!/bin/bash") f.puts("echo Hello world!") f.close FileUtils.chmod(0755, "hello.sh")
$ ruby file_chmod.rb $ ls -l hello.sh -rwxr-xr-x 1 sakura staff 30 2 11 21:42 hello.sh $ ./hello.sh Hello world!