1 Check the file size
Check the size of all files in the current folder (including subfolders)
du -sh shows the total size of
194M .
du -h shows the size of each file separately
15M ./package
16K ./.fontconfig
4.0K ./.cache
5.1M ./.rpmdb
20M .
View the size of all files in the specified folder (including subfolders)
# 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-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 size of the specified folder
du -hs ftp .3G
ftp
usage: du [options]... [files]... or: du [options]... --files0-from=F , calculate the disk usage for each file, and take the total usage for the directory.
Parameters that are required for long options are also required for short options.
-a, --all print disk usage for all files, not just directories
--apparent-size show apparent usage, not disk usage; although apparent usage is usually
smaller, it can sometimes be "holes", internal fragmentation, non-directly referenced blocks, etc.
-B, --block-size=size use specified number of bytes of blocks
-b, --bytes equal to --apparent-size --block-size=1
-c, --total show total information
-D, -- dereference-args Dereference the symbolic links listed on the command line
--files0-from=F Calculate the disk space occupied by NUL-terminated file names in file F
If the value of F is "-", read the file from standard input name
-H equals to --dereference-args (-D)
-h, --human-readable display size in a more readable way (eg: 1K 234M 2G)
--si like -h, but used in calculations 1000 is the base instead of 1024
-k is equal to --block-size=1K
-l, --count-links If it is a hard link, calculate its size multiple times
-m is equal to --block-size=1M
-L, --dereference find out the real destination indicated by any symlink
-P, --no-dereference do not follow any symlink (default)
-0, --null treat each empty line as 0 bytes instead of newline
-S, --separate-dirs exclude subdirectory usage
-s, --summarize only calculate the total usage of each parameter in the command line separately
-x, --one-file-system skip at directories on different filesystems
-X, --exclude-from=files exclude files matching the pattern described in the specified file
--exclude=PATTERN exclude files matching the pattern described in PATTERN
--max-depth=N Display the total number of directories (used with --all to calculate the file)
when N is the specified value, the calculation depth is N;
--max-depth=0 is equal to --summarize
--time Display the last of all files in a directory or subdirectories of this directory Modification time
--time=WORD Display WORD time instead of modification time:
atime, access, use, ctime or status
--time-style=style displays the time according to the specified style (the style interpretation rules are the same as the "date" command):
full-iso, long-iso, iso, +FORMAT
--help show this help information and exit
--version show version information and exit
[size] can be in the following units (an integer can be added before the unit):
kB 1000, K 1024, MB 1000000, M 1048576, and G, T, P, E, Z, Y.
Please report bugs to du
GNU coreutils project homepage: <http://www.gnu.org/software/coreutils/>
GNU software general help: <http://www.gnu.org/gethelp/>
Please contact <http://www.gnu.org/gethelp/> http://translationproject.org/team/zh_CN.html> Report the translation error of du
2 Ubuntu Check the disk space size command
df -h Df command is the Linux system to check the file system in the unit of disk partition, you can add parameters to check the remaining disk space Space information, command format: df -hl The display format is: Filesystem Size Used Avail Use% Mounted on /dev/hda2 45G 19G 24G 44% / /dev/hda1 494
df - The h
Df command is to view the file system in the unit of disk partition in the Linux system. You can add parameters to view the remaining space information of the disk. The command format is:
df -hl
The display format is:
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.5 G 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 above output as an example, it means:
the second hard disk (b) of the HD hard disk interface, the second partition (2), the capacity is 75G , using 75G, available is 0, so the utilization is 100%, is mounted on the root partition directory (/).
The following is an explanation of the relevant commands:
df -hl View the remaining space on the disk
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 number of the folder
More functions can be viewed by entering the following command:
df --help
du --help
(responsible editor: admin)
3 Deleting the log file
Today, I saw that the company's linux server did not put anything, but 50% of it was used. When I checked 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 can be recommended to use
sudo find /var/log/ -type f -mtime +30 -exec rm -f {} \;
delete old files before 30 days
linux-system view folder size, view disk space size command
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326538551&siteId=291194637
Recommended
Ranking