The file that consumes the most disk space in the Linux lookup system

Source: Internet
Author: User

Q: There is a customer disk space in the afternoon is very large, using DF to view the disk space is very small, customers want to know which files are full of files.

    • Q1: How do I see the file with the largest disk space under Linux?
    • Q2: Under Linux, how do I get files under a folder to be sorted by size?

A:

I do not know if you have encountered such a problem, the server is not on the shelf how long the disk is full.

Analysis: Most of the logs are not rolling, you can use a script or logrotate to either delete the log regularly or close the unwanted logging function directly. 51 Open Source community posts have relevant methods for handling various server logs. Next you'll be reminded of the path where the log files for Apache and MySQL or other application servers are located. After entering the corresponding log path, it turns out that the log is a disaster, delete the log, about the journal Wheel Roll please refer to 51 other posts in the open source community. But this is not the subject of this article. If the other files occupy disk space, how to find out. I mainly use the Find and Du commands.

Use the Find command to locate a file larger than the specified size:

[email protected] Data]#/--+10G      

Will output:

/usr/Local/apache2/logs/access_log      

You can now see the size of this file by using the du command:

[email protected] Data]#-/usr/local/apache2/logs/ access_log            
24G     /usr/local/apache2/logs/access_log   

We can repeatedly execute the Find command to find large files, for example: find / -type f -size +5G find files larger than 5G. find / -type f -size +1Gfind files larger than 1G

Under Linux, how do I get files under a folder to be sorted by size?

There are two ways.

    • Method One: # ls -lhSl long format display, H Human readable mode, size unit is M,G and other easy-to-read format, S size sort by size.
    • Method Two: #du -h * | sort -n

Of course you can also view the maximum number of files within a folder or the smallest number of files in a pipeline, plus the pipe symbol and head or tail command du -h * | sort -n|head .du -h * | sort -n|tail

The file that consumes the most disk space in the Linux lookup system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.