使用到的是df命令。
先看一下df命令的说明:
df - report filesystem disk space usage
SYNOPSIS
df [OPTION]... [FILE]...
DESCRIPTION
This manual page documents the GNU version of df. df displays the
amount of disk space available on the filesystem containing each file
name argument. If no file name is given, the space available on all
currently mounted filesystems is shown. Disk space is shown in 1K
blocks by default, unless the environment variable POSIXLY_CORRECT is
set, in which case 512-byte blocks are used.
If an argument is the absolute file name of a disk device node con-
taining a mounted filesystem, df shows the space available on that
filesystem rather than on the filesystem containing the device node
(which is always the root filesystem). This version of df cannot show
the space available on unmounted filesystems, because on most kinds of
systems doing so requires very nonportable intimate knowledge of
filesystem structures.
OPTIONS
Show information about the filesystem on which each FILE resides, or
all filesystems by default.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
include filesystems having 0 blocks
-B, --block-size=SIZE use SIZE-byte blocks
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si
likewise, but use powers of 1000 not 1024
-i, --inodes
list inode information instead of block usage
-k like --block-size=1K
-l, --local
limit listing to local filesystems
--no-sync
do not invoke sync before getting usage info (default)
-P, --portability
use the POSIX output format
--sync invoke sync before getting usage info
-t, --type=TYPE
limit listing to filesystems of type TYPE
-T, --print-type
print filesystem type
-x, --exclude-type=TYPE
limit listing to filesystems not of type TYPE
-v (ignored)
学习开始:Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 7218432 1957704 4894048 29% /
none 0 0 0 - /proc
none 0 0 0 - /sys
none 0 0 0 - /dev/pts
none 517292 0 517292 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
[root@CentOS4 ~]# df -aT
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext2 7218432 1957704 4894048 29% /
none proc 0 0 0 - /proc
none sysfs 0 0 0 - /sys
none devpts 0 0 0 - /dev/pts
none tmpfs 517292 0 517292 0% /dev/shm
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
[root@CentOS4 ~]# df -a -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext2 7218432 1957704 4894048 29% /
none proc 0 0 0 - /proc
none sysfs 0 0 0 - /sys
none devpts 0 0 0 - /dev/pts
none tmpfs 517292 0 517292 0% /dev/shm
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
[root@CentOS4 ~]# df -a -t
df: option requires an argument -- t
Try `df --help' for more information.
[root@CentOS4 ~]# df -a -t -T
Filesystem 1K-blocks Used Available Use% Mounted on
上面我们可以发现命令[root@CentOS4 ~]# df -aT与[root@CentOS4 ~]# df -a -T等效。
显示指定文件系统的空间使用情况
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 7218432 1957704 4894048 29% /
人性化显示各存储空间大小
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 6.9G 1.9G 4.7G 29% /
none 0 0 0 - /proc
none 0 0 0 - /sys
none 0 0 0 - /dev/pts
none 506M 0 506M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
[root@CentOS4 ~]# df -a -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 6.9G 1.9G 4.7G 29% /
none 0 0 0 - /proc
none 0 0 0 - /sys
none 0 0 0 - /dev/pts
none 506M 0 506M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
有时候挂载了网络文件系统,若只想看本机的文件系统用如下命令
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext2 6.9G 1.9G 4.7G 29% /
none proc 0 0 0 - /proc
none sysfs 0 0 0 - /sys
none devpts 0 0 0 - /dev/pts
none tmpfs 506M 0 506M 0% /dev/shm
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
也可以这样写:
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext2 6.9G 1.9G 4.7G 29% /
none proc 0 0 0 - /proc
none sysfs 0 0 0 - /sys
none devpts 0 0 0 - /dev/pts
none tmpfs 506M 0 506M 0% /dev/shm
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
还可以这样写:
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext2 6.9G 1.9G 4.7G 29% /
none proc 0 0 0 - /proc
none sysfs 0 0 0 - /sys
none devpts 0 0 0 - /dev/pts
none tmpfs 506M 0 506M 0% /dev/shm
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
查看某个文件系统的磁盘使用情况
Filesystem Size Used Avail Use% Mounted on
none 506M 0 506M 0% /dev/shm
问题,要是想查一个目录文件的大小怎么办,找了资料,命令du可以检查目录空间大小,这安排下一次学习,现在已经深夜12点了,休息。