In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to check the remaining disk space in Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to check the remaining disk space by Linux".
(1) View file size
View all file sizes under the current folder (including subfolders)
Du-sh
# du-h
15M. / package
16K. / .fontconfig
4.0K. / .cache
5.1M. / .rpmdb
20M.
View all file sizes (including subfolders) under the specified folder
# du-h ftp
3.8G ftp/sanya/doc
3.8G ftp/sanya
4.0K ftp/testftp/doc
1.4M ftp/testftp
875m ftp/platform/doc/002- video recording
27M ftp/platform/doc/001-PDF
5.2M ftp/platform/doc/BBFlash
1.2g ftp/platform/doc/003- recording
2.1G ftp/platform/doc
2.1G ftp/platform
4.0K ftp/pmo/doc
20K ftp/pmo
36M ftp/uf/doc/innovate-201207
36M ftp/uf/doc
36M ftp/uf
446M ftp/code/doc
446M ftp/code
6.3G ftp
View the specified file size
# du-h. / package/compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
184K. / package/compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
View the specified folder size
# du-hs ftp
6.3G ftp
Usage: du [option]. [file].
Or: du [options]... -- files0-from=F
Calculate the disk usage of each file, and the directory takes the total amount.
The parameters that must be used for long options are also required for short options.
-a,-- all outputs the disk usage of all files, not just directories
-- apparent-size shows the surface usage, not the disk usage, although the surface usage is usually
It is smaller, but sometimes it is broken because of the "hole" between sparse files.
Chips, blocks that are not directly referenced, and so on.
-B,-- block-size= size using blocks with a specified number of bytes
-b,-- bytes equals-- apparent-size-- block-size=1
-c,-- total displays total information
-D,-- dereference-args removes the symbolic connection listed on the command line
-- files0-from=F calculates the disk space occupied by the file name ending with NUL in file F
If the value of F is "-", the file name is read from standard input
-H equals-- dereference-args (- D)
-h,-- human-readable displays dimensions in a readable manner (for example, 1K 234m 2G)
-- si is similar to-h, but uses 1000 as the base instead of 1024 for calculation
-k equals-- block-size=1K
-l,-- count-links if it is a hard connection, calculate its size several times
-m equals-- block-size=1M
-L,-- dereference finds the real destination indicated by any symbolic link
-P,-- no-dereference does not follow any symbolic links (default)
-0,-- null treats each blank line as 0 bytes rather than newline characters
-S,-- separate-dirs does not include the occupancy of subdirectories
-s,-- summarize only calculates the total amount of each parameter in the command line
-x,-- one-file-system skips directories on different file systems
-X,-- exclude-from= file excludes files that match the pattern described in the specified file
-- exclude=PATTERN excludes files that match the pattern described in PATTERN
-- max-depth=N displays directory totals (using calculation files with-- all)
The calculation depth is N when N is the specified value.
-max-depth=0 equals-summarize
-- time displays the last modification time of all files in the directory or subdirectory of that directory
-- time=WORD displays the WORD time instead of the modification time:
Atime,access,use,ctime or status
-- time-style= style displays the time according to the specified style (the style interpretation rule is the same as the "date" command):
Full-iso,long-iso,iso,+FORMAT
-- help displays this help and exits
-- version displays version information and exits
[size] can be the following units (units can be preceded by integers):
KB 1000 and K 1024 MB 1000000 and M 1048576, as well as G, T, P, E, Z, Y.
Please report the error of du to
GNU coreutils Project Home Page:
General help for GNU software:
Please report the translation error of du to
(2) Ubuntu command to view disk space size
The df-h Df command is used by the linux system to view the file system in terms of disk partitions, and you can add parameters to view the remaining disk space information. The command format: df-hl display format: file system capacity has been used.% available mount point Filesystem Size Used Avail Use% Mounted on / dev/hda2 45G 19G 24G 44% / dev/hda1 494
Df-h
The Df command means that the linux system views the file system in terms of disk partition, and you can add parameters to view the information of the remaining disk space. The command format:
Df-hl
The display format is:
File system capacity used available used% mount point
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% /
Taking the output above as an example, it means:
The second hard disk (b) of the HD hard disk interface, the second partition (2), has a capacity of 75g, uses 75G, and the availability is 0, so the utilization rate is 100%, which is mounted to the root partition directory (/).
The following is an explanation of the relevant commands:
Df-hl to check the remaining disk space
Df-h to view the partition size of each root path
Du-sh [directory name] returns the size of the directory
Du-sm [folder] returns the total number of megabytes in the folder
For more functions, you can enter the command to view:
Df-help
Du-help
(responsible Editor: admin)
(3) Delete log files
Today, I saw that the company's linux server didn't put anything, but it had already used 50%. As soon as I looked at it, it turned out that the log file was too large, so I deleted it manually.
This is faster.
Sudo / dev/null > / var/log/**.log
The following one can be recommended
Sudo find / var/log/-type f-mtime + 30-exec rm-f {}\
Delete old files from 30 days ago
At this point, I believe you have a deeper understanding of "how to check the remaining disk space in Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.