Link to home
Start Free TrialLog in
Avatar of akohan
akohan

asked on

How to check permission of a file or path?


Hello,

I know this is possible by "stat" command or  "ls"  command but I'm looking for a command to return me if $USER (current user) has  privilege or permission to a specific /dir1/dir2/a_file

1) Let's say user1 runs script1
2) user1 has access to some paths and no access to some others
3) I need a command to return a  true/false value or anything to check it in my script befoer following a procedure.

Thanks
Avatar of ozo
ozo
Flag of United States of America image

perl -e 'print 0+-r "/dir1/dir2/a_file"'
perl -e 'print 0+-w "/dir1/dir2/a_file"'
perl -e 'print 0+-x "/dir1/dir2/a_file"'
Avatar of akohan
akohan

ASKER


Thanks you so much but it has to be in bash.

Thanks again for your resonse.
AkOHAN

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial