When managing a Linux system, ensuring the security and appropriate permissions of files and directories is crucial. Particularly, being aware of which files and directories have write permissions is important for system security and data integrity. This guide will show you how to use the find
command to search recursively through the file system to identify files and directories based on their write permissions.
In this tutorial you will learn:
- How to use the
find
command to locate files and directories with specific write permissions. - How to tailor search commands to specific needs like user, group, and others’ write permissions.

Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux-based system |
Software | Terminal or command line access |
Other | Basic understanding of Linux file permissions and command line usage |
Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Finding Files and Directories with Write Permissions
This section will guide you through various scenarios where you might need to find files or directories with specific write permissions using the find
command.
- Find all files with write permission for anyone: This example shows how to find all files within a directory that anyone can write to.
find /path/to/search -type f -perm /222
This command recursively searches for all files that have write permissions for the user, group, or others.
Find all files with write permission for anyone - Find all directories with write permission for anyone: Similar to files, this command focuses on directories.
find /path/to/search -type d -perm /222
This will list all directories where write permissions are set for any user.
- Files writable by the user only: This example narrows down the search to files writable only by the file owner.
find /path/to/search -type f -perm /u=w
This finds files where only the owner has write permissions.
- Directories writable by the group only: Targets directories with group write permissions.
find /path/to/search -type d -perm /g=w
This command will list directories writable by the group.
- Files writable by others: To focus on potential security risks, this command finds files writable by users other than the owner or group.
find /path/to/search -type f -perm /o=w
This helps identify files that might be more vulnerable to unauthorized changes.
- Combining conditions for more precise search: This example uses logical operators to find files with specific complex permission sets.
find /path/to/search -type f \( -perm /u=w -or -perm /g=w \)
This command looks for files writable either by the user or the group.
Conclusion
Using the find
command to search for files and directories with write permissions allows system administrators to monitor and secure their environments effectively. Regular checks can help in maintaining the integrity and security of the data on your Linux system.