Ubuntu 查看分区内文件及文件夹占用大小
查看磁盘占用
vanjay@VanJay:~$ df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 3.9G 0 3.9G 0% /dev
tmpfs 789M 2.0M 787M 1% /run
/dev/sdb5 9.4G 8.0G 926M 90% /
tmpfs 3.9G 31M 3.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 88M 88M 0 100% /snap/core/5662
/
分区空间都哪去了?
vanjay@VanJay:~$ sudo du -hsx /* | sort -rh | head -n 40
16G /home
3.9G /usr
2.4G /var
792M /lib
451M /swapfile
252M /opt
140M /boot
21M /root
14M /etc
13M /bin
12M /sbin
2.0M /run
132K /tmp
40K /snap
16K /lost+found
8.0K /media
4.0K /srv
4.0K /mnt
4.0K /lib64
4.0K /cdrom
0 /vmlinuz.old
0 /vmlinuz
0 /sys
0 /proc
0 /initrd.img.old
0 /initrd.img
0 /dev
home
分区被什么占用了?
vanjay@VanJay:~$ sudo du -hsx /home/* | sort -rh | head -n 35
7.8G /home/data
7.6G /home/vanjay
16K /home/lost+found
交互式查看
安装库
sudo apt install ncdu
比如查看/分区
ncdu 1.12 ~ Use the arrow keys to navigate, press ? for help
--- / ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3.9 GiB [##########] /usr
2.4 GiB [###### ] /var
791.2 MiB [# ] /lib
450.6 MiB [# ] swapfile
251.2 MiB [ ] /opt
139.8 MiB [ ] /boot
20.7 MiB [ ] /root
13.7 MiB [ ] /etc
12.3 MiB [ ] /bin
11.3 MiB [ ] /sbin
3.6 MiB [ ] .__deepin.lft
132.0 KiB [ ] /tmp
40.0 KiB [ ] /snap
e 16.0 KiB [ ] /lost+found
8.0 KiB [ ] /media
4.0 KiB [ ] /lib64
e 4.0 KiB [ ] /srv
e 4.0 KiB [ ] /mnt
e 4.0 KiB [ ] /cdrom
4.0 KiB [ ] .__deepin.num
@ 0.0 B [ ] initrd.img.old
@ 0.0 B [ ] initrd.img
@ 0.0 B [ ] vmlinuz.old
@ 0.0 B [ ] vmlinuz
> 0.0 B [ ] /sys
> 0.0 B [ ] /run
> 0.0 B [ ] /proc
> 0.0 B [ ] /home
> 0.0 B [ ] /dev
Total disk usage: 7.9 GiB Apparent size: 7.8 GiB Items: 209677
可使用方向键逐级查看