Explore Disk Space and Memory using the Terminal
![](/covers/explore-disk-space-and-memory-using-the-terminal.png)
Knowing how to determine your server's free disk space and where that space is being used is essential. Thus, I will demonstrate the bash commands du
and df
, which help with this. Additionally, we will examine the free
command for reporting memory usage.
# Show Disk Usage
Show the disk usage of your root directory. The following uses df
with the -h
parameter to show the output in human readable form.
df -h /
# output
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p3 118G 16G 100G 14% /
# Explore Directories
In order to explore the current directory you can use the du
command. Again we are using the -h
parameter to show the output in human readable form and then we also use the -s
parameter to summarize the output. The *
is used the show the output of all the folders in the current directory.
du -h -s *
# output
1,1G Applications
68G codes
76K Desktop
26G Documents
8,0K Downloads
4,0K Music
1,2G Pictures
4,0K Public
1,9G snap
4,0K Templates
18G Videos
# Show Memory Usage
Besides disk space it important to know the memory usage. We are going to use the free
command to report us on the memory usage.
# memory usage in megabyte
free --mega
# memory usage in gigabyte
free --giga
# output
total used free shared buff/cache available
Mem: 16703 6836 578 391 10033 9866
Swap: 8589 0 8589
free manpage (opens new window)
# Source
https://www.howtogeek.com/409611/how-to-view-free-disk-space-and-disk-usage-from-the-linux-terminal/