View memory usage
free -b | -k | -m | -g
represents the usage rate in units ofBYTE
KB
MB
GB
respectivelytop
Dynamically view memory usage
Check disk usage
- fdisk for creating and maintaining partitions
fdisk -l
View all partitions - df View disk usage statistics.
du View actual disk space usage.
du == disk usage (磁盘使用量,占用的磁盘空间) du 的基本使用 du -s #s参数是可以统计占硬盘空间大小的 如 du -skh b.txt -k或--kilobytes 以1024 bytes为单位。 -h或--human-readable 以K,M,G为单位,提高信息的可读性 -s或--summarize 统计目录或文件
$$ 文件磁盘占用空间 ≠ 文件大小 $$
The Linux file system has the concept of 'block'. Generally, the default block size is 4k, that is, a file is only 1byte in size, so it will still occupy one block by itself. If the file is 6k, it will occupy two blocks. In a linux system with a block size of 4k, the disk space occupied by each file will be n*4k, so in general, the disk usage of a file will be higher than the actual size of the file (0k~4k).
Use the commandls -l
view the actual size of the file, and usedu
view the disk occupancy of the file.
But there are also special cases, when the file has a relatively large 'black hole', the occupied space of the disk will be smaller than the actual size of the file黑洞产生的原因 在向一个文件中写数据的时候,文件偏移量可以大于文件的当前长度,在这种情况下, 对该文件的下一次写将加长该文件,并在文件中构成一个空洞,这一定是允许的。 位于文件中但没有写过的字节都被读为0.文件中的空洞并不要求在磁盘上占用存储区。 具体处理方式与文件系统的实现有关,当定位超出文件尾端之后写时,对于新写的数据 需要分配磁盘块,但是对于原文件尾端和新开始写位置之间的部分则不需要分配磁盘块。 例如: 用dd if=/dev/zero of=a.out seek=1023 bs=1M count=1创建a.out文件后, 用ls查看a.out的文件大小为1G,用du查看a.out文件大小为1M。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。