ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux学习笔记2

Linux学习笔记2

原创 Linux操作系统 作者:wghao 时间:2007-11-16 09:41:41 0 删除 编辑
虽然不能把每一学习点都记录下来,但能记录的尽量记录,以方便以后查看自己的学习方法和对其总结。[@more@]今天的主要目的是学习怎么样检查系统磁盘空间的使用情况。
使用到的是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)

学习开始:
[root@CentOS4 ~]# df -a
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等效。

显示指定文件系统的空间使用情况

[root@CentOS4 ~]# df -t ext2
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 7218432 1957704 4894048 29% /


人性化显示各存储空间大小

[root@CentOS4 ~]# df -ah
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


有时候挂载了网络文件系统,若只想看本机的文件系统用如下命令

[root@CentOS4 ~]# df -ahlT
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


也可以这样写:

[root@CentOS4 ~]# df -a -h -l -T
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


还可以这样写:

[root@CentOS4 ~]# df -allhlT
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

查看某个文件系统的磁盘使用情况

[root@CentOS4 ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
none 506M
0 506M 0% /dev/shm

问题,要是想查一个目录文件的大小怎么办,找了资料,命令du可以检查目录空间大小,这安排下一次学习,现在已经深夜12点了,休息。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7764484/viewspace-982557/,如需转载,请注明出处,否则将追究法律责任。

上一篇: Linux学习笔记1
请登录后发表评论 登录
全部评论

注册时间:2007-12-19

  • 博文量
    57
  • 访问量
    233003