Ubuntu view files and disk space size management
(1) View file size
View all file sizes (including subfolders) under the current folder
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
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
Usage: du [options] ... [File] ...
Or: du [options] ...--files0-from=f
Calculate the amount of disk per file, and the total amount of the directory.
Parameters that must be used for long options are also required for short options.
-A,--all output the disk usage of all files, not only the directory
--apparent-size shows the surface dosage, not the amount of disk; Although the surface dosage is usually smaller, it can sometimes become larger because of sparse file "holes", internal fragments, and not directly referenced blocks.
-B,--block-size= size uses a block of the specified number of bytes
-B,--bytes equals--apparent-size--block-size=1
-C,--total display totals information
-D,--dereference-args the symbolic connections listed on the command line
--files0-from=f calculates the amount of disk space that is occupied by the filename in Nul at the end of the 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 (e.g. 1K 234M 2G)
--si is similar to-H, but uses 1000 as the base instead of 1024 when calculating
-K equals--block-size=1k
-L,--count-links if it's a hard connection, calculate its dimensions multiple times
-M equals--block-size=1m
-L,--dereference find the true destination of any symbolic link indication
-P,--no-dereference does not follow any symbolic links (default)
-0,--null each blank line as 0 bytes rather than a newline character
-S,--separate-dirs does not include the amount of subdirectories
-S,--summarize only calculates the total amount of each parameter in the command column, respectively
-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 patterns described in pattern
--MAX-DEPTH=N Displays the catalog totals (using a computed file with--all). When n is a specified number, the depth is n;
--max-depth=0 equals--summarize
--time Displays the last modified time of the directory or all files under that directory subdirectory
--time=word displays WORD time, not modified time: Atime,access,use,ctime or status
The--time-style= style displays the time according to the specified style (style interpretation rule and date command): Full-iso,long-iso,iso,+format
--HELP displays this help information and exits
--version display version information and exit [size] can be the following units (preceded by an integer): KB 1000,k 1024,mb 1000000,m 1048576, and G, T, P, E, Z, Y.
Please report the error to Du
GNU coreutils Project Homepage:
GNU Software general help:
Please report the translation error to the
(2) Ubuntu view disk space Size command
Df-h DF command is a Linux system to view the file system in disk partition units, you can add parameters to view the disk remaining space information, command format: DF-HL display format: File system capacity used available% mount point filesystem size Used avail use % mounted On/dev/hda2 45G 19G 24G 44%//dev/hda1 494
The DF command is a Linux system that looks at the file system on a disk partition, and can add parameters to view the disk's remaining space information, in command format:
The display format is:
File system capacity used available% 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%/
Take the above output as an example, the meaning of the expression is:
The second hard drive (b) of the HD hard disk interface, the second partition (2), the capacity is 75G, 75G, usable is 0, so utilization is 100% and is mounted on the root partition directory (/).
The following is an explanation of the relevant commands:
DF-HL View disk remaining space
Df-h View the partition size of each root path
Du-sh [directory Name] Returns the size of the directory
DU-SM [Folder] returns the total m of this folder
More versatile you can enter commands to view:
(3) Delete log files
Today, the company's Linux server did not put anything, but has been used 50%, a view of the original log file is too large, and then manually deleted,
This is faster.
Sudo/dev/null >/var/log/**.log
Here's a recommendation to use
sudo find/var/log/-type f-mtime +30-exec rm-f {} \;
Delete old files from 30 days ago
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.