df:整個文件系統和磁盤狀況)node
du:單文件或者文件夾的磁盤塊)shell
fdisk:磁盤的分區管理)centos
stat: 顯示文件、文件夾的信息
app
1.0:簡介: 命令能夠獲取硬盤被佔用了多少空。這個是獲取整個文件系統和磁盤的狀況ui
-a:顯示全部文件系統的磁盤使用狀況,包括0塊(block)的文件系統,如/proc文件系統。 -k:以k字節爲單位顯示。 -i:顯示i節點信息,而不是磁盤塊。 -t:顯示各指定類型的文件系統的磁盤空間使用狀況。 -x:列出不是某一指定類型文件系統的磁盤空間使用狀況(與t選項相反)。 -T:顯示文件系統類型。
1.1顯示磁盤分區: df this
$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/centos-root 31441920 4529648 26912272 15% / devtmpfs 925544 0 925544 0% /dev tmpfs 935256 148 935108 1% /dev/shm tmpfs 935256 9068 926188 1% /run tmpfs 935256 0 935256 0% /sys/fs/cgroup /dev/mapper/centos-home 49725724 356928 49368796 1% /home /dev/sda1 508588 126460 382128 25% /boot .host:/ 454928380 47202848 407725532 11% /mnt/hgfs 解釋: Filesystem -----》磁盤的分區信息 1K-blocks ----》分區塊 Used ------》使用狀況 Available ------》剩餘狀況 Use% -------》使用比例 Mounted on -------》掛載的文件 ( 使用+剩餘 不必定等於總塊數。爲了給系統預留一部分空間,讓磁盤滿的狀況,讓管理員進入進行操做)
1.2 顯示磁盤的inode :spa
$ df -i (list inode information instead of block usage:顯示塊對應的inode) Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/centos-root 31457280 138991 31318289 1% / devtmpfs 231386 400 230986 1% /dev tmpfs 233814 8 233806 1% /dev/shm tmpfs 233814 525 233289 1% /run tmpfs 233814 13 233801 1% /sys/fs/cgroup /dev/mapper/centos-home 49750016 4267 49745749 1% /home /dev/sda1 512000 330 511670 1% /boot .host:/ 0 0 0 - /mnt/hgfs 解釋: Inodes -------》總共的inode<系統分配的範圍> IUsed --------》使用 IFree ------》未使用
1.3顯示磁盤的使用類型:code
$ df –T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/mapper/centos-root xfs 31441920 4529228 26912692 15% / devtmpfs devtmpfs 925544 0 925544 0% /dev tmpfs tmpfs 935256 148 935108 1% /dev/shm tmpfs tmpfs 935256 9064 926192 1% /run tmpfs tmpfs 935256 0 935256 0% /sys/fs/cgroup /dev/mapper/centos-home xfs 49725724 356864 49368860 1% /home /dev/sda1 xfs 508588 126460 382128 25% /boot .host:/ vmhgfs 454928380 47202848 407725532 11% /mnt/hgfs
2.1簡介: du:(Disk usage )磁盤的使用狀況。統計文件/文件夾 佔磁盤空間的大小orm
-s:對每一個Names參數只給出佔用的數據塊總數。 -a:遞歸地顯示指定目錄中各文件及子目錄中各文件佔用的數據塊數。若既不指定-s,也不指定-a,則只顯示Names中的每個目錄及其中的各子目錄所佔的磁盤塊數。 -b:以字節爲單位列出磁盤空間使用狀況(系統默認以k字節爲單位)。 -k:以1024字節爲單位列出磁盤空間使用狀況。 <k、b 在這種統計命令中通常用來表示:byte或者k> -c:最後再加上一個總計(系統默認設置)。 -l:計算全部的文件大小,對硬連接文件,則計算屢次。 -x:跳過在不一樣文件系統上的目錄不予統計。
3.1簡介:給磁盤分區.<通常不經常使用>遞歸
Usage: fdisk [options] <disk> change partition table fdisk [options] -l <disk> list partition table(s) fdisk -s <partition> give partition size(s) in blocks Options: -b <size> sector size (512, 1024, 2048 or 4096) 扇區大小 -c[=<mode>] compatible mode: 'dos' or 'nondos' (default) -h print this help text 幫助 -u[=<unit>] display units: 'cylinders' or 'sectors' (default) -v print program version -C <number> specify the number of cylinders -H <number> specify the number of heads -S <number> specify the number of sectors per track
3.2 使用:
第一步:fdisk 磁盤名(fdisk /dev/sda)
a toggle a bootable flag 切換開機的文件 b edit bsd disklabel 編輯 c toggle the dos compatibility flag d delete a partition 刪除分區 g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types 分區類型表<至關於ascii> m print this menu n add a new partition 添加 o create a new empty DOS partition table p print the partition table 打印 q quit without saving changes s create a new empty Sun disklabel t change a partition's system id 改變分區類型、通常用於新的設備 u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
選擇打印:p
類型表:l
4.1 簡介: 顯示文件、文件夾的信息
文件夾 $ stat /home File: ‘/home’ Size: 16 Blocks: 0 IO Block: 4096 directory Device: fd02h/64770d Inode: 128 Links: 3 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-12-13 11:29:01.142687113 +0800 Modify: 2015-12-10 19:54:40.089728044 +0800 Change: 2015-12-10 19:54:40.089728044 +0800 Birth: - 文件 $ stat VMwareTools-10.0.0-2977863.tar.gz File: ‘VMwareTools-10.0.0-2977863.tar.gz’ Size: 71524872 Blocks: 139704 IO Block: 4096 regular file Device: fd02h/64770d Inode: 175 Links: 1 Access: (0444/-r--r--r--) Uid: ( 1000/ fxl) Gid: ( 1000/ fxl) Access: 2015-12-06 10:47:02.939028461 +0800 Modify: 2015-12-06 10:46:52.035027559 +0800 Change: 2015-12-06 10:46:52.035027559 +0800 Birth: -