How to Find Big Files Size on Linux RHEL/CentOS

Find Big Files Size

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space.

Low disk space can also affect server performance and sometimes cause critical processes such as backup job to fail.

This article shows how you can find big files size on Linux CentOS and RHEL.

Command Example to Find Big Files Size on Linux

1. How to display the biggest directories in /var/log and display the result in human readable format

# cd /var/log
# du -sh * | sort -rh | head -10
78M     nginx
14M     audit
1012K   dmesg.old
980K    messages-20170109
700K    messages-20160907
556K    anaconda
288K    messages-20161212
128K    wtmp
120K    httpd
96K     messages-20160929

2. To display the largest folders including the sub-directories for /var/log :

# du -Sh /var/log | sort -rh | head -10
78M     /var/log/nginx
14M     /var/log/audit
3.6M    /var/log
556K    /var/log/anaconda
120K    /var/log/httpd
68K     /var/log/tuned
56K     /var/log/mariadb
28K     /var/log/php-fpm
4.0K    /var/log/varnish
4.0K    /var/log/ppp

or

# du -Sh /var/log | sort -n -r | head -n 10
556K    /var/log/anaconda
120K    /var/log/httpd
78M     /var/log/nginx
68K     /var/log/tuned
56K     /var/log/mariadb
28K     /var/log/php-fpm
14M     /var/log/audit
4.0K    /var/log/varnish
4.0K    /var/log/ppp
4.0K    /var/log/dirsrv

3. To display the largest files including the sub-directories for /var/log :

# du -ah /var/log | sort -rh | head -10
96M     /var/log
78M     /var/log/nginx/ehowstuff.local.error.log-20160907
78M     /var/log/nginx
14M     /var/log/audit
6.1M    /var/log/audit/audit.log.2
6.1M    /var/log/audit/audit.log.1
1.8M    /var/log/audit/audit.log
1012K   /var/log/dmesg.old
980K    /var/log/messages-20170109
700K    /var/log/messages-20160907

4. To find the largest files in a particular location or directory for example /var/log :

# find /var/log -type f -exec du -Sh {} + | sort -rh | head -n 10
78M     /var/log/nginx/ehowstuff.local.error.log-20160907
6.1M    /var/log/audit/audit.log.2
6.1M    /var/log/audit/audit.log.1
1.8M    /var/log/audit/audit.log
1012K   /var/log/dmesg.old
980K    /var/log/messages-20170109
700K    /var/log/messages-20160907
288K    /var/log/messages-20161212
184K    /var/log/anaconda/anaconda.storage.log
152K    /var/log/nginx/ehowstuff.local.access.log-20160907.gz

5. To find the largest files (top 10) in a particular location or directory for example /var/log :

# find /var/log -printf '%s %p\n'|sort -nr|head
81440064 /var/log/nginx/ehowstuff.local.error.log-20160907
6291477 /var/log/audit/audit.log.2
6291467 /var/log/audit/audit.log.1
1823505 /var/log/audit/audit.log
1052691 /var/log/dmesg
1001793 /var/log/messages-20170109
709481 /var/log/messages-20160907
293738 /var/log/messages-20161212
292000 /var/log/lastlog
187757 /var/log/anaconda/anaconda.storage.log

6. To display the largest files(top 20) in a particular location or directory for example /var/log using ls command :

# ls -lSh | head -n20
total 3.7M
-rw-r--r--  1 root       root    1.1M Jan  9 21:52 dmesg
-rw-------  1 root       root    979K Jan  9 15:12 messages-20170109
-rw-------  1 root       root    693K Sep  7 03:21 messages-20160907
-rw-------  1 root       root    287K Dec 12 10:01 messages-20161212
-rw-r--r--. 1 root       root    286K Jan  9 22:03 lastlog
-rw-rw-r--. 1 root       utmp    125K Jan  9 22:03 wtmp
-rw-------  1 root       root     95K Sep 29 21:01 messages-20160929
-rw-r--r--  1 root       root     94K Jan  9 14:57 dmesg.old
-rw-------  1 root       root     81K Jan  9 22:07 messages
-rw-------  1 root       root     55K Sep  6 23:16 secure-20160907
-rw-r--r--  1 root       root     36K Sep  7 03:21 cron-20160907
-rw-------. 1 root       root     26K Jan  4 22:12 yum.log-20170109
-rw-r--r--  1 root       root     23K Jan  9 21:53 vmware-vmsvc.log
-rw-------. 1 root       root     17K Dec 30  2015 yum.log-20160101
-rw-------  1 root       root    9.3K Jan  9 14:59 secure-20170109
-rw-r--r--  1 root       root    9.2K Jan  9 21:52 boot.log
-rw-------. 1 root       root    8.0K Dec 20 22:39 grubby
-rw-------  1 root       root    7.3K Dec 12 10:17 maillog-20161212
-rw-r--r--  1 root       root    5.4K Jan  9 15:19 cron-20170109

I hope this article gives you some ideas and essential guidance on how to find big files size on linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7.

See also  How to Install FTP Client to connect FTP Server on RHEL 6

References :

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *