Commands.page Logo

How to Find Files with 777 Permissions in Ubuntu Linux

This guide explains how to locate files with insecure 777 permissions on Ubuntu using the command line. We will cover the specific find command syntax and how to execute it safely to maintain system security.

To find files with specific permissions like 777, you use the find command with the -perm flag. This utility searches directory trees for files that match the criteria you set. Running this command allows administrators to audit their system for overly permissive files that could be exploited by malicious actors.

The basic command to search the current directory and all subdirectories is:

find . -perm 777

To search the entire filesystem, you typically need root privileges. Use the following command to scan from the root directory:

sudo find / -perm 0777

In this syntax, / represents the root of the filesystem, and sudo ensures the command has permission to read all directories. The -perm 0777 argument tells find to look for files where the permission bits match 777 exactly. You can replace / with any specific path, such as /home or /var/www, to limit the search scope.

Once the command lists the files, you should review them immediately. If a file does not require world-writable access, change its permissions using the chmod command. For example, to set a file to 755, run chmod 755 filename. Regularly auditing for 777 permissions is a best practice for hardening Ubuntu server security.