Table of Contents

It’s important to always be aware of resource usage in your cloud VPS. Without a cPanel or other graphical user interfaces (GUIs) you need how to monitor your system on the command line. This is not difficult, and actually many users prefer to work this way. Once you get used to it, command line work can be fun and time-saving.
The most common utility used in measuring disk space is the GNU df
command, which is already installed in your system. In this article, we will go through the basic usage of this command as well as provide you with the advanced options, so this article can serve as your singular resource for everything you ever wanted to know about the df
command.
Using The df
Command
For more information check out the GNU website.
One of the best ways to check for free disk space is to use the df
(disk free) command.
The GNU df
command prints out to you all of the available disk space on your file system for each “file” (remember that drives are mounted as device “files” in Unix-like systems).
For more information on how disks are mounted (or not mounted) on your system, see the below section of disk mounting and file system.
The Basic Usage
Most basically, it is recommended to use the df
command with the -h
(human readable) option, to convert the bytes into easily readable megabyte and gigabyte measurements.
Here’s the command with the -h
output from an Ubuntu system:
For demonstration purposes, here is the raw output without the -h
option:
Complete Option Layout
-a
,-all
- include psuedo, duplicate, and inaccessible file systems
-B
,--block-size=SIZE
- scale sizes by parameter “SIZE”
-h
,--human-readable
- print size in powers of 1024 (basically formatted as megabyte or gigabyte)
-H
,--si
- print sizes in powers of 1000 (e.g., 1.1G)
-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 the FIELDLIST parameter, or print all fields if parameter is omitted.
-P
,--portability
- use the POSIX output format
--sync
- invoke sync before getting usage info
--total
- elide all entries insignificant to available space, and produce a grand total
-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
Disk Mounting and File System
In the classical Unix-like file system, you can mount drives to a location in the file system. This may seem foreign to you if you are accustomed to how your operating system automatically mounts a drive to a convenient location the same way each time. But if you think about it, the mounting system offers you some more flexibility. For example, if you want to mount a drive to /USB/drive/
, you can use that path, and no matter what drive you mount there, the path will stay the same. This gives you some flexibility in writing scripts, managing backups, or a whole host of other important system tasks.
What Are Blocks and Block Size?
Programs like df
display disk sizes in blocks. As you saw in the above output examples, the default block size is measured in bytes. But this can be difficult to calculate on the spot with respect to how much this space this means to you. So you can specify your byte usage by having the computer calculate by blocks of various sizes. For example, in the df -h
command, the output of bytes (the blocks, basically) are automatically re-calculated to give you the measurements in powers 1,024 bytes. This most closely approximates gigbytes, megabytes, and kilobytes you’re accustomed to seeing in your operating system.
More Resources on System Monitoring
Check out these other resources from the support center: