Finding all large files in the root filesystem

I have a linux server, which currently has below space usage:

/dev/sda3              20G   15G  4.2G  78% /
/dev/sda6              68G   42G   23G  65% /u01
/dev/sda2              30G  7.4G   21G  27% /opt
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                  48G  8.2G   39G  18% /dev/shm

As you can see. / is at 78%. I want to check, which files or folders are consuming space.

I tried this:

find . -type d -size +100M

Which shows result like this:


Now this is my issue. I only want the name of those files located in folders that are consuming space at / and not at /u01 or /home. Since / is base of everything, it is showing me every file of my server.

Is is possible to get big files that is contributing to 78% of / ?

Asked By: Abhishek dot py



find / -xdev -type f -size +100M

It lists all files that has size bigger than 100M.

If you want to know about directory, you can try ncdu.

If you aren’t running Linux, you may need to use -size +204800 or -size +104857600c, as the M suffix to mean megabytes isn’t in POSIX.

find / -xdev -type f -size +102400000c
Answered By: cuonglm

In addition to @Gnouc answer, you can also use the exec option of find combined with ls -la to get more details. You should have sudo privileges to do that.

$ find / -xdev -type f -size +100M -exec ls -lha {} ; | sort -nk 5

To only see files that are in the gigbyte, do:

root# du -ahx / | grep -E 'd+Gs+'

1.8G    /.Spotlight-V100/Store-V2/A960D58E-A644-4497-B3C1-866A529BF919
1.8G    /.Spotlight-V100/Store-V2
Answered By: z atef

The following command not only find you the top 50 largest files (>100M) on your filesystem, but also sort (GNU sort) by the biggest:

find / -xdev -type f -size +100M -exec du -sh {} ';' | sort -rh | head -n50

-xdev Don’t descend directories on other filesystems.

On BSD find use -x which is equivalent to the deprecated -xdev primary.

For all files and directories, it’s even easier:

du -ahx / | sort -rh | head -20

(the -x flag is what’s required to constrain du to a single filesystem)

If you’re not using GNU sort (from coreutils), use it without -h:

du -ax / | sort -rn | head -20

For current directory only (for quicker results), replace / with ..

Answered By: kenorb
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.