Find the answer to your Linux question:
Results 1 to 2 of 2
Hiya, Im looking for a program or script that could show me a list of file and folders that a specified user could access if they were logged in. Eg, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    What could a user see if they were logged in?


    Hiya,

    Im looking for a program or script that could show me a list of file and folders that a specified user could access if they were logged in.

    Eg, out of all the files on the harddrive, what would user "X" be able to read?

    Anyone know of a script/program that does this?

    Thanks,

    Jason

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I don't think that there is a command that can do that, but, correct me if I'm wrong, shouldn't it be possible to do it something like this (running as the user to check):
    Code:
    #!/bin/sh
    
    function checkdir
    {
        for f in "$1"*; do
            if [ -d "$f" ]; then
                if [ -r "$f" -a -x "$f" ]; then
                    checkdir "$f/"
                elif [ -r "$f" ]; then
                    echo "$f"
                elif [ -x "$f" ]; then
                    echo "half-warning: $f is executable, but not readable"
                fi
            fi
            if [ -f "$f" -a -r "$f" ]; then
                echo "$f"
            fi
        done
    }
    
    checkdir /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •