Hostxpeed
Login Get Started →
Getting Started

How to Search for a File

5 min read
19 views
Jun 10, 2026

Prerequisites

Before searching for files, make sure you have:

  • SSH access to your VPS
  • Basic knowledge of the filename or pattern

Method 1: Using find (Most Powerful)

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Search by exact filename:

find / -name "filename.txt" 2>/dev/null

Case-insensitive search:

find / -iname "filename.txt" 2>/dev/null

Search in specific directory:

find /var/www -name "index.php"

Search for files containing pattern:

find / -name "*.conf" 2>/dev/null

find Pattern Examples

Find all PHP files:

find /var/www -name "*.php"

Find all log files:

find /var/log -name "*.log"

Find by partial name:

find / -name "*backup*" 2>/dev/null

Find files starting with "config":

find / -name "config*" 2>/dev/null

find with Multiple Conditions

Find files with .txt OR .log:

find / -type f ( -name "*.txt" -o -name "*.log" ) 2>/dev/null

Find files larger than 10MB AND with .zip extension:

find / -type f -name "*.zip" -size +10M 2>/dev/null

Find files modified in last 7 days:

find / -type f -mtime -7 2>/dev/null

Method 2: Using locate (Fastest)

Install locate:

apt install mlocate -y

Update database (run as root):

updatedb

Search for file:

locate filename.txt

Case-insensitive:

locate -i filename.txt

Limit results:

locate -n 10 filename.txt

Count matches:

locate -c filename.txt

Method 3: Using which (Search in PATH)

Find executable location:

which nginx

Find all locations of command:

whereis nginx

Find with aliases:

type nginx

Method 4: Using grep (Search File Contents)

Find files containing text:

grep -r "search text" /var/www/

Search with filename:

grep -rl "search text" /var/www/

Case-insensitive search:

grep -ri "search text" /var/www/

Method 5: Search by Size

Find empty files:

find / -type f -size 0 2>/dev/null

Find files larger than 1GB:

find / -type f -size +1G 2>/dev/null

Method 6: Search by Time

Modified in last 24 hours:

find / -type f -mtime 0 2>/dev/null

Modified in last 60 minutes:

find / -type f -mmin -60 2>/dev/null

Accessed in last 2 days:

find / -type f -atime -2 2>/dev/null

Created in last 10 minutes:

find / -type f -cmin -10 2>/dev/null

Method 7: Search by User/Owner

Files owned by hxroot:

find / -user hxroot 2>/dev/null

Files with specific group:

find / -group www-data 2>/dev/null

Execute Command on Found Files

Delete found .tmp files:

find /tmp -name "*.tmp" -exec rm {} ;

Change permissions on PHP files:

find /var/www -name "*.php" -exec chmod 644 {} ;

Count number of .log files:

find /var/log -name "*.log" | wc -l

Search Script

#!/bin/bash
echo "Searching for: $1"
echo "========================="
# Search with find
find / -name "*$1*" 2>/dev/null
echo ""
echo "========================="
echo "Search complete"

Save as search.sh, make executable (chmod +x search.sh), run:

./search.sh config

Performance Tips

  • Use locate for fastest search (but needs updated database)
  • Limit search to specific directories instead of entire filesystem
  • Use 2>/dev/null to hide permission denied errors
  • Use -maxdepth to limit recursion depth
find /var -maxdepth 2 -name "*.conf"

✅ You can now search for files on your Hostxpeed VPS using multiple methods.

Was this article helpful?