本文簡要介紹ruby語言中 FileUtils.chmod
的用法。
用法
chmod(mode, list, noop: nil, verbose: nil)
將命名文件(在 list
中)的權限位更改為由 mode
表示的位模式。
mode
是符號和絕對模式都可以使用。
絕對模式是
FileUtils.chmod 0755, 'somecommand'
FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
符號模式是
FileUtils.chmod "u=wrx,go=rx", 'somecommand'
FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
- “a”
-
是用戶、組、其他掩碼。
- “u”
-
是用戶的掩碼。
- “g”
-
是組的掩碼。
- “o”
-
是 other 的掩碼。
- “w”
-
是寫權限。
- “r”
-
是讀取權限。
- “x”
-
是執行權限。
- “X”
-
僅對目錄的執行權限,必須與“+”結合使用
- “s”
-
是uid,gid。
- “t”
-
是粘位。
- “+”
-
被添加到給定模式的類中。
- “-”
-
從給定的類給定模式中刪除。
- “=”
-
是類的確切性質,將被賦予一個指定的模式。
相關用法
- Ruby FileUtils.chmod_R用法及代碼示例
- Ruby FileUtils.chown_R用法及代碼示例
- Ruby FileUtils.chown用法及代碼示例
- Ruby FileUtils.compare_file用法及代碼示例
- Ruby FileUtils.cp_lr用法及代碼示例
- Ruby FileUtils.collect_method用法及代碼示例
- Ruby FileUtils.commands用法及代碼示例
- Ruby FileUtils.cd用法及代碼示例
- Ruby FileUtils.cp用法及代碼示例
- Ruby FileUtils.cp_r用法及代碼示例
- Ruby FileUtils.mkdir用法及代碼示例
- Ruby FileUtils.options_of用法及代碼示例
- Ruby FileUtils.ln_s用法及代碼示例
- Ruby FileUtils.install用法及代碼示例
- Ruby FileUtils.rmdir用法及代碼示例
- Ruby FileUtils.rm_rf用法及代碼示例
- Ruby FileUtils.mv用法及代碼示例
- Ruby FileUtils.have_option?用法及代碼示例
- Ruby FileUtils.mkdir_p用法及代碼示例
- Ruby FileUtils.rm_f用法及代碼示例
- Ruby FileUtils.rm_r用法及代碼示例
- Ruby FileUtils.ln用法及代碼示例
- Ruby FileUtils.options用法及代碼示例
- Ruby FileUtils.ln_sf用法及代碼示例
- Ruby FileUtils.touch用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 FileUtils.chmod。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。