In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
How do I check the actual size of the Linux directory file? This article uses an example display to introduce in detail the use of the command to obtain and view file size, which can be used for reference by interested friends. I hope it will be helpful to you.
What is the du command?
The du command indicates disk utilization (Disk Usage). This is a standard Unix program for estimating file space usage in the current working directory.
It uses recursion to summarize disk usage to get the size of the directory and its subdirectories.
As I said, when using the ls command, the directory size shows only 4KB. See the output below.
$ls-lh | grep ^ ddrwxr-xr-x 3 daygeek daygeek 4.0K Aug 2 13:57 Bank_Detailsdrwxr-xr-x 2daygeek daygeek 4.0K Mar 15 2019 daygeekdrwxr-xr-x 6 daygeek daygeek 4.0K Feb 16 2019 drive-2daygeekdrwxr-xr-x 13 daygeek daygeek 4.0K Jan 6 2019 drive-mageshmdrwxr-xr-x 15 daygeek daygeek 4.0K Sep 29 21:32 Thanu_Photos
1) how to get only the size of the parent directory on Linux
Use the following du command format to get the total size of a given directory. In this example, we will get the total size of the / home/daygeek/Documents directory.
$du-hs / home/daygeek/Documents
Or
$du-h-max-depth=0 / home/daygeek/Documents/20G / home/daygeek/Documents
Details:
Du.-that's an order.
-h-displays the size in an easy-to-read format (for example, 1K 234m 2G)
-s-displays only the total number of each parameter
-- max-depth=N-the print depth of the directory
2) how to get the size of each directory on Linux
Use the following du command format to get the total size of each directory, including subdirectories.
In this example, we will get the total size of each / home/daygeek/Documents directory and its subdirectories.
$du-h / home/daygeek/Documents/ | sort-rh | head-2020g / home/daygeek/Documents/9.6G / home/daygeek/Documents/drive-2daygeek6.3G / home/daygeek/Documents/Thanu_Photos5.3G / home/daygeek/Documents/Thanu_Photos/Camera5.3G / home/daygeek/Documents/drive-2daygeek/Thanu-videos3.2G / home/daygeek/Documents/drive-mageshm2.3G / home/daygeek/Documents/drive-2daygeek/ Thanu-Photos2.2G / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month916M / home/daygeek/Documents/drive-mageshm/Tanisha454M / home/daygeek/Documents/drive-mageshm/2g-backup415M / home/daygeek/Documents/Thanu_Photos/WhatsApp Video300M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Jan-2017288M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-2017226M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Sep-2017219M / home/daygeek/Documents/Thanu_Photos/WhatsApp Documents213M / home/daygeek/Documents/drive-mageshm/photos163M / home/daygeek/Documents/Thanu_Photos/WhatsApp Video/Sent161M / home/daygeek/Documents/Thanu_Photos/WhatsApp Images154M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/June-2017150M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Nov-2016
3) how to get a summary of each directory on Linux
Use the following du command format to get only the summary of each directory.
$du-hs / home/daygeek/Documents/* | sort-rh | head-109.6G / home/daygeek/Documents/drive-2daygeek6.3G / home/daygeek/Documents/Thanu_Photos3.2G / home/daygeek/Documents/drive-mageshm756K / home/daygeek/Documents/Bank_Details272K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-TouchInterface1.png172K / home/daygeek/Documents/user-friendly-zorin-os-15 -has-been-released-NightLight.png164K / home/daygeek/Documents/ConfigServer Security and Firewall (csf) Cheat Sheet.pdf132K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-Todo.png112K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-ZorinAutoTheme.png96K / home/daygeek/Documents/distro-info.xlsx
4) how to get the size of each directory without subdirectories on Linux
Use the following du command format to show the total size of each directory, excluding subdirectories.
$du-hS / home/daygeek/Documents/ | sort-rh | head-205.3G / home/daygeek/Documents/Thanu_Photos/Camera5.3G / home/daygeek/Documents/drive-2daygeek/Thanu-videos2.3G / home/daygeek/Documents/drive-2daygeek/Thanu-Photos1.5G / home/daygeek/Documents/drive-mageshm831M / home/daygeek/Documents/drive-mageshm/Tanisha454M / home/daygeek/Documents/drive-mageshm/2g-backup300M / home/ Daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Jan-2017288M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-2017253M / home/daygeek/Documents/Thanu_Photos/WhatsApp Video226M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Sep-2017219M / home/daygeek/Documents/Thanu_Photos/WhatsApp Documents213M / home/daygeek/Documents/drive-mageshm/photos163M / home/daygeek/Documents/ Thanu_Photos/WhatsApp Video/Sent154M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/June-2017150M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Nov-2016127M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Dec-2016100M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-201694M / home/daygeek/Documents/drive-2daygeek/Thanu-photos -by-month/Nov-201792M / home/daygeek/Documents/Thanu_Photos/WhatsApp Images90M / home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Dec-2017
5) how to get the size of only one level of subdirectories on Linux
If you want to get the size of a first-level subdirectory (including its subdirectories) of a given directory on Linux, use the following command format.
$du-h-max-depth=1 / home/daygeek/Documents/3.2G / home/daygeek/Documents/drive-mageshm4.0K / home/daygeek/Documents/daygeek756K / home/daygeek/Documents/Bank_Details9.6G / home/daygeek/Documents/drive-2daygeek6.3G / home/daygeek/Documents/Thanu_Photos20G / home/daygeek/Documents/
6) how to get the total in the output of du command
If you want to get the totals in the du command output, use the following du command format.
$du-hsc / home/daygeek/Documents/* | sort-rh | head-1020g total9.6G / home/daygeek/Documents/drive-2daygeek6.3G / home/daygeek/Documents/Thanu_Photos3.2G / home/daygeek/Documents/drive-mageshm756K / home/daygeek/Documents/Bank_Details272K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-TouchInterface1.png172K / home/daygeek/Documents/user-friendly-zorin-os -15-has-been-released-NightLight.png164K / home/daygeek/Documents/ConfigServer Security and Firewall (csf) Cheat Sheet.pdf132K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-Todo.png112K / home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-ZorinAutoTheme.png
After reading the above, have you mastered the method of checking the actual size of the Linux directory file? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.