View file and folder size commands under Linux

Source: Internet
Author: User


The DF command can show the available space and usage for all current file systems, and see the following example:

The following is a code fragment:

The code is as follows Copy Code
[Yayug@yayu ~]$ Df-h
FileSystem Size Used Avail use% mounted on
/DEV/SDA1 3.9G 300M 3.4G 8%/
/dev/sda7 100G 188M 95G 1%/data0
/DEV/SDB1 133G 80G 47G 64%/data1
/dev/sda6 7.8G 218M 7.2G 3%/var
/dev/sda5 7.8G 166M 7.2G 3%/tmp
/dev/sda3 9.7G 2.5G 6.8G 27%/usr
Tmpfs 2.0G 0 2.0G 0%/dev/shm

The DF command is a Linux system that looks at the file system on a disk partition, and can add parameters to view the disk's remaining space information, in command format:

The code is as follows Copy Code
Df-hl

The display format is:
File system capacity used available% mount point

The code is as follows Copy Code
FileSystem Size Used Avail use% mounted on
/dev/hda2 45G 19G 24G 44%/
/DEV/HDA1 494M 19M 450M 4%/boot
/dev/hda6 4.9G 2.2G 2.5G 47%/home
/dev/hda5 9.7G 2.9G 6.4G 31%/opt
None 1009M 0 1009M 0%/dev/shm
/dev/hda3 9.7G 7.2G 2.1G 78%/usr/local
/DEV/HDB2 75G 75G 0 100%/
/DEV/HDB2 75G 75G 0 100%/

Take the above output as an example, the meaning of the expression is:

The second hard drive (b) of the HD hard disk interface, the second partition (2), the capacity is 75G, 75G, usable is 0, so utilization is 100% and is mounted on the root partition directory (/).

The following is an explanation of the relevant commands:

DF-HL View disk remaining space

Df-h View the partition size of each root path

Du-sh [directory Name] Returns the size of the directory

DU-SM [Folder] returns the total m of this folder

More versatile you can enter commands to view:

DF--help

Du--help


Du: Querying for file or folder disk use space

If you have a large number of files and folders in the current directory, you can iterate through the space used by all files and folders by using commands with no parameters du. This is a bad place to see if it's too big, so specify the number of layers in the Drill-down directory, Parameters:--max-depth=, which is a very useful parameter! For example, note that you can use "*" to get the size of the file space.

Reminder: It has always been ordered to be more complex than Linux, and its du command specifies that the number of layers in the Drill-down directory is simpler than Linux, FreeBSD.


The following is a code fragment:

The code is as follows Copy Code

[Root@bsso yayu]# du-h--max-depth=1 work/testing
27M Work/testing/logs
35M work/testing

[Root@bsso yayu]# du-h--max-depth=1 work/testing/*
8.0K work/testing/func.php
27M Work/testing/logs
8.1M Work/testing/nohup.out
8.0K work/testing/testing_c.php
12K work/testing/testing_func_reg.php
8.0K work/testing/testing_get.php
8.0K work/testing/testing_g.php
8.0K work/testing/var.php

[Root@bsso yayu]# du-h--max-depth=1 work/testing/logs/
27M work/testing/logs/

[Root@bsso yayu]# du-h--max-depth=1 work/testing/logs/*
24K Work/testing/logs/errdate.log_show.log
8.0K Work/testing/logs/pertime_show.log
27M Work/testing/logs/show.log

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.