Unexpected SUID and SGID files can turn a normal account into a privileged execution path. Finding those mode bits during a security review, incident triage, or package audit helps separate expected system helpers from local files that should not run with elevated owner or group privileges.
The find command can match permission bits directly. SUID is the octal 4000 bit, SGID is the octal 2000 bit, and -perm /6000 matches entries that have either bit set. Use -perm -4000 or -perm -2000 when the scan needs only one of the two bits.
Run broad scans with sudo so permission-denied directories do not hide privileged files. Keep the starting path and -xdev boundary deliberate, because a root-filesystem scan should not automatically cross into backup disks, container layers, removable media, or network mounts unless those filesystems are part of the review.
$ sudo find /opt/review -xdev -type f -perm /6000 -ls 3014736 68 -rwxr-sr-x 1 root staff 68064 Jun 13 12:58 /opt/review/bin/group-runner 3014735 68 -rwsr-xr-x 1 root root 68064 Jun 13 12:58 /opt/review/bin/backup-helper
Replace /opt/review with the path being audited. Use / for the root filesystem, or a mount point such as /srv when the review is intentionally limited. -xdev keeps find on the starting filesystem.
$ sudo find /opt/review -xdev -type f -perm -4000 -ls 3014735 68 -rwsr-xr-x 1 root root 68064 Jun 13 12:58 /opt/review/bin/backup-helper
The owner execute position shows s in -rwsr-xr-x when SUID is present and the owner execute bit is also set.
$ sudo find /opt/review -xdev -type f -perm -2000 -ls 3014736 68 -rwxr-sr-x 1 root staff 68064 Jun 13 12:58 /opt/review/bin/group-runner
The group execute position shows s in -rwxr-sr-x when SGID is present and the group execute bit is also set.
$ sudo find /opt/review -xdev -type d -perm -2000 -ls 3014734 4 drwxrwsr-x 2 root root 4096 Jun 13 12:58 /opt/review/shared
SGID on a directory makes new entries inherit the directory group on many Linux filesystems. That can be expected for shared project directories, but it should still match the intended owner and group.
$ stat --format '%A %a %U %G %n' /opt/review/bin/backup-helper /opt/review/bin/group-runner /opt/review/shared -rwsr-xr-x 4755 root root /opt/review/bin/backup-helper -rwxr-sr-x 2755 root staff /opt/review/bin/group-runner drwxrwsr-x 2775 root root /opt/review/shared
The numeric mode makes the special bit explicit: 4 at the front means SUID, 2 means SGID, and 6 means both bits are set.
$ dpkg-query -S /usr/bin/passwd passwd: /usr/bin/passwd
Use rpm -qf /path/to/file on RHEL, Fedora, Rocky Linux, AlmaLinux, and related systems. Package ownership does not prove a file is safe, but it helps separate distribution-managed privileged helpers from local additions.
$ dpkg-query -S /opt/review/bin/backup-helper dpkg-query: no path found matching pattern /opt/review/bin/backup-helper
An unpackaged SUID or SGID executable under a writable, temporary, application, or user-controlled path deserves immediate review. Record the path, mode, owner, group, hash, and package result before changing or deleting the file.