首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

linux du下令学习

2013-10-11 
linux du命令学习linux du命令用来查看磁盘空间的使用情况。1. 通过du命令查看/bin目录下各个命令所占用的

linux du命令学习

linux du命令用来查看磁盘空间的使用情况。

1. 通过du命令查看/bin目录下各个命令所占用的存储空间,
sh-# du -ah /bin/ | sort -nr
933K    /bin/
676K    /bin/busybox
25K     /bin/fw_printenv
5.0K    /bin/mountpoint
0       /bin/xargs
0       /bin/umount
0       /bin/touch
0       /bin/top
0       /bin/tar
0       /bin/sysctl
0       /bin/sync
0       /bin/stty
0       /bin/sort
0       /bin/sleep
0       /bin/sh
0       /bin/sed
0       /bin/route
0       /bin/rmmod
0       /bin/rm
0       /bin/pwd
0       /bin/ps
0       /bin/ping6
0       /bin/ping
0       /bin/nice
0       /bin/mv
0       /bin/mount.static
0       /bin/mount
0       /bin/modprobe
0       /bin/mknod
0       /bin/mkdir
0       /bin/lsmod
0       /bin/ls
0       /bin/login
0       /bin/ln
0       /bin/kill
0       /bin/insmod
0       /bin/ifconfig
0       /bin/hostname
0       /bin/head
0       /bin/gzip
0       /bin/grep
0       /bin/getopt
0       /bin/find
0       /bin/echo
0       /bin/du
0       /bin/dmesg
0       /bin/dirname
0       /bin/depmod
0       /bin/date
0       /bin/cp
0       /bin/chrt
0       /bin/chmod
0       /bin/cat
0       /bin/blkid.static
0       /bin/blkid
0       /bin/bash
0       /bin/basename
0       /bin/awk
0       /bin/arping
0       /bin/agetty
sh-#

2. 为什么有很多命令占用的空间大小为0呢?
使用ls命令查看,原来这些大小为0的命令都是symbolic link;
可以看到ls命令也能查看档案所占用的磁盘空间大小。
sh-# ls -lh /bin/
total 933K
lrwxrwxrwx 1 root root   19 Oct 10 01:29 agetty -> /openbox/bin/agetty
lrwxrwxrwx 1 root root   19 Oct 10 01:29 arping -> /openbox/bin/arping
lrwxrwxrwx 1 root root   16 Oct 10 01:29 awk -> /openbox/bin/awk
lrwxrwxrwx 1 root root   21 Oct 10 01:29 basename -> /openbox/bin/basename
lrwxrwxrwx 1 root root   17 Oct 10 01:29 bash -> /openbox/bin/bash
lrwxrwxrwx 1 root root   12 Oct 10 01:29 blkid -> /bin/busybox
lrwxrwxrwx 1 root root   25 Oct 10 01:29 blkid.static -> /openbox/bin/blkid.static
-rwxr-xr-x 1 root root 676K Oct 10 01:29 busybox
lrwxrwxrwx 1 root root   16 Oct 10 01:29 cat -> /openbox/bin/cat
lrwxrwxrwx 1 root root   18 Oct 10 01:29 chmod -> /openbox/bin/chmod
lrwxrwxrwx 1 root root   17 Oct 10 01:29 chrt -> /openbox/bin/chrt
lrwxrwxrwx 1 root root   15 Oct 10 01:29 cp -> /openbox/bin/cp
lrwxrwxrwx 1 root root   17 Oct 10 01:29 date -> /openbox/bin/date
lrwxrwxrwx 1 root root   19 Oct 10 01:29 depmod -> /openbox/bin/depmod
lrwxrwxrwx 1 root root   20 Oct 10 01:29 dirname -> /openbox/bin/dirname
lrwxrwxrwx 1 root root   18 Oct 10 01:29 dmesg -> /openbox/bin/dmesg
lrwxrwxrwx 1 root root   15 Oct 10 01:29 du -> /openbox/bin/du
lrwxrwxrwx 1 root root   17 Oct 10 01:29 echo -> /openbox/bin/echo
lrwxrwxrwx 1 root root   17 Oct 10 01:29 find -> /openbox/bin/find
-rwxr-xr-x 1 root root  25K Oct 10 01:30 fw_printenv
lrwxrwxrwx 1 root root   19 Oct 10 01:29 getopt -> /openbox/bin/getopt
lrwxrwxrwx 1 root root   17 Oct 10 01:29 grep -> /openbox/bin/grep
lrwxrwxrwx 1 root root   17 Oct 10 01:29 gzip -> /openbox/bin/gzip
lrwxrwxrwx 1 root root   17 Oct 10 01:29 head -> /openbox/bin/head
lrwxrwxrwx 1 root root   21 Oct 10 01:29 hostname -> /openbox/bin/hostname
lrwxrwxrwx 1 root root   21 Oct 10 01:29 ifconfig -> /openbox/bin/ifconfig
lrwxrwxrwx 1 root root   19 Oct 10 01:29 insmod -> /openbox/bin/insmod
lrwxrwxrwx 1 root root   17 Oct 10 01:29 kill -> /openbox/bin/kill
lrwxrwxrwx 1 root root   15 Oct 10 01:29 ln -> /openbox/bin/ln
lrwxrwxrwx 1 root root   18 Oct 10 01:29 login -> /openbox/bin/login
lrwxrwxrwx 1 root root   15 Oct 10 01:29 ls -> /openbox/bin/ls
lrwxrwxrwx 1 root root   18 Oct 10 01:29 lsmod -> /openbox/bin/lsmod
lrwxrwxrwx 1 root root   18 Oct 10 01:29 mkdir -> /openbox/bin/mkdir
lrwxrwxrwx 1 root root   18 Oct 10 01:29 mknod -> /openbox/bin/mknod
lrwxrwxrwx 1 root root   21 Oct 10 01:29 modprobe -> /openbox/bin/modprobe
lrwxrwxrwx 1 root root   25 Oct 10 01:29 mount -> /openbox/bin/mount.static
lrwxrwxrwx 1 root root   25 Oct 10 01:29 mount.static -> /openbox/bin/mount.static
-rwxr-xr-x 1 root root 5.0K Oct 10 01:29 mountpoint
lrwxrwxrwx 1 root root   15 Oct 10 01:29 mv -> /openbox/bin/mv
lrwxrwxrwx 1 root root   17 Oct 10 01:29 nice -> /openbox/bin/nice
lrwxrwxrwx 1 root root   17 Oct 10 01:29 ping -> /openbox/bin/ping
lrwxrwxrwx 1 root root   18 Oct 10 01:29 ping6 -> /openbox/bin/ping6
lrwxrwxrwx 1 root root   15 Oct 10 01:29 ps -> /openbox/bin/ps
lrwxrwxrwx 1 root root   16 Oct 10 01:29 pwd -> /openbox/bin/pwd
lrwxrwxrwx 1 root root   15 Oct 10 01:29 rm -> /openbox/bin/rm
lrwxrwxrwx 1 root root   18 Oct 10 01:29 rmmod -> /openbox/bin/rmmod
lrwxrwxrwx 1 root root   18 Oct 10 01:29 route -> /openbox/bin/route
lrwxrwxrwx 1 root root   16 Oct 10 01:29 sed -> /openbox/bin/sed
lrwxrwxrwx 1 root root   17 Oct 10 01:29 sh -> /openbox/bin/bash
lrwxrwxrwx 1 root root   18 Oct 10 01:29 sleep -> /openbox/bin/sleep
lrwxrwxrwx 1 root root   17 Oct 10 01:29 sort -> /openbox/bin/sort
lrwxrwxrwx 1 root root   17 Oct 10 01:29 stty -> /openbox/bin/stty
lrwxrwxrwx 1 root root   17 Oct 10 01:29 sync -> /openbox/bin/sync
lrwxrwxrwx 1 root root   19 Oct 10 01:29 sysctl -> /openbox/bin/sysctl
lrwxrwxrwx 1 root root   16 Oct 10 01:29 tar -> /openbox/bin/tar
lrwxrwxrwx 1 root root   16 Oct 10 01:29 top -> /openbox/bin/top
lrwxrwxrwx 1 root root   18 Oct 10 01:29 touch -> /openbox/bin/touch
lrwxrwxrwx 1 root root   18 Oct 10 01:29 xargs -> /openbox/bin/xargs
sh-#

3. 使用df命令可以查看整个文件系统的磁盘空间使用状况,
sh-# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                42.0M     42.0M         0 100% /
none                    144.0M    484.0K    143.5M   0% /tmp
none                    144.0M         0    144.0M   0% /opt
/dev/sda1                 3.7G    219.7M      3.5G   6% /tmp/mnt/usb/sda1
sh-#

4. 使用stat命令可以查看指定档案所占用的磁盘空间或者档案所在的文件系统的磁盘空间使用状况,
sh-# stat /bin/
  File: "/bin/"
  Size: 925             Blocks: 0          IO Block: 4096   directory
Device: fe00h/65024d    Inode: 43          Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-10-10 01:30:00.000000000
Modify: 2013-10-10 01:30:00.000000000
Change: 2013-10-10 01:30:00.000000000

sh-#
sh-# stat -f /bin/
  File: "/bin/"
    ID: fe0000000000 Namelen: 256     Type: squashfs
Block size: 131072
Blocks: Total: 336        Free: 0          Available: 0
Inodes: Total: 1332       Free: 0
sh-#

热点排行