الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

df

Show how much space is used and free on each mounted file system.

المستوى
امتحان RHCSA
المجموعة
الأقراص وأنظمة الملفات
يحتاج root
لا
الحزمة
coreutils

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

df (disk free) lists the mounted file systems with their size, used space, free space, use percentage and mount point. It is the first command when somebody says "the disk is full".

With -h sizes are easy to read; with -T you also see the type (xfs, ext4, tmpfs, nfs). With -i it shows inodes: a disk can also be "full" when all inodes are used (millions of tiny files), even if there is free space.

طريقة الكتابة

df [OPTION]... [FILE]...

الخيارات 18

الأكثر استخدامًا

-h, --human-readable
Sizes in powers of 1024, like 950M or 17G.
-T, --print-type
Show the file system type.
-i, --inodes
Show inode use instead of block use.
-H, --si
Sizes in powers of 1000 (like disk makers use).
-a, --all
Also show pseudo, duplicate and inaccessible file systems.
-l, --local
Only local file systems (no NFS or CIFS).
-t, --type=type
Only file systems of this type, like xfs.
-x, --exclude-type=type
Leave out this type, like tmpfs.
-k
Sizes in 1 KiB blocks.
-B, --block-size=size
Sizes in this unit, like M or G.
--output[=<fields>]
Choose the columns: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target.
--total
Add a line with the total.
-P, --portability
Use the POSIX output format (one line per file system, good for scripts).
--sync
Run sync before reading the numbers.
--no-sync
Do not run sync first (the default).
-v
Ignored.
--help
Show help.
--version
Show the version.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Show all file systems with readable sizes

    df -h

    Look at the Use% column. Above 90% needs action.

  2. 2Show the types too

    df -hT

    You see which ones are xfs, ext4, tmpfs or NFS.

  3. 3Which file system holds this folder?

    df -h /var/log

    Shows the file system that the folder is on.

  4. 4Check inodes when the disk is "full" but has space

    df -i /var

    100% IUse% means no new files can be made. Look for folders with millions of small files.

  5. 5Only real disks, no tmpfs

    df -h -x tmpfs -x devtmpfs

    A cleaner list for reports.

  6. 6Only XFS file systems

    df -hT -t xfs

    Useful when you check the volumes you created in the LVM chapter.

  7. 7Choose the columns for a report

    df -h --output=target,size,used,avail,pcent

    Easy to read and to paste in a ticket.

  8. 8Alert when a file system is above 85% (monitoring script)

    df -P | awk 'NR>1 && $5+0 > 85 {print "WARN", $6, $5}'

    -P keeps each file system on one line, so awk reads it safely.

  9. 9Check a new mount

    mount /dev/vdb1 /mnt/data && df -h /mnt/data

    Confirms the size and that the mount worked.

  10. 10Only local file systems

    df -hl

    Skips NFS shares that may hang when the server is down.

  11. 11Show the total of all file systems

    df -h --total | tail -1

    One number for the whole server.

انتبه

  • df and du can disagree: a deleted file that a program still has open still uses space. Find it with lsof +L1.
  • XFS and ext4 keep some space reserved; "Avail" can be smaller than Size minus Used.
  • A hanging NFS server can make df hang. Use df -l or df -x nfs4.

الملفات

/proc/self/mountinfo
The list of mounts that df reads.

نصائح للحفظ

  • df -hT = which disk, how full, what type. df -i = inodes.
  • df = per file system, du = per folder.