Link to home
Start Free TrialLog in
Avatar of atom_jelly
atom_jellyFlag for United States of America

asked on

Removing World Writable Permissions

I need help with creating either an if statement that will look at the $PATH for root and remove any world writable permissions.
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

for dir in $(echo $PATH | tr ":" " "); do echo chmod -R o-w $dir; done

Or, shorter:

echo chmod -R o-w $(echo $PATH | tr ":" " ")

echo is for a dry run, remove it to actually perform the operations.

Run the above as root.
Avatar of atom_jelly

ASKER

This works! Thanks just one more question I believe the STIG finding is for any world writable permissions for root's $PATH. So could I put in there chmod -R u+w $dir

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany 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
Thank you all.