Find Files Based on their Permissions in Linux
Find Files Based on their Permissions in Linux
In Unix-like and some other operating systems, find is a command-line utility that searches one or more directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action on each matched file.
Let’s have some example
- Find Files With 777 Permissions in root directory
# find . -type f -perm 0777 -print
- Find Files Without 777 Permissions
# find / -type f ! -perm 777
- Find Read Only Files
# find / -perm /u=r
- Find all Executable files.
# find / -perm /a=x
- File all Hidden Files
# find /tmp -type f -name ".*"
- Find all Empty Directories
# find /tmp -type d -empty
- Find all empty files under certain path.
# find /tmp -type f -empty
Find and remove multiple files such as .mp3 or .txt, then use
# find . -type f -name "*.txt" -exec rm -f {} \; OR # find . -type f -name "*.mp3" -exec rm -f {} \;