Skip to main content
To find a file by name on Linux, run sudo find / -name "nginx.conf" 2>/dev/null; use -iname to ignore upper and lower case and * as a wildcard, for example -name "*.log". To search for text inside files, run grep -rn "server_name" /etc/nginx: -r searches all subfolders and -n shows the line number of every match.

Before you start

  • Connect with SSH.
  • Searching the whole disk from / can take a while and shows many “Permission denied” lines without sudo. Use sudo (root can leave it out), start in the most likely folder, and add 2>/dev/null to hide error messages.

How to find a file by name

Expected output:
Always put the name in quotes when it contains *, so the shell doesn’t expand it first.

How to find files by size or date

-mtime -1 means “less than one day ago”; +7 means “more than seven days ago”. -mmin -30 works in minutes.

How to act on the files you find

Show details:
Delete old files:
-delete removes files permanently with no confirmation. Run the same command with -print first, read the list, then replace -print with -delete. Never run a -delete search from /.

How to find a file quickly with locate

locate searches a prebuilt index, so it answers instantly.
The index is refreshed once a day, so brand-new files only appear after sudo updatedb.

How to search for text inside files with grep

Example output:
Each line shows the file, line number and matching text. To see a config file without comments and blank lines:

Search command output

Pipe any command into grep:

How to check it worked

Create a test file and find it both ways:
Both commands print /home/alex/findme.txt; grep adds :1:hello from alex.

Frequently asked questions

How do I find which config file sets a value?

Search the config folder for the setting name: sudo grep -rn "upload_max_filesize" /etc/php. The last file loaded usually wins.

Is there a faster grep?

ripgrep (rg) skips binary and ignored files and is much faster on large trees. Install it with sudo apt install ripgrep on Ubuntu/Debian; on AlmaLinux/Rocky it is in EPEL.

How do I find which package owns a file?

Use dpkg -S /usr/sbin/nginx on Ubuntu/Debian and rpm -qf /usr/sbin/nginx on AlmaLinux/Rocky.

How do I find where a command is installed?

Run command -v nginx or which nginx. type -a nginx shows every match on your PATH.

VPS and dedicated server guides

Every server guide in one place.

Essential Linux commands

The commands you use every day.

Check disk space

df and du explained.

Read logs with journalctl

Search the systemd journal.

Checked against the official GNU findutils manual and GNU grep manual on 4 November 2026; commands tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026