Du-sh/* check which file points use my hard disk

Source: Internet
Author: User

We often receive questions from our VPS users, "My VPS is not equipped with new things. Why is the harder the hard disk is to be used ?", This is mostly because of the long-term accumulation of various logs on the system, such as nginx, the access log information left behind by apache is not cleared for a long time, and the access traffic is large, it will easily expand to GB. Sometimes the logs of some application programs are hidden in the depths of the file system, and it is hard to find out; sometimes I copy some large files and put them somewhere for a long time. In Linux, how does one find these files that occupy hard disk space?

First, we can count the hard disk usage of each directory in the root directory and find the directory that occupies the most disk:

# du -sh /*6.2M/bin17M/boot136K/dev97M/etc147G/home584M/lib16M/lib6416K/lost+found8.0K/media12K/mnt252K/opt0/proc1.7G/root28M/sbin8.0K/selinux3.1M/srv0/sys20K/tmp1.9G/usr748M/var

We can see from the above that/home occupies the most disk space. Let's see which users in/home occupy the most space:

# du -sh /home/*4.0K/home/bak106M/home/cos28K/home/guest16K/home/lost+found105G/home/vpsee33G/home/somebody8.2G/home/abc

We can see that the user vpsee and his home directory/home/vpsee used the most hard drive (105 GB). Let's see which files in/home/vpsee occupy space, run the following command to find out the files in a directory (/home/vpsee) with a size greater than 500 MB (print the first 40 rows and sort them in the ascending order of MB ):

# find /home/vpsee -printf "%k %p\n" | sort -g -k 1,1 | \awk '{if($1 > 500000) print $1/1024 "MB" " " $2 }' |tail -n 40647.68MB  /home/vpsee/linux/debian-504-amd64-CD-1.iso675.664MB /home/vpsee/linux/Fedora-13-i686-Live.iso677.656MB /home/vpsee/unix/osol-0906-x86.iso678.172MB /home/vpsee/linux/ubuntu-10.04-server-amd64.iso700.133MB /home/vpsee/linux/ubuntu-10.04-desktop-i386.iso1304.64MB /home/vpsee/mac/MacTeX.mpkg.zip

You can see that/home/vpsee is an iso favorites craze, and a bunch of Linxu ISO installation files have been collected. In the past, everyone liked to collect some software and tools stored on hard disks in the dial-up Internet era, now that the network is so developed, these old habits are no longer necessary, and ISO files are dispensable. When necessary, we will go to the next latest one. We don't need to keep it by ourselves. The network is our hard disk.

Related Article

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.