Linux学习笔记2

虽然不能把每一学习点都记录下来,但能记录的尽量记录,以方便以后查看自己的学习方法和对其总结。[@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)

学习开始:
None.gif [root @CentOS4 ~ ] # df -a
None.gif Filesystem 1K - blocks Used Available Use % Mounted on
None.gif / dev / sda1 7218432 1957704 4894048 29 % /
None.gifnone 0 0 0 - / proc
None.gifnone 0 0 0 - / sys
None.gifnone 0 0 0 - / dev / pts
None.gifnone 517292 0 517292 0 % / dev / shm
None.gifnone 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif[root @CentOS4 ~ ] # df -aT
None.gif Filesystem Type 1K - blocks Used Available Use % Mounted on
None.gif / dev / sda1 ext2 7218432 1957704 4894048 29 % /
None.gifnone proc 0 0 0 - / proc
None.gifnone sysfs 0 0 0 - / sys
None.gifnone devpts 0 0 0 - / dev / pts
None.gifnone tmpfs 517292 0 517292 0 % / dev / shm
None.gifnone binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc rpc_pipefs 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif[root @CentOS4 ~ ] # df -a -T
None.gif Filesystem Type 1K - blocks Used Available Use % Mounted on
None.gif / dev / sda1 ext2 7218432 1957704 4894048 29 % /
None.gifnone proc 0 0 0 - / proc
None.gifnone sysfs 0 0 0 - / sys
None.gifnone devpts 0 0 0 - / dev / pts
None.gifnone tmpfs 517292 0 517292 0 % / dev / shm
None.gifnone binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc 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等效。

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

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


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

None.gif [root @CentOS4 ~ ] # df -ah
None.gif Filesystem Size Used Avail Use % Mounted on
None.gif / dev / sda1 6 . 9G 1 . 9G 4 . 7G 29 % /
None.gifnone 0 0 0 - / proc
None.gifnone 0 0 0 - / sys
None.gifnone 0 0 0 - / dev / pts
None.gifnone 506M 0 506M 0 % / dev / shm
None.gifnone 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif[root @CentOS4 ~ ] # df -a -h
None.gif Filesystem Size Used Avail Use % Mounted on
None.gif / dev / sda1 6 . 9G 1 . 9G 4 . 7G 29 % /
None.gifnone 0 0 0 - / proc
None.gifnone 0 0 0 - / sys
None.gifnone 0 0 0 - / dev / pts
None.gifnone 506M 0 506M 0 % / dev / shm
None.gifnone 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif


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

None.gif [root @CentOS4 ~ ] # df -ahlT
None.gif Filesystem Type Size Used Avail Use % Mounted on
None.gif / dev / sda1 ext2 6 . 9G 1 . 9G 4 . 7G 29 % /
None.gifnone proc 0 0 0 - / proc
None.gifnone sysfs 0 0 0 - / sys
None.gifnone devpts 0 0 0 - / dev / pts
None.gifnone tmpfs 506M 0 506M 0 % / dev / shm
None.gifnone binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc rpc_pipefs 0 0 0 - / var / lib / nfs / rpc_pipefs


也可以这样写:

None.gif [root @CentOS4 ~ ] # df -a -h -l -T
None.gif Filesystem Type Size Used Avail Use % Mounted on
None.gif / dev / sda1 ext2 6 . 9G 1 . 9G 4 . 7G 29 % /
None.gifnone proc 0 0 0 - / proc
None.gifnone sysfs 0 0 0 - / sys
None.gifnone devpts 0 0 0 - / dev / pts
None.gifnone tmpfs 506M 0 506M 0 % / dev / shm
None.gifnone binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc rpc_pipefs 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif


还可以这样写:

None.gif [root @CentOS4 ~ ] # df -allhlT
None.gif Filesystem Type Size Used Avail Use % Mounted on
None.gif / dev / sda1 ext2 6 . 9G 1 . 9G 4 . 7G 29 % /
None.gifnone proc 0 0 0 - / proc
None.gifnone sysfs 0 0 0 - / sys
None.gifnone devpts 0 0 0 - / dev / pts
None.gifnone tmpfs 506M 0 506M 0 % / dev / shm
None.gifnone binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc
None.gifsunrpc rpc_pipefs 0 0 0 - / var / lib / nfs / rpc_pipefs
None.gif

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

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

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

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

转载于:http://blog.itpub.net/7764484/viewspace-982557/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值