Avatar of atom_jelly
atom_jelly
Flag 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.
Unix OSScripting LanguagesShell Scripting

Avatar of undefined
Last Comment
atom_jelly

8/22/2022 - Mon
woolmilkporc

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.
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
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
atom_jelly

ASKER
Thank you all.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck