Solved

RHEL, How to determine largest files

Posted on 2012-04-05
3
336 Views
Last Modified: 2012-04-06
I used the following command to find out which directories were taking up space on my machine which is out of disk space

du -xsk /* | sort -nr

42088124        /var

Open in new window


How can I determine which are the largest files withing /var
0
Comment
Question by:Los Angeles1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 78

Assisted Solution

by:arnold
arnold earned 166 total points
ID: 37813113
You can do find /var -size +200000c -ls| awk ' { print $7,$NF } ' | sort -rn | more

The size as used here refers to 200000c 200000bytes. You can adjust it lower or higher
Awk will split the ls -l which is what -ls is in the find command on spaces the seventh item is the size of the file, and NF represents the total number of columns in each line adding the $NF represents the last value in each line.

You may have a large file that has no reference within the filesystem I.e. a log that is being used by a running process, but the filename has been deleted. As long as a process has a filehandle, the file remains in existance.  For this you would use lsof and other tools to locate all open files by running processes to locate one.
Example would be an apache process that was writing access.log and then some one did rm access.log
While the file is no longer referenced within the log filesystem, the data is still being written to it as long as a hup, reload are not sent to the apache process at which point it will disconnect and reattach to a new log file and the amount of space previously used by the deleted access.log file will be freed.
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 167 total points
ID: 37813148
Why not

du -xsk /var/* | sort -n

The largest file will appear at the bottom of the list.

Or with subdirectories:

 find /var -type f -printf "%k %p\n" |sort -n

Again, the largest file will appear at the bottom of the list.

wmp
0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 167 total points
ID: 37814752
Hi,

I guess this command will do for you:

# find . -type f -exec du -k {} \; | sort -r -n 

Open in new window


The first part finds files and then executes du. Then the second part sorts it. if you can apply " | head -10" and it will give you 10 largest files.

Feel free to change the "." after find to any valid path to examine other paths.

Cheers,
K.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Samba Question 11 138
Unix Help with:  mailx -s 17 65
Shrink Linux Swap File Size CentOS 10 71
Linux recover lost file deleted by mv 1 31
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question