124

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:

./u01/app/june01.dbf
./u01/app/temp01.dbf
./u01/app/smprd501.dbf
./home/abhishek/centos.iso
./home/abhishek/filegroup128.jar

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 / ?

217

Try:

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
  • 1
    -xdev just prevents find from walking across filesystems, so you'll only search your current physical drive. If that's not what you want, just remove the -xdev arg. – hobs Jan 13 at 5:58
49

In addition to @Gnouc answer , you can also add ls -la to get more details. You should have sudo privileges to do that .

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

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

root# du -ahx / | grep -E '\d+G\s+'


1.8G    /.Spotlight-V100/Store-V2/A960D58E-A644-4497-B3C1-866A529BF919
1.8G    /.Spotlight-V100/Store-V2
44

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 currently directory only (for quicker results), replace / with ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.