Useful 9 (df) linux commands to check disk space

Useful 9 (df) Linux Commands to Check Disk Space

In this article, we going to see how to check disk space using Linux commands, Here we have the various method and in online we have a lot of tools for checking disk space utilization in Linux. In Linux we have built-in service called “df” this command stands for “disk filesystem“, this is useful to get full detailed empty disk space and used disk space of the Linux system files.

This section explains a method to get the full information of Linux disk space usage with the help of “df” command. Hence, you could entirely understand the usage of “df” Linux command.

1.
Sponsored
Display Usage of File System Disk Space

Following this “df” command displays the information of blocks, disk used space, disk available space and mounted on a file system.

[softaox@172-143-123-20 ~]$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       62903276 29745072  33158204  48% /
devtmpfs         1929488        0   1929488   0% /dev
tmpfs            1940196        0   1940196   0% /dev/shm
tmpfs            1940196   186960   1753236  10% /run
tmpfs            1940196        0   1940196   0% /sys/fs/cgroup
/dev/loop0       2103452     3736   1989536   1% /tmp
tmpfs             388040        0    388040   0% /run/user/0

2. Display the Detailed Usage of all File System Disk Space

Using “df -a” command we display the detailed information about all the file system disk usage including dummy file systems along with their memory usage also.

See also  Ubuntu Weekly Newsletter Issue 813
[softaox@172-143-123-20 ~]$ df -a
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs                 -        -         -    - /
sysfs                  0        0         0    - /sys
proc                   0        0         0    - /proc
devtmpfs         1929488        0   1929488   0% /dev
securityfs             0        0         0    - /sys/kernel/security
tmpfs            1940196        0   1940196   0% /dev/shm
devpts                 0        0         0    - /dev/pts
tmpfs            1940196   186952   1753244  10% /run
tmpfs            1940196        0   1940196   0% /sys/fs/cgroup
cgroup                 0        0         0    - /sys/fs/cgroup/systemd
pstore                 0        0         0    - /sys/fs/pstore
cgroup                 0        0         0    - /sys/fs/cgroup/perf_event
cgroup                 0        0         0    - /sys/fs/cgroup/freezer
cgroup                 0        0         0    - /sys/fs/cgroup/pids
cgroup                 0        0         0    - /sys/fs/cgroup/cpu,cpuacct
cgroup                 0        0         0    - /sys/fs/cgroup/blkio
cgroup                 0        0         0    - /sys/fs/cgroup/net_cls,net_prio
cgroup                 0        0         0    - /sys/fs/cgroup/memory
cgroup                 0        0         0    - /sys/fs/cgroup/cpuset
cgroup                 0        0         0    - /sys/fs/cgroup/hugetlb
cgroup                 0        0         0    - /sys/fs/cgroup/devices
configfs               0        0         0    - /sys/kernel/config
/dev/vda1       62903276 29753704  33149572  48% /
systemd-1              -        -         -    - /proc/sys/fs/binfmt_misc
debugfs                0        0         0    - /sys/kernel/debug
hugetlbfs              0        0         0    - /dev/hugepages
mqueue                 0        0         0    - /dev/mqueue
/dev/loop0       2103452     3736   1989536   1% /tmp
/dev/loop0       2103452     3736   1989536   1% /var/tmp
binfmt_misc            0        0         0    - /proc/sys/fs/binfmt_misc
tmpfs             388040        0    388040   0% /run/user/0
fusectl                0        0         0    - /sys/fs/fuse/connections

3. Display the Disk space usage in Human Readable Format

We all understand the sizes in the format like megabytes, gigabytes, terabyte, etc. But in above all commands we can’t see in the Human Readable format. Using the “df -h” command will helpful to display sizes in Human Readable formats like 50K 50M, 50G.

[softaox@172-143-123-20 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        60G   29G   32G  48% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G  183M  1.7G  10% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop0      2.1G  3.7M  1.9G   1% /tmp
tmpfs           379M     0  379M   0% /run/user/0

4. Display the File System in Bytes Format

Following this command “df -k” we display the file system information and usage in 1024-byte blocks.

[softaox@172-143-123-20 ~]$ df -k
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       62903276 29755564  33147712  48% /
devtmpfs         1929488        0   1929488   0% /dev
tmpfs            1940196        0   1940196   0% /dev/shm
tmpfs            1940196   186952   1753244  10% /run
tmpfs            1940196        0   1940196   0% /sys/fs/cgroup
/dev/loop0       2103452     3736   1989536   1% /tmp
tmpfs             388040        0    388040   0% /run/user/0
5. Display the File System in MegaByte (MB) Format

Following this command “df -m” we display the file system usage in MegaByte (MB) format.

See also  How to Install DEB Files in Ubuntu 22.04?
Sponsored
[softaox@172-143-123-20 ~]$ df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda1          61429 29050     32380  48% /
devtmpfs            1885     0      1885   0% /dev
tmpfs               1895     0      1895   0% /dev/shm
tmpfs               1895   183      1713  10% /run
tmpfs               1895     0      1895   0% /sys/fs/cgroup
/dev/loop0          2055     4      1943   1% /tmp
tmpfs                379     0       379   0% /run/user/0
6. Display /home File System Device Information

Using this “df -h /home” command we can display only /home file system device information in Human Readable format.

[softaox@172-143-123-20 ~]$ df -h /home
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        60G   29G   32G  48% /

7. Display the File System Inodes

In this, we can see the file system used inodes and their percentage using “df -i” command.

[softaox@172-143-123-20 ~]$ df -i
Filesystem       Inodes  IUsed    IFree IUse% Mounted on
/dev/vda1      31456704 902021 30554683    3% /
devtmpfs         482372    327   482045    1% /dev
tmpfs            485049      1   485048    1% /dev/shm
tmpfs            485049    600   484449    1% /run
tmpfs            485049     16   485033    1% /sys/fs/cgroup
/dev/loop0       137904    132   137772    1% /tmp
tmpfs            485049      1   485048    1% /run/user/0

8. Display the Detailed Information About File System Type

It is easy to see the system file type of your system along with other details above previous commands, not displayed information about system file type using “df -T” we can able to see the file type.

[softaox@172-143-123-20 ~]$ df -T
Filesystem     Type     1K-blocks     Used Available Use% Mounted on
/dev/vda1      xfs       62903276 29746300  33156976  48% /
devtmpfs       devtmpfs   1929488        0   1929488   0% /dev
tmpfs          tmpfs      1940196        0   1940196   0% /dev/shm
tmpfs          tmpfs      1940196   186952   1753244  10% /run
tmpfs          tmpfs      1940196        0   1940196   0% /sys/fs/cgroup
/dev/loop0     ext3       2103452     3736   1989536   1% /tmp
tmpfs          tmpfs       388040        0    388040   0% /run/user/0

9. Display Options & Help Using “df –help” Command

Using “df –help” we can display available options in “df” command.

[softaox@172-143-123-20 ~]$ 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 pseudo, duplicate, inaccessible file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
      --direct          show statistics for a file instead of mount point
      --total           produce a grand total
  -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)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -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

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

FIELD_LIST is a comma-separated list of columns to be included.  Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).

The post Useful 9 (df) Linux Commands to Check Disk Space appeared first on Linux, Angular, Angular JS, jQuery, PHP, MySQL and Web Development Tutorials.

See also  Deploying secure AI and real-time robots at ROSCon 24

Leave a Comment

Only people in my network can comment.