In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the du command of the Linux system". 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!
There are some differences between du and df. Du is mainly used to view the disk space occupied by files and directories and to output the estimated amount of disk space used by specified files or directories.
How to use the du command the general syntax of the du command is as follows:
Du [OPTIONS]... FILE... If a given FILE is a directory, du summarizes the disk usage of each file and subdirectory in that directory. If not specified by FILE, du reports the disk usage of the current working directory.
When executed without any option du, disk usage for a given file or directory and each of its subdirectories is displayed in bytes.
$du ~ / Documents you can also pass multiple files and directories as parameters to the du command:
$du ~ / Documents ~ / Pictures ~ / .zshrc if you run the du command in a file or directory that you don't have permission for, something like "du: cannot read directory" will appear. In this case, you need to add sudo before the command.
There are many options for du, and we will outline the most commonly used options.
The-an option tells du that you report disk space usage for each file in the directory.
$du-a ~ / Documents typically, you want to display only the space occupied by a given directory in a human-readable format. To do this, use the-h option.
For example, to get the total size of / var/lib 's subdirectories and all of their subdirectories, run the following command:
$sudo du-h / var/lib We used sudo because most of the files and directories in the / var/lib directory are owned by root users and cannot be read by ordinary users. The output looks like this:
... 4.0K / var/lib/apt/mirrors/partial 8.0K / var/lib/apt/mirrors 205m / var/lib/apt 2.9g / var/lib/ to output only the total size of the specified directory and not the total size of the subdirectories, use the following-s option:
The $sudo du-sh / var 2.9g / var-c option tells du to report the total. This is useful when you want to get the combined size of two or more directories.
$sudo du-csh / var/log / var/lib 1.2g / var/log 2.9g / var/lib 4.1g total if you want to display disk usage of n-level subdirectories, use the-- max-depth option and specify the subdirectory level. For example, to get a report on the first-level directory you will use:
The default behavior of the $sudo du-h-- max-depth=1 / var/lib... 544K / var/lib/usbutils 4.0K / var/lib/acpi-support 205m / var/lib/apt 2.9g / var/libdu utility is to retrieve the disk space used by the directory or file. To find the apparent size of the file, use the-- apparent-size switch. The "apparent size" of the file is the amount of data that actually exists in the file.
$sudo du-sh-- apparent-size / var/lib 2.9g / var/libdu also allows you to use shell mode. For example, to get the size of all directories starting with "Do" in the home directory, you will run:
$sudo du-csh ~ / Do* 102m / home/linuxize/Documents 358m / home/linuxize/Downloads 460m total use du with other commands du commands can be used with other commands for pipes.
For example, to print the five largest directories in the / var directory, you can pass the output du to the sort command to sort the directories by their size, and then pipe the output to the head command that prints only the first five directories:
$sudo du-h / var/ | sort-rh | head-54.6g / var/ 2.9g / var/lib 2.6g / var/lib/snapd 1.7g / var/lib/snapd/snaps 1.2g / var/log/journal/af8ce1d394b844fea8c19ea5c6a9bd09 "how to use the du command of the Linux system", 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.