Decode360's Blog

          業(yè)精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 ::  :: 管理 ::
            397 隨筆 :: 33 文章 :: 29 評(píng)論 :: 0 Trackbacks
          Linux磁盤(pán)管理命令[du|df]
          ?
          ?
          ??? 來(lái)了解一下Linux下對(duì)磁盤(pán)進(jìn)行查看和控制的兩個(gè)命令。這兩個(gè)命令都比較好用,非常需要的功能,而且參數(shù)也不復(fù)雜。Linux我不熟悉,基本上都是從網(wǎng)上搜集資料學(xué)習(xí),記在博客中,以方便今后匯總查詢(xún)。好,簡(jiǎn)單學(xué)習(xí)一下:
          ?
          ?
          一、du命令

          首先看一下du的help說(shuō)明:
          ---------------------------------
          ?
          [root@misdwh opt]# du --help
          Usage: du [OPTION]... [FILE]...
          ? or:? du [OPTION]... --files0-from=F
          Summarize disk usage of each FILE, recursively for directories.
          ?
          Mandatory arguments to long options are mandatory for short options too.
          ? -a, --all???????????? write counts for all files, not just directories
          ????? --apparent-size?? print apparent sizes, rather than disk usage; although
          ????????????????????????? the apparent size is usually smaller, it may be
          ????????????????????????? larger due to holes in ('sparse') files, internal
          ????????????????????????? fragmentation, indirect blocks, and the like
          ? -B, --block-size=SIZE use SIZE-byte blocks
          ? -b, --bytes?????????? equivalent to `--apparent-size --block-size=1'
          ? -c, --total?????????? produce a grand total
          ? -D, --dereference-args? dereference FILEs that are symbolic links
          ????? --files0-from=F?? summarize disk usage of the NUL-terminated file
          ????????????????????????? names specified in file F
          ? -H??????????????????? like --si, but also evokes a warning; will soon
          ????????????????????????? change to be equivalent to --dereference-args (-D)
          ? -h, --human-readable? print sizes in human readable format (e.g., 1K 234M 2G)
          ????? --si????????????? like -h, but use powers of 1000 not 1024
          ? -k??????????????????? like --block-size=1K
          ? -l, --count-links???? count sizes many times if hard linked
          ? -m??????????????????? like --block-size=1M
          ? -L, --dereference???? dereference all symbolic links
          ? -P, --no-dereference? don't follow any symbolic links (this is the default)
          ? -0, --null??????????? end each output line with 0 byte rather than newline
          ? -S, --separate-dirs?? do not include size of subdirectories
          ? -s, --summarize?????? display only a total for each argument
          ? -x, --one-file-system? skip directories on different file systems
          ? -X FILE, --exclude-from=FILE? Exclude files that match any pattern in FILE.
          ????? --exclude=PATTERN Exclude files that match PATTERN.
          ????? --max-depth=N???? print the total for a directory (or file, with --all)
          ????????????????????????? only if it is N or fewer levels below the command
          ????????????????????????? line argument;? --max-depth=0 is the same as
          ????????????????????????? --summarize
          ????? --time??????????? show time of the last modification of any file in the
          ????????????????????????? directory, or any of its subdirectories
          ????? --time=WORD?????? show time as WORD instead of modification time:
          ????????????????????????? atime, access, use, ctime or status
          ????? --time-style=STYLE show times using style STYLE:
          ????????????????????????? full-iso, long-iso, iso, +FORMAT
          ????????????????????????? FORMAT is interpreted like `date'
          ????? --help???? display this help and exit
          ????? --version? output version information and exit
          ?
          SIZE may be (or may be an integer optionally followed by) one of following:
          kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
          ?
          ?
          ?
          ?
          ?
          ?
          語(yǔ)法:du [ -a | -s ] [ -k ] [ -m ] [ -g ][ -l ] [ -r ] [ -x ] [ -H | -L ][ File ... ]
          ?
          描述:du命令顯示用于文件的塊數(shù)量。如果指定的File參數(shù)實(shí)際上是一個(gè)目錄,就要報(bào)告該目錄內(nèi)的所有文件。如果沒(méi)有提供File參數(shù),du命令使用當(dāng)前目錄內(nèi)的文件。 如果File參數(shù)是一個(gè)目錄,那么報(bào)告的塊的數(shù)量就是分配到目錄中文件以及分配到目錄自身的塊之和。
          ?
          指定-a標(biāo)志:報(bào)告?zhèn)€體文件中塊數(shù)量。不管是否使用了-a標(biāo)志,由File參數(shù)指定的個(gè)體文件總是要列出。
          指定-s標(biāo)志:報(bào)告用于所有指定文件和目錄中所有文件的全部塊。
          ?
          ---------------------------------

          分類(lèi)解說(shuō)一下各個(gè)參數(shù)的含義:
          ?
          -a 顯示文件夾中的所有文件夾、文件的大小。默認(rèn)只顯示文件夾大小,不顯示文件。
          -B 以xxByte為單位顯示塊數(shù)(默認(rèn)為1024)
          -b 以1Byte為單位顯示塊數(shù)(但貌似與-B1的結(jié)果不同)
          -c 最后顯示一行匯總數(shù)據(jù)
          -h 以方便閱讀的方式展現(xiàn)大小(是以1000為單位,而非1024)
          -k 用 1024 字節(jié)單位計(jì)算塊數(shù),而不是用缺省的 512 字節(jié)單位。
          -m 用 MB 單位計(jì)算塊數(shù),而不是用缺省的 512 字節(jié)單位。
          -0 注意是數(shù)字“0”,而非字母“O”。表示每行后面不換行,直接跟下去
          -S 外層的文件夾大小不包含內(nèi)層大小

          -s 只顯示整個(gè)對(duì)象文件夾的合計(jì)大小。將該標(biāo)志與-a標(biāo)志進(jìn)行對(duì)比。
          -x 在評(píng)估文件大小時(shí),只評(píng)估那些與File參數(shù)指定的文件或者目錄駐留在相同設(shè)備上的文件。
          ?
          ?
          注:
          1、具有多個(gè)鏈接的文件只為一個(gè)條目計(jì)數(shù)和書(shū)寫(xiě)。
          2、由于塊計(jì)數(shù)只基于文件大小,所以在報(bào)告的塊數(shù)中,未分配的塊是沒(méi)有包含進(jìn)去的。
          3、如果du得不到文件屬性,或者無(wú)法讀取目錄,它就報(bào)告一個(gè)錯(cuò)誤,并且會(huì)影響命令的退出狀態(tài)。
          4、如果同時(shí)指定-k、-m標(biāo)志,則后面的那個(gè)起作用。且輸出結(jié)果四舍五入。
          ?

          退出狀態(tài):
          ?
          此命令返回下列出口值:
          =0 成功結(jié)束。
          >0 發(fā)生錯(cuò)誤。
          ?
          ?
          ?
          二、df命令
          ?
          同樣先來(lái)看help說(shuō)明
          ---------------------------------
          ?
          [root@misdwh devMISowb]# df --help
          Usage: df [OPTION]... [FILE]...
          Show information about the file system on which each FILE resides,
          or all file systems by default.
          ?
          Mandatory arguments to long options are mandatory for short options too.
          ? -a, --all???????????? include dummy file systems
          ? -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 file systems
          ????? --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 file systems of type TYPE
          ? -T, --print-type????? print file system type
          ? -x, --exclude-type=TYPE?? limit listing to file systems not of type TYPE
          ? -v??????????????????? (ignored)
          ????? --help???? display this help and exit
          ????? --version? output version information and exit
          ?
          SIZE may be (or may be an integer optionally followed by) one of following:
          kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
          ---------------------------------
          ?
          df命令可顯示所有文件系統(tǒng)對(duì)i節(jié)點(diǎn)和磁盤(pán)塊的使用情況。
          ?
          各個(gè)選項(xiàng)的含義如下:?
          ?
          -a 顯示所有文件系統(tǒng)的磁盤(pán)使用情況,包括0塊(block)的文件系統(tǒng),如/proc文件系統(tǒng)。?
          -B 以xxByte為單位顯示塊數(shù)(默認(rèn)為1024)
          -h 以方便閱讀的方式展現(xiàn)大小(是以1024為單位)
          -H 以方便閱讀的方式展現(xiàn)大小(是以1000為單位)
          -i 顯示i節(jié)點(diǎn)信息,而不是磁盤(pán)塊。
          -k 以k字節(jié)為單位顯示。?
          -P 以POSIX格式輸出結(jié)果(不換行?)
          -t 后面跟“=type類(lèi)型”,顯示各指定類(lèi)型的文件系統(tǒng)的磁盤(pán)空間使用情況。
          -T 顯示文件系統(tǒng)類(lèi)型。
          -x 后面跟“=type類(lèi)型”,列出不是某一指定類(lèi)型文件系統(tǒng)的磁盤(pán)空間使用情況(與t選項(xiàng)相反)。?
          ?
          ?
          ?
          顯示內(nèi)容說(shuō)明:
          ?
          $ df?
          ?
          Filesystem 1K-blocks?? Used? Available Use% Mounted on?
          /dev/hda2? 1361587?? 1246406????? 44823 97% /?
          ?
          df命令的輸出清單的第1列是代表文件系統(tǒng)對(duì)應(yīng)的設(shè)備文件的路徑名( 一般是硬盤(pán)上的分區(qū));第2列給出分區(qū)包含的數(shù)據(jù)塊(1024字節(jié))的數(shù)目;第3、4列分別表示已用的和可用的數(shù)據(jù)塊數(shù)目。用戶(hù)也許會(huì)感到奇怪的是:第3、4列塊數(shù)之和不等于第2列中的塊數(shù)。這是因?yàn)槿笔〉拿總€(gè)分區(qū)都留了少量空間供系統(tǒng)管理員使用。即使遇到普通用戶(hù)空間已滿(mǎn)的情況,管理員仍能登錄和留有解決問(wèn)題所需的工作空間。清單中Use%列表示普通用戶(hù)空間使用的百分比,即使這一數(shù)字達(dá)到100%,分區(qū)仍然留有系統(tǒng)管理員使用的空間。最后,Mounted on列表示文件系統(tǒng)的安裝點(diǎn)。?

          ?
          ?
          posted on 2009-06-29 23:01 decode360 閱讀(540) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): 03.Linux
          主站蜘蛛池模板: 拜泉县| 塔河县| 施秉县| 顺昌县| 谷城县| 通辽市| 尖扎县| 华宁县| 桦甸市| 夹江县| 高密市| 台湾省| 稷山县| 辉南县| 余干县| 新野县| 蒲江县| 黄梅县| 内江市| 天等县| 通山县| 杭锦旗| 怀来县| 怀柔区| 镇坪县| 来宾市| 华安县| 彭水| 大悟县| 抚远县| 高阳县| 来宾市| 五大连池市| 南京市| 昌宁县| 治多县| 庆元县| 青海省| 磐石市| 海盐县| 当涂县|