Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:47:34+00:00 2026-05-27T06:47:34+00:00

On Unix/Linux systems, the chmod function supports symbolic modes, meaning you can do what

  • 0

On Unix/Linux systems, the chmod function supports “symbolic modes”, meaning you can do what is essentially bit-arithmetic with permissions, e.g. chmod u+x ... is a symbolic form for adding executable permissions for the user. The chmod function in Ruby’s FileUtils only supports an absolute bitmask as a permission, i.e. you can only do FileUtils.chmod(0777, ...) but FileUtils.chmod('u+x', ...) will not work.

I get that one way to do this is to just call the system command directly: system("chmod u+x ..."), but I’d prefer to keep code in the Ruby domain as much as possible without spawning shells everywhere. Alternatively, I could iterate through File objects, File.stat them, get their existing bitmasks and modify them individually, but symbolic modes will support a file glob, which is much more succinct and less error prone.

Does anyone know whether there is a way to do this in a more elegant way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:47:35+00:00Added an answer on May 27, 2026 at 6:47 am

    What version of Ruby are you using? Look at the 1.9.3 docs for FileUtils.chmod:

    Changes permission bits on the named files (in list) to the bit
    pattern represented by mode. mode is the symbolic and absolute mode
    can be used. Absolute mode is

    FileUtils.chmod 0755, 'somecommand'
    FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
    FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
    

    Symbolic mode is

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can the .NET framework be installed on Linux, Unix, MAC etc. operating systems?
Is there any C++ implementation of 64-bit Unix timestamp conversions for 32-bit systems? I
On a modern Unix or Linux system, how can you tell which code set
When using mmap() for shared memory (from Linux, or other UNIX-like systems) is it
I need to measure, in C++ on Linux (and other Unix-like systems), the CPU
Python for Unix and Linux System Administration is aimed at sysadmins. Any other favorites
In Unix/Linux, how do you find out what group a given user is in
I want to learn to program in a UNIX/Linux environment. I'll be using the
I need to run a standalone ruby script as Unix (linux) daemon. After running
What is recommended way to keep a user configuration data in Unix/Linux? My programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.