如何查看linux根分区下所有目录及文件的大小
时间:2014-11-15 00:01:54浏览:2723
[root@minimal boot]# pwd
/boot
[root@minimal boot]# ls / |xargs du -sh
du: cannot access `bin': No such file or directory
du: cannot access `boot': No such file or directory
du: cannot access `cgroup': No such file or directory
du: cannot access `dev': No such file or directory
du: cannot access `etc': No such file or directory
du: cannot access `home': No such file or directory
du: cannot access `lib': No such file or directory
13K lost+found
du: cannot access `media': No such file or directory
du: cannot access `mnt': No such file or directory
du: cannot access `opt': No such file or directory
du: cannot access `proc': No such file or directory
du: cannot access `root': No such file or directory
du: cannot access `sbin': No such file or directory
du: cannot access `selinux': No such file or directory
du: cannot access `srv': No such file or directory
du: cannot access `sys': No such file or directory
du: cannot access `tmp': No such file or directory
du: cannot access `usr': No such file or directory
du: cannot access `var': No such file or directory
[root@minimal boot]# cd /
[root@minimal /]# ls |xargs du -sh
5.9M bin
28M boot
4.0K cgroup
480K dev
31M etc
20K home
100M lib
16K lost+found
102M media
64M mnt
2.8G opt
du: cannot access `proc/2533/task/2533/fd/4': No such file or directory
du: cannot access `proc/2533/task/2533/fdinfo/4': No such file or directory
du: cannot access `proc/2533/fd/4': No such file or directory
du: cannot access `proc/2533/fdinfo/4': No such file or directory
0 proc
139M root
9.2M sbin
0 selinux
4.0K srv
0 sys
380K tmp
2.6G usr
116M var
ls与xargs配合使用时,ls只能显示当前的目录,所以要想显示根目录下的文件的大小,必须在根目录下配合使用ls与xargs命令
[root@minimal /]# ls |grep -v proc |xargs du -sh |sort -h
0 selinux
0 sys
4.0K cgroup
4.0K srv
16K lost+found
20K home
380K tmp
492K dev
5.9M bin
9.2M sbin
28M boot
31M etc
64M mnt
100M lib
102M media
116M var
152M root
2.6G usr
2.8G opt
按大小和单一模式显示除proc目录以外的所有根目录下的文件
/proc
这个目录本身是一个『虚拟档案系统』!它放置的数据都是在内存当中, 例如系统核心、形成信息、接口设备的状态及网络状态等等。因为这个目录下的数据都是在内存当中, 所以本身不占任何硬盘空间!
[root@RedHat /]# ls -A |grep -v proc |xargs du -sh |sort -h
0 .autofsck
0 misc
0 net
0 selinux
0 sys
4.0K cgroup
4.0K media
4.0K srv
12K .dbus
16K lost+found
28K mnt
28K tmp
712K dev
7.3M root
7.4M bin
13M sbin
19M boot
33M etc
102M lib
177M var
323M home
2.9G opt
3.6G usr
ls -A显示所有文件但不包括"."和"..";即当前目录和当前目录的父目录。
[root@RedHat /]# ls -a |grep -v proc |xargs du -sh |sort -h
du: cannot access `./proc/9394/task/9394/fd/4': No such file or directory
du: cannot access `./proc/9394/task/9394/fdinfo/4': No such file or directory
du: cannot access `./proc/9394/fd/4': No such file or directory
du: cannot access `./proc/9394/fdinfo/4': No such file or directory
du: cannot access `../proc/9394/task/9394/fd/4': No such file or directory
du: cannot access `../proc/9394/task/9394/fdinfo/4': No such file or directory
du: cannot access `../proc/9394/fd/4': No such file or directory
du: cannot access `../proc/9394/fdinfo/4': No such file or directory
0 .autofsck
0 misc
0 net
0 selinux
0 sys
4.0K cgroup
4.0K media
4.0K srv
12K .dbus
16K lost+found
28K mnt
28K tmp
712K dev
7.3M root
7.4M bin
13M sbin
19M boot
33M etc
102M lib
177M var
323M home
2.9G opt
3.6G usr
7.1G .
7.1G ..
|grep -v proc 不显示proc目录
du -sh 以单一模式显示文件或目录的大小
|sort -h 按从小到大的顺序显示文件列表
上一篇:Linux系统中,如何批量删除某一个文件
下一篇:dedecms {dede:datalist}标签下,if语句的运用!
发表评论
昵称: 验证码: