View File and folder size in CentOS

Source: Internet
Author: User

View File and folder size in CentOS
1. centos File Viewing command

Even though you do not need to focus on the size of files such as output logs, it is wise to know the df and du commands and help you locate the problem.

Df allows you to view the size, usage ratio, file system, and its mount point of a level-1 folder, but there is nothing to do with the file. It can be thought of as a system level.
Du allows you to view the file and folder size.

They are very effective when used in combination. For example, you can use df to check which level directory is too large, and then use df to view the size of the folder or file, so that you can quickly determine the crux of the problem.

2. Specific operation commands

The following is a brief introduction:

The df command can display the available space and usage of all file systems. See the following example:

[dddd@dddd0101780922251.et2 /home/admin/dddd/logs/info]$df -hFilesystem Size Used Avail Use% Mounted on/dev/xvda1 60G 4.2G 53G 8% /tmpfs 7.9G 264K 7.9G 1% /dev/shm/dev/xvdb1 500G 30G 446G 7% /home

The-h Parameter indicates that "Human-readable" is used for output, that is, the file system uses readable formats such as GB and MB.

The first field output (Filesystem) and the last field (Mounted on) are respectively the File System and Its mount point. We can see that the/dev/sda1 partition is mounted under the root directory.

The following four fields: Size, Used, Avail, and Use % are the capacity, Used Size, remaining Size, and percentage of the shard. In FreeBSD, when the hard disk capacity is full, you may see that the percentage used exceeds 100%, because FreeBSD will leave some space for the root user to make the root user full in the file system, you can also write something to the file system for management.

Du: queries the disk space used by files or folders.

If there are many files and folders in the current directory, you can use the command without the du parameter to list the space used by all files and folders cyclically. This is not good for checking whether the location is too large. Therefore, you must specify the number of layers in the directory. The parameter is-max-depth =, which is a very useful parameter! As shown in the following figure. Use "*" to obtain the space used by the file.

Reminder: FreeBSD, which is always more complex than linux, uses the "du" command to specify the number of layers in the directory, which is simpler than that in linux. It is-d.

View the size of each folder in the current folder. Run the command du-h-max-depth = 1 *

[dddd@dddd010178092151.et2 /home/admin/dddd/logs]$lsdebug error info middleware rus-api-services_deploy.log[dddd@dddd010178092151.et2 /home/admin/dddd/logs]$du -h --max-depth=1 *19G debug296M error1.3G info0 middleware4.0K dddd_deploy.log

View the size of each file under a specific folder in the same way. Enter the folder and execute the preceding command.

[dddd@dddd010178092121.et2 /home/admin/dddd/logs/error]$du -h --max-depth=1 *8.0K GaoKuai2YongHu_Error672K GaoKuai2YongHu_Error.2016-02-22 316K GaoKuai2YongHu_Error.2016-02-2320K GaoKuai2YongHu_Error.2016-03-0220K GaoKuai2YongHu_Error.2016-03-084.0K GaoKuai2YongHu_Error.2016-03-254.0K GaoKuai2YongHu_Error.2016-03-304.0K GaoKuai2YongHu_Error.2016-03-314.0K GaoKuai2YongHu_Error.2016-04-064.0K GaoKuai2YongHu_Error.2016-04-0724K GaoKuai2YongHu_Error.2016-04-12200K GaoKuai2YongHu_Error.2016-04-25428K GaoKuai2YongHu_Error.2016-04-264.0K GaoKuai2YongHu_Error.2016-04-294.0K GaoKuai2YongHu_Error.2016-05-054.0K GaoKuai2YongHu_Error.2016-05-174.0K GaoKuai2YongHu_Error.2016-05-184.0K GaoKuai2YongHu_Error.2016-05-2060K GaoKuai2YongHu_Error.2016-05-234.0K GaoKuai2YongHu_Error.2016-05-274.0K GaoKuai2YongHu_Error.2016-05-30292K GaoKuai2YongHu_Error.2016-05-310 GaoKuai2YongHu_Error.2016-06-144.0K GaoKuai2YongHu_Error.2016-06-218.0K GaoKuai2YongHu_Error.2016-06-29294M GaoKuai2YongHu_Error.2016-07-124.0K GaoKuai2YongHu_Error.2016-07-14
3. Summary

1. df-h is used to check the system file structure and size.

2. Check the file size with du-h-max-depth = 1 *

These two methods are sufficient to meet basic daily needs.

4. References

1. view the file and folder size in Linux

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.