Linux find Command for Security: Hunt Suspicious Files in Seconds


Ask a Linux admin their favourite security tool and you'll hear names like Fail2ban, ClamAV, or Wireshark. Almost nobody says find — and that's a mistake. The humble find command is one of the fastest ways to hunt for signs of compromise on a Linux system. Here are five searches every beginner should know.

The Basics

find searches directories and matches files by name, type, size, permissions, or modification time. The syntax is simple:

find /where -to -look -for -what

For example, find /home -name "*.sh" lists every shell script under /home. Now let's put it to work.

1. Files Modified in the Last 24 Hours

After a suspected breach, the first question is: what changed recently?

sudo find /etc /usr/bin /var/www -type f -mtime -1

-mtime -1 means modified less than 1 day ago. Attackers touch system files, drop scripts, and edit configs — this catches the fresh footprints. Narrow the window with -mmin -60 for the last hour.

2. Rogue SUID Binaries

SUID lets a program run with its owner's privileges — usually root. Attackers love planting or abusing SUID binaries for privilege escalation.

sudo find / -perm -4000 -type f 2>/dev/null

Know your baseline: /usr/bin/sudo, /usr/bin/passwd, and /usr/bin/su are normal. Anything unfamiliar — especially in /tmp or a web directory — is a red flag.

3. World-Writable Files

Files anyone can modify are a gift to attackers.

sudo find / -type f -perm -0002 2>/dev/null | grep -v "/proc"

On a healthy server this list is short. A web shell or backdoor dropped in a writable directory shows up here.

4. Suspicious Files in /tmp and /dev/shm

Temporary directories are the attacker's favourite hiding spot because they're writable by everyone and rarely monitored.

find /tmp /dev/shm -type f -exec ls -la {} \;

Look for executables, scripts, or anything with a random-looking name. Legitimate software rarely leaves binaries here.

5. Huge or Hidden Files

Crypto miners and stolen data often hide as large files or dotfiles in odd places:

sudo find /home /var -type f -size +100M -exec ls -lh {} \;
find / -type f -name ".*" -mtime -7 2>/dev/null | head -30

Putting It Together: A 2-Minute Hunt

# What changed in the last day?
sudo find / -type f -mtime -1 2>/dev/null | grep -v -E "^/(proc|sys|run|var/log)"
# Any new SUID binaries?
sudo find / -perm -4000 -type f 2>/dev/null
# Anything executable hiding in /tmp?
find /tmp /dev/shm -type f -perm -111 2>/dev/null

Two Rules

  • Run these only on systems you own or manage, or on your own lab VMs. Scanning someone else's server without permission is illegal.
  • 2>/dev/null hides "permission denied" noise — add it to every root-wide search or you'll drown in errors.

find won't replace a real intrusion detection system, but it answers the most important question in seconds: did something change on my machine? Learn it now, and the day something looks wrong, you'll already know where to look.

 

Comments

Popular Posts