Decode360's Blog

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

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

          首先看一下du的help說明:
          ---------------------------------
          ?
          [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.
          ?
          ?
          ?
          ?
          ?
          ?
          語法:du [ -a | -s ] [ -k ] [ -m ] [ -g ][ -l ] [ -r ] [ -x ] [ -H | -L ][ File ... ]
          ?
          描述:du命令顯示用于文件的塊數量。如果指定的File參數實際上是一個目錄,就要報告該目錄內的所有文件。如果沒有提供File參數,du命令使用當前目錄內的文件。 如果File參數是一個目錄,那么報告的塊的數量就是分配到目錄中文件以及分配到目錄自身的塊之和。
          ?
          指定-a標志:報告個體文件中塊數量。不管是否使用了-a標志,由File參數指定的個體文件總是要列出。
          指定-s標志:報告用于所有指定文件和目錄中所有文件的全部塊。
          ?
          ---------------------------------

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

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

          退出狀態:
          ?
          此命令返回下列出口值:
          =0 成功結束。
          >0 發生錯誤。
          ?
          ?
          ?
          二、df命令
          ?
          同樣先來看help說明
          ---------------------------------
          ?
          [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命令可顯示所有文件系統對i節點和磁盤塊的使用情況。
          ?
          各個選項的含義如下:?
          ?
          -a 顯示所有文件系統的磁盤使用情況,包括0塊(block)的文件系統,如/proc文件系統。?
          -B 以xxByte為單位顯示塊數(默認為1024)
          -h 以方便閱讀的方式展現大小(是以1024為單位)
          -H 以方便閱讀的方式展現大小(是以1000為單位)
          -i 顯示i節點信息,而不是磁盤塊。
          -k 以k字節為單位顯示。?
          -P 以POSIX格式輸出結果(不換行?)
          -t 后面跟“=type類型”,顯示各指定類型的文件系統的磁盤空間使用情況。
          -T 顯示文件系統類型。
          -x 后面跟“=type類型”,列出不是某一指定類型文件系統的磁盤空間使用情況(與t選項相反)。?
          ?
          ?
          ?
          顯示內容說明:
          ?
          $ df?
          ?
          Filesystem 1K-blocks?? Used? Available Use% Mounted on?
          /dev/hda2? 1361587?? 1246406????? 44823 97% /?
          ?
          df命令的輸出清單的第1列是代表文件系統對應的設備文件的路徑名( 一般是硬盤上的分區);第2列給出分區包含的數據塊(1024字節)的數目;第3、4列分別表示已用的和可用的數據塊數目。用戶也許會感到奇怪的是:第3、4列塊數之和不等于第2列中的塊數。這是因為缺省的每個分區都留了少量空間供系統管理員使用。即使遇到普通用戶空間已滿的情況,管理員仍能登錄和留有解決問題所需的工作空間。清單中Use%列表示普通用戶空間使用的百分比,即使這一數字達到100%,分區仍然留有系統管理員使用的空間。最后,Mounted on列表示文件系統的安裝點。?

          ?
          ?
          posted on 2009-06-29 23:01 decode360 閱讀(547) 評論(0)  編輯  收藏 所屬分類: 03.Linux
          主站蜘蛛池模板: 安阳市| 广河县| 游戏| 博湖县| 昭觉县| 康马县| 澄江县| 来凤县| 五莲县| 屯门区| 涞源县| 化州市| 邻水| 陈巴尔虎旗| 视频| 江源县| 诸暨市| 苍山县| 宁波市| 宜阳县| 伊宁县| 新沂市| 山阴县| 沧源| 宁陵县| 余江县| 明水县| 含山县| 阜宁县| 平利县| 通城县| 东光县| 拉萨市| 绍兴县| 宁河县| 兴安县| 武清区| 林口县| 来凤县| 宾川县| 崇文区|