Skip to content

How to Find Files on a Linux Server: Complete Guide

How to find files on a Linux server is an important skill when troubleshooting disk space problems. Large log files, old backups, database exports, and application uploads can consume storage without being noticed. Linux commands such as find, du, and sort help you locate these files and identify which directories are using the most space.

When a Linux server starts running out of disk space, the first step is to find out which files are taking up room. Old backups, oversized logs, database exports, and application uploads are common places to investigate.

You do not need a graphical file manager to do this. A few Linux commands can show where storage is going, help you locate unusually large files, and narrow the search to a specific directory.

1. Check Which Filesystem Is Running Out of Space

Start with:

df -h

This displays the space used and available on mounted filesystems. For example:

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        80G   72G  8.0G  90% /

Here, the root filesystem is 90% full. That does not tell you which files are responsible, but it identifies the filesystem you should investigate first.

To check the space used by a particular directory, run:

du -sh /var

Replace /var with the directory you want to inspect.

2. Search for Files Above a Specific Size

The find command can locate files that exceed a size threshold. To search for files larger than 1 GB, run:

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

The search starts at /, so it can take time on a server with many files. The -type f option limits the results to regular files, while 2>/dev/null suppresses error messages such as permission-denied warnings.

You can adjust the size to suit your needs:

find / -type f -size +500M 2>/dev/null

Or search for files larger than 100 MB:

find / -type f -size +100M 2>/dev/null

If you already know where the problem might be, search that directory instead of the entire server. For example:

find /var -type f -size +100M 2>/dev/null

A narrower search usually finishes faster and produces fewer irrelevant results.

3. List the Largest Files and Directories

To see which items are consuming the most space under /var, use:

du -ah /var 2>/dev/null | sort -rh | head -20

The command displays the 20 largest entries, including files and directories. The -h option makes sizes easier to read, and sort -rh places larger sizes first.

You can use the same approach for home directories:

du -ah /home 2>/dev/null | sort -rh | head -20

Keep in mind that a directory’s reported size includes the contents beneath it. A large directory and the files inside it may therefore appear as separate entries.

If you need a list of large files only, use find rather than relying on this directory-size listing.

4. Get a Size-Sorted List of the Largest Files

On Linux distributions with GNU find, this command displays the 20 largest regular files it can access:

find / -type f -printf '%s %p\n' 2>/dev/null |
  sort -nr |
  head -20 |
  awk '{printf "%.2f GB\t%s\n", $1/1073741824, $2}'

Each result contains the file size in gigabytes and its path. This is useful when you need to compare several large files rather than simply locate files above a fixed size.

The command may take a while because it searches the filesystem before sorting the results. It also requires enough temporary storage or memory for the list of discovered files. On very large servers, narrow the search to the affected directory first.

5. Look for Oversized Log Files

Application and system logs can grow quickly when a service repeatedly records errors or log rotation is not configured properly.

To locate log files larger than 100 MB:

find /var/log -type f -size +100M \
  -exec ls -lh {} \; 2>/dev/null

To check the sizes of the immediate entries under /var/log, run:

du -sh /var/log/*

Pay attention to application logs and persistent systemd journal data, which may be stored under /var/log/journal/.

Do not remove a log simply because it is large. Check which service owns it and whether the information is needed for debugging or auditing. If the log keeps growing, investigate the source of the messages and configure appropriate log rotation or retention.

6. Check Backup Directories

Backups can occupy substantial storage when older copies remain on the server after newer backups have been created.

To find backup files larger than 1 GB:

find /backup -type f -size +1G \
  -exec ls -lh {} \; 2>/dev/null

This example assumes the backup directory is /backup. Substitute the actual path used by your backup software.

Before removing anything, confirm that a newer backup is complete and can be restored if needed. If backups are consuming the same disk used by your applications, storing older copies on separate storage may help reduce pressure on the server.

7. Find Large Files in a Particular User Account

On a shared hosting server, one account may use more storage than others. To inspect a user’s home directory, run:

du -ah /home/username 2>/dev/null | sort -rh | head -20

Replace username with the actual account name.

To list files larger than 250 MB in that account:

find /home/username -type f -size +250M 2>/dev/null

This can help locate large archives, uploaded media, database exports, and application files. Run the commands with appropriate permissions, and do not modify another user’s files without authorization.

8. Search Without Entering Other Mounted Filesystems

A server may have separate filesystems mounted under paths such as /home, /mnt, or /backup.

If you only want to search the filesystem containing the starting path, add -xdev:

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

This prevents find from descending into directories on different device filesystems. It can make a search more focused, but it also excludes files on separate mounted filesystems. If the full disk is mounted at /home or /backup, search that filesystem separately.

9. Investigate Disk Space Used by Deleted Files

A file can disappear from its directory while its disk space remains in use. This can happen when a running process still has the file open.

If lsof is installed, check for deleted files that remain open:

lsof +L1

Review the process name, process ID, and file size in the output. If a large deleted log file appears, identify the associated service before deciding what to do.

A controlled service reload or restart may release the space, depending on how the application handles the file. Do not terminate an important process without checking its role and the potential impact.

10. Decide What to Do With the Files You Find

Finding a large file does not automatically mean it is safe to delete. A database file, application upload, or backup may be essential even if it consumes several gigabytes.

Before making changes:

  • Check the file’s purpose, owner, path, and size.
  • Confirm whether an application or service is actively using it.
  • Verify that important data has a usable backup.
  • Remove only files that are confirmed to be unnecessary.
  • Run df -h again to check whether available space has increased.

If storage usage keeps climbing, investigate the cause rather than repeatedly deleting files. A growing log, accumulating backups, or application-generated data may require a permanent fix.

Linux provides several ways to investigate disk usage without installing extra software. Start with df -h to identify the affected filesystem, use find to locate files above a chosen size, and use du with sort to inspect the largest entries in a directory.

For ongoing server maintenance, check storage regularly and review backup retention and log rotation settings. If your applications genuinely need more disk capacity, compare the storage options available through ServerNext VPS hosting before deciding whether to expand your existing setup or move to a larger plan.