磁盘管理基础命令
df:显示磁盘空间使用情况,默认单位为KB 一般常用的是df -h,这个命令会把磁盘空间的单位弄成GB、MB等
[ liyufeng@localhost ~] $ df
文件系统 1K-块 已用 可用 已用% 挂载点
devtmpfs 482112 0 482112 0 % /dev
tmpfs 497852 0 497852 0 % /dev/shm
tmpfs 497852 8768 489084 2 % /run
tmpfs 497852 0 497852 0 % /sys/fs/cgroup
/dev/sda3 18555904 5420116 13135788 30 % /
/dev/sda1 303780 155544 148236 52 % /boot
tmpfs 99572 8 99564 1 % /run/user/42
tmpfs 99572 32 99540 1 % /run/user/1000
[ liyufeng@localhost ~] $ df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 471M 0 471M 0 % /dev
tmpfs 487M 0 487M 0 % /dev/shm
tmpfs 487M 8 .5M 478M 2 % /run
tmpfs 487M 0 487M 0 % /sys/fs/cgroup
/dev/sda3 18G 5 .2G 13G 30 % /
/dev/sda1 297M 152M 145M 52 % /boot
tmpfs 98M 24K 98M 1 % /run/user/1000
[ liyufeng@localhost ~] $
free:显示系统内存情况 常用的是free -m,表示以MB为单位显示内存使用情况
[ liyufeng@localhost ~] $ free
total used free shared buff/cache available
Mem: 995704 672900 64576 19580 258228 159568
Swap: 2097148 52232 2044916
[ liyufeng@localhost ~] $ free -m
total used free shared buff/cache available
Mem: 972 657 62 19 252 155
Swap: 2047 51 1996
[ liyufeng@localhost ~] $
du:查看磁盘占用空间。与df的不同之处在于du是面向某个文件或目录的,而df是面向系统的 常用du -a,显示该目录中所有文件的大小
[ liyufeng@localhost code] $ du
32 .
[ liyufeng@localhost code] $ du -a
4 ./test3.sh
4 ./test4.sh
4 ./test5.sh
4 ./test6.sh
0 ./20220427.txt
4 ./test7.sh
4 ./test8.sh
4 ./test9.sh
4 ./test10.sh
32 .
[ liyufeng@localhost code] $
参数 说明 -l 查看所有分区情况 -l 路径 查看指定分区情况。 -s 将指定的分区大小输出到标准输出上,单位为区块