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
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.
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:
Filesystem Size Used Avail Use% Mounted on udev 3.7G 0 3.7G 0% /dev tmpfs 776M 4.2M 772M 1% /run /dev/mmcblk0p2 30G 15G 15G 51% / tmpfs 3.8G 0 3.8G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup /dev/loop0 49M 49M 0 100% /snap/core18/1936 /dev/loop2 49M 49M 0 100% /snap/core18/2002 /dev/loop1 29M 29M 0 100% /snap/snapd/11584 /dev/loop4 128K 128K 0 100% /snap/software-boutique/56 /dev/loop5 128K 128K 0 100% /snap/ubuntu-mate-pi/11 /dev/loop3 27M 27M 0 100% /snap/snapd/9730 /dev/loop6 16M 16M 0 100% /snap/ubuntu-mate-welcome/615 /dev/loop7 16M 16M 0 100% /snap/ubuntu-mate-welcome/625 /dev/mmcblk0p1 255M 119M 137M 47% /boot/firmware tmpfs 776M 52K 776M 1% /run/user/1000
For demonstration purposes, here is the raw output without the
Filesystem 1K-blocks Used Available Use% Mounted on udev 3826036 0 3826036 0% /dev tmpfs 794560 4244 790316 1% /run /dev/mmcblk0p2 30448324 15300444 15131496 51% / tmpfs 3972792 0 3972792 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 3972792 0 3972792 0% /sys/fs/cgroup /dev/loop0 50048 50048 0 100% /snap/core18/1936 /dev/loop2 50176 50176 0 100% /snap/core18/2002 /dev/loop1 28800 28800 0 100% /snap/snapd/11584 /dev/loop4 128 128 0 100% /snap/software-boutique/56 /dev/loop5 128 128 0 100% /snap/ubuntu-mate-pi/11 /dev/loop3 27520 27520 0 100% /snap/snapd/9730 /dev/loop6 15616 15616 0 100% /snap/ubuntu-mate-welcome/615 /dev/loop7 15616 15616 0 100% /snap/ubuntu-mate-welcome/625 /dev/mmcblk0p1 260968 121336 139632 47% /boot/firmware tmpfs 794556 52 794504 1% /run/user/1000
Complete Option Layout
- include psuedo, duplicate, and inaccessible file systems
- scale sizes by parameter “SIZE”
- print size in powers of 1024 (basically formatted as megabyte or gigabyte)
- print sizes in powers of 1000 (e.g., 1.1G)
- list inode information instead of block usage
- like –block-size=1K
- limit listing to local file systems
- do not invoke sync before getting usage info (default)
- use the output format defined by the FIELDLIST parameter, or print all fields if parameter is omitted.
- use the POSIX output format
- invoke sync before getting usage info
- elide all entries insignificant to available space, and produce a grand total
- limit listing to file systems of type “TYPE”
- print file system type
- limit listing to file systems not of type “TYPE”
- display this help and exit
- 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?
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: