一,内存单位转换
Byte 字节的意思
B是一个电脑存储的基本单位(字节);
1个英文字符是1个字节,也就是1B;
1个汉字为2个字符,也就是2B;
1024B=1KB
1024KB=1MB
1024MB=1GB
1024GB=1TB
二,命令df
-
命令语法 df [选项] [参数]
-
命令描述 df命令用于显示已挂载磁盘的总容量,使用容量,剩余容量等,可以不加任何参数,默认显示单位为KB
-
命令选项 -h:使用合适的单位显示 -i:查看inodes使用情况 -k:以KB为单位显示 -m:以MB为单位显示
df 命令示例
[root@localhost ~]# df
文件系统 1K-块 已用 可用 已用
/dev/mapper/cl-root 18655232 1164384 17490848 7
devtmpfs 493156 0 493156 0
tmpfs 504196 0 504196 0
tmpfs 504196 6868 497328 2
tmpfs 504196 0 504196 0
/dev/sda1 201380 119360 82020 60
tmpfs 100840 0 100840 0
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用
/dev/mapper/cl-root 18G 1.2G 17G 7
devtmpfs 482M 0 482M 0
tmpfs 493M 0 493M 0
tmpfs 493M 6.8M 486M 2
tmpfs 493M 0 493M 0
/dev/sda1 197M 117M 81M 60
tmpfs 99M 0 99M 0
- 选项-i,查看inodes使用情况,如使用到100%,即使磁盘空间有富余,也会提示磁盘空间已满。
[root@localhost ~]# df -i
文件系统 Inode 已用(I) 可用(I) 已用(I)
/dev/mapper/cl-root 9332736 28208 9304528 1
devtmpfs 123289 389 122900 1
tmpfs 126049 1 126048 1
tmpfs 126049 474 125575 1
tmpfs 126049 16 126033 1
/dev/sda1 102400 330 102070 1
tmpfs 126049 1 126048 1
[root@localhost ~]
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/mapper/cl-root 18655232 1164232 17491000 7% /
/dev/sda1 201380 119360 82020 60% /boot
[root@localhost ~]
文件系统 1M-块 已用 可用 已用% 挂载点
/dev/mapper/cl-root 18218 1137 17082 7% /
/dev/sda1 197 117 81 60% /boot
上述示例说明
- 第一列 为分区的名字;
- 第二列 为该分区的总容量;
- 第三列 为使用容量;
- 第四列 为剩余容量;
- 第五列 为使用容量的百分比;
- 第六列 为挂载点;
三,du命令
-
命令语法 du [选项] [参数]
-
命令描述 du命令用来查看某个目录或文件所占空间大小。默认显示单位KB。
-
命令选项 -a:=all,显示全部文件与目录的大小 -b:以byte(B)为单位显示内容 -k:以KB为单位显示内容 -m:以MB为单位显示内容 -h:系统自动调节单位显示内容 -c:最后加总 -s:只列出总和
du命令示例
[root@localhost ~]
4 /root/.ssh
4 /root/dir
0 /root/222
0 /root/dd
56 /root
[root@localhost ~]# du -sh /root
56K /root
[root@localhost ~]# du -sh /etc/passwd
4.0K /etc/passwd
[root@localhost ~]# ls -lh /etc/passwd
-rw-r--r--. 1 root root 1.3K 10月 31 09:18 /etc/passwd
说明: 这里用ls和du分别查看passwd文件的使用大小,du命令显示的4KB(默认情况下,不到4KB以4KB显示,因为一个块是4KB,以后会学到),而ls命令显示的是1.3KB(真实大小)。