Here is the Linux command to check disk space in gb. There are several ways to check total hard disk space in Ubuntu command line.
Before we begin, let use see the GUI way to check disk space in Linux Ubuntu:
Check how much disk space is left on Ubuntu
You can check how much disk space is left with Disk Usage Analyzer or System Monitor.
Check with Disk Usage Analyzer
To check the free disk space and disk capacity using Disk Usage Analyzer:
- Open Disk Usage Analyzer from the Activities overview. The window will display a list of file locations together with the usage and capacity of each.
- Click one of the items in the list to view a detailed summary of the usage for that item. Click the menu button, and then Scan Folder… or Scan Remote Folder… to scan a different location.
The information is displayed according to Folder, Size, Contents and when the data was last Modified.
Check with System Monitor
To check the free disk space and disk capacity with System Monitor:
- Open the System Monitor application from the Activities overview.
- Select the File Systems tab to view the system’s partitions and disk space usage. The information is displayed according to Total, Free, Available and Used.
Check Disk Space In Ubuntu Terminal
The “df” command is for “disk filesystem” and is a great tool to know about the disk space usage on Linux Systems. The df command displays the amount of disk space available on the file system.
Some important points to note:
- If no file name is given, the space available on all currently mounted file systems is shown.
- The disk space is shown in 1K blocks by default.
- When an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node.
- By default, it will also show the always the root file system.
Example-1:
The simplest df command is by itself. Without any command parameters. When executed the df command displays the information about the file system disk space usage. It shows the device name, total blocks, total disk space, used disk space, free disk space and mount points.df
Example-2:
Using the df command with -a or –all it shows dummy file systems information along with all the basic file system disk usage info:df -a
Example-3:
As the disk space is shown in 1K blocks by default, users can use “-h” command parameter to show the file system disk space usage data in “human readable” format.df -h
Example-4:
Use the command parameters -hT to display the info about the /home file system:df -hT /home
Example-5:
Use the command argument -k to display all file system information in 1024-byte blocks:df -k
Example-6:
Similarly you can use the command argument -m to display all file system information in MB (Mega Byte) and -h to see the info in GB (Gigabyte):df -m
df -h
Example-7:
If you wish to see the disk space usage info of a certain file system type, use it as argument:df -t ext3
Similarly there are many more commands you can use to check hard disk space. You can use du command, stat command, fdisk command and lsblk command.