I want to do the following:

  1. Need to find all world writable files and folders from / root.
  2. If found, I need to check whether the sticky bit is set or not.
  3. If the sticky bit is not set, then set it.

Can we come up with a command line solution for this type of problem?

4 Answers 4


You can do this using find's -perm -mode format. From man find:

-perm -mode

All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which would want to use them. You must specify u',g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples.

So, to find all files that are world writeable, irrespective of what other permissions they have, you can do:

find / -perm -o+w 

To set the sticky bit, use -exec:

find . -perm -o+w -exec chmod +t {} + 
  • 3
    NB: use find / -not -type l -perm -o+w if you don't want output to include the names of symbolic links as well.
    – chb
    Oct 10, 2016 at 8:12

This command should find writable directories all in one command, I find myself using this quite often. This it the optimal command! ;) hope it serves you well:

find / -type d \( -perm -g+w -or -perm -o+w \) -exec ls -adl {} \;

This command might work for you:

find / -type f! -path "/ proc / *" -prune -perm o + w exec ls {} -lg /; 2> / dev / null

My favorite is this one:

Find world writable folders on local disks, with sticky bit not set and set it:

df --local -P 2> /dev/null | awk {'if (NR!=1) print $6'} | \
xargs -I '{}' find '{}' -xdev -type d \( -perm -0002 -a -perm -1000 \) exec chmod +t {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.