[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

RHEL, How to determine largest files

Posted on 2012-04-05
3
Medium Priority
?
343 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 80

Assisted Solution

by:arnold
arnold earned 664 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 668 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 668 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

649 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