In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to check the size of specified folders and files under Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Df command: view the free space and usage of all current file systems
Df can view the first-level folder size, usage ratio, file system and its mount point, but there is nothing it can do with files.
The code is as follows:
Df-lh
The parameter-h indicates that the output of "Human-readable" is used, that is, easy-to-read formats such as GB, MB, etc. are used in the file system size.
The first field (Filesystem) and the last field (Mounted on) of the above command output are the file system and its mount point, respectively. We can see that the partition / dev/sda1 is hung in the root directory.
The next four fields Size, Used, Avail, and Use% are the capacity, size used, remaining size, and percentage of the partition, respectively.
Du command: query disk usage space for files or folders
If there are many files and folders in the current directory, use the command without the parameter du to cycle through the space used by all files and folders. This is disadvantageous to see which place is too large, so you have to specify the number of layers in the deep directory, the parameter:-max-depth=, this is a very useful parameter! As follows, pay attention to the use of "*" to get the size of the file space.
The code is as follows:
[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
Check the size of the linux file directory and the number of files contained in the folder
The code is as follows:
Du-sh xmldb/ statistics total size
Du-sm * | sort-n / / count the current directory size and sort it
Du-sk * | sort-n
Du-sk * | grep guojf / / look at the size of a person
Du-m | cut-d "/"-f 2 / / look at the text before the second / character
Check how many files there are in this folder / * how many files
The code is as follows:
Du xmldb/
Du xmldb/* | wc-l
The difference between du and df
Add the size of du statistics file
Df statistics block usage
If a process opens a large file and the large file is dropped directly by rm or mv, du will update the statistics, df will not update the statistics, or the space will not be freed. Until the process of opening large files is dropped by Kill.
In this way, when the files under / var/spool/clientmqueue are deleted periodically, if the process is not killed, the space has not been released.
After killing the process with the following command, the system recovers.
Fuser-u / var/spool/clientmqueue
Ls command: view file size in K, M, G units
The code is as follows:
Ls
Ls-l
Ls-lh
Ll-h
This is the end of the content of "how to check the size of specified folders and files under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.