How To Use Linux df Command with Examples?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/use-linux-df-command-with-examples/
PINTEREST
PINTEREST
INSTAGRAM

One of the main duty of System Administrator is monitoring and checking the disk usage. According to situation take action against it. df command is used to file system disk space usage. It is practical to see disk usage in a fast and clean way.

Getting Help About df

We can get help about df with –help parameter. Keep in mind that -h is used for formatting operation.

How To Use Linux df Command with Examples?

Display Information About File System With df

If we do not provide any option or parameter the df command will list all partitions and related information. We have explained the related information below the screenshot.

Display Information About File System With df
Display Information About File System With df
  • Filesystem is the mount point of filesystem
  • 1K-blocks is number of 1Kilobyteblocks
  • Used is how many of the blocks are used
  • Available is how many of the blocks are free
  • Use % is usage percentage
  • Mounted on is where the file system mounted

Display All File Systems with df

Previous examples will list only real file systems. But as we know that Linux creates a lot of pseudue file systems for its functionality. We can list all file systems even pro, sysfs. lxc related file systems are displayed too.

Display All File Systems with df
Display All File Systems with df

Display File Systems By Specifying Memory Block Size with df

Default block size is set to 1KB as we seen before. We can change this size whatever we want. Here we change to it 100 with -B option.

Display File Systems By Specifying Memory Block Size with df
Display File Systems By Specifying Memory Block Size with df

Print Size As Human Readable with df

We have not 50-100 kb of file system. Today file systems are very huge in size and reading these sizes as kb is complex so we prefer human readable GB sizes. We will use -h option to list more readable format.

LEARN MORE  Python Command Line Arguments with sys.argv

Print Size As Human Readable with df
Print Size As Human Readable with df

Show Total of The File Systems with df

We can sum up total size of the file systems with –total .At the end of list a new column named total added

Show Total of The File Systems with df
Show Total of The File Systems with df

List Inodes Count with df

Inodes are fundamental part of the file systems. Up to now we have used 1K blocks but we may show the total inode numbers about file systems with -i option like below.

List Inodes Count with df
List Inodes Count with df

Print File System Type with df

File systems are We can also list file system type with df with -T option.

Print File System Type with df
Print File System Type with df

As we see there is tmpfs,ext4,xfs file systems in the screenshot.

List Only Local File Systems with df

There may be remote or network based file systems those are all ready mounted into the local Linux system. We can list only local file system by using -l option. Remote file systems like smb, nfs are not listed.

Filter Results According to File System with df

There are different type of file systems in a regular Linux system. We can filter results according to file system. This will provided with -t  option.

Filter Results According to File System with df
Filter Results According to File System with df

Sort File System According To Usage Percentage

We can sort the file system usage with sort command like below.

Sort File System According To Percentage
Sort File System According To Percentage

Get Block Size Always in GB with df

We may want to list sizes in GB for all ways. By using -BG option df will always output GB.

LEARN MORE  Bash Command Basics

Get Block Size Always in GB with df
Get Block Size Always in GB with df

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/use-linux-df-command-with-examples/
PINTEREST
PINTEREST
INSTAGRAM