How to check Disk Space in Linux ?

How to check Disk Space in Linux ?

While working on Linux systems a question arises in our mind is that how can we find out disk space utilization information using command line option?
Well, great news is, Linux has a inbuilt utility "df" to check disk space usage:

Linux commands to check disk space

df command – Shows the amount of disk space used and available on Linux file systems.
du command – Display the amount of disk space used by the specified files and for each subdirectory.
btrfs fi df /device/ – Show disk space usage information for a btrfs based mount point/file system.

1). Check disk space with df command :
Syntax : df [options] [devices]
----
df
df -h
It will shows the result in human readable format.
df -k It will shows the result in KiloBytes
df -m It will shows the result in MegaBytes.
----

You can simply type the df command without argument, which will produce a table for each device name on the system.

To see information about specific filesystem you can give a device as an argument :
------
$ df /dev/sda
$ df -h /dev/sdc1
$ df /data/

------

To display output using inode usage instead of block usage:
-------
$ df -i
$ df -i -h

-------
To display the type of each filesystems listed such as ext4, btrfs, ext2, nfs4, fuse, cgroup, cputset, and more:
-------
$ df -T
$ df -T -h
$ df -T -h /data/

-------

To list all but exclude ext2 filesystem pass the -x TYPE option:
-------
$ df -x ext2
-------

Show all file system:
--------
$ df -a
--------

Getting more help about the df command
--------
$ df --help
--------

To read man page:
--------
$ man df
---------

2). Understanding du command

The du command is used to find out the names of directories and files that consume large amounts of space on a disk. The syntax of du command is:
--------
du
du /path/do/dir
du [options] [directories and/or files]

---------

To check names and space consumption of each of the directories including all subdirectories in the directory tree:
--------
$ du
$ du -h human readable form
--------
Example :
To find out /home/ directory space usage, enter:
--------
$ du /home/
$ du -h /home/

--------

Summarize disk usage for any directory name :
--------
$ du -s /home/
$ du -sh /home/

--------

For more information on the du command :
--------
$ man du
$ du --help

--------

3). Understanding btrfs file system

For btrfs filesystem use the btrfs fi df command to see space usage information.
Syntax :
--------
btrfs filesystem df /path/
btrfs fi df /dev/path
btrfs fi df [options] /path/

---------
Author
bhawanisingh
Views
2,224
First release
Last update
Rating
0.00 star(s) 0 ratings
Top