Linux below all subdirectories and disk footprint

Source: Internet
Author: User
Tags linux

Today Jenkins (formerly Hudson) CI server suddenly hung up, the investigation of a half-day found that the disk has 100%, I really regret that the disk was not set up a big point, in fact, you can adjust with LVM, but the heart is still no bottom, afraid of the data are lost, decided to adjust the disk allocation. Now, first of all, Jenkins under the useless items are killed, you can make a lot of space.

We all know that using the du command allows you to view directories, such as viewing the/home/kuuyee directory for disk space use the following command:

1root@pm-ubuntu:~# Du/home/kuuyee-sh

2333m/home/kuuyee

But there is a problem, my Jenkins directory there are hundreds of build projects, one by one to look at the directory occupancy situation too much trouble, Google to find a way:

1root@pm-ubuntu:~# Du/home--max-depth=1-h

2125m/home/linux

3333m/home/kuuyee

4457m/home

That's it. The disk occupancy of all subdirectories is listed! The--max-depth parameter here represents the depth of the directory to be listed, set to 2 if you want to list the level two directory, and so on.

If you want to, the result output to the file can be this:

1root@pm-ubuntu:~# du/home--max-depth=1-h > Disk_status.txt

The following is a description of the use and parameters of the du command:

Usage: du [options] ... [File] ...

Or: du [option]...–files0-from=f

Summarize the amount of disk used in each < file >, and take the total amount of the catalogue.

The parameter meaning is as follows:

-S gives only the total number of blocks of data used for each names parameter.

-A recursively displays the number of blocks of data in each file in the specified directory and in the Descendants directory. If-S is not specified or-A is specified, only the number of disk blocks per directory in names and each subdirectory in it is displayed.

-B lists disk space usage in bytes (the system defaults to K bytes).

-k lists disk space usage in 1024-byte units.

-C finally add a total (system default).

-L calculates all file sizes.

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.