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

  • SEARCH
  • Home
  • 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 8061089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:12:50+00:00 2026-06-05T10:12:50+00:00

I should start by saying I consider myself a proficient user. But today I

  • 0

I should start by saying I consider myself a proficient user. But today I had the need to automate this and was stumped.

Let’s suppose I am root, and as such I’m able to traverse the whole filesystem but I can’t run “sudo” nor “su”.

I have a given user and a given path.

How can I check, over the CLI, whether the user will be able to read and/or write to the path?

I know this sounds easy, but keep in mind that:

  • We’re not, nor can we become, the user.
  • We can’t just rely on the final directory permissions, as permissions higher up the path may be blocking access to the final directory.
  • We can’t just rely just on the directory group permissions either, in this age of inherited groups.

I’m assuming this can’t be done through any command, and I’d need to first gather all user groups, then traverse the whole hierarchy of the path, check read permissions all along the path and then read & write for the final directory. Sounds awfully expensive, though.

  • 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-06-05T10:12:53+00:00Added an answer on June 5, 2026 at 10:12 am

    Tag me a scripting guru!

    check_access() {
      checked_file=$1
      target_user=$2
      result=PASS
    
      groups=`id -G $target_user | sed -e 's| | -o -group |g' -e 's|^|\\( -group |' -e 's|$| \\)|'`
    
      while [ $checked_file != / ]; do 
        find $checked_file -maxdepth 0 \
          -type f \( \
            \( -user $target_user -perm 0400 \) \
            -o \( $groups -perm 0040 \) \
            -o -perm 0004 \
          \) -o -type d \( \
            \( -user $target_user -perm 0100 \) \
            -o \( $groups -perm 0010 \) \
            -o -perm 0001 \
          \) >/dev/null 2>&1 || result=FAIL
        checked_file=`dirname $checked_file`
      done
      echo $result
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I should start this off by saying I'm not sure this is necessarily
Let me start off by saying, I'm not new to programming but am very
This is my first post here, so I should probably start by saying thankyou
Let me start out by saying I have tried this and looked at this
First off, let me start by saying, I know this exact question has been
Let me begin by saying this; I know that similar questions exist, but they
I should start by saying I have researched this question. I can't find any
Let me start by saying I'm a huge fan of the elegance of this
So any custom data attribute that I use should start with data-: <li class=user
here is the code: http://jsfiddle.net/VW8V5/1/ When hover it should start looping but end of

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.