Ravindra BagaleCourses & study guides

6. Linux Advanced Commands

6.8 Disk and Storage Commands

df -h            # disk space per mounted filesystem (human readable)
df -Th           # include filesystem type (xfs, ext4)
sudo du -sh /var/log                    # total size of a folder
sudo du -h --max-depth=1 /var | sort -h # which sub-folder is big?
lsblk            # block devices (disks & partitions) as a tree
lsblk -f         # with filesystem type, UUID and mount point
sudo blkid       # UUIDs of all filesystems
findmnt /        # what is mounted at /
sudo mount /dev/nvme1n1 /data
sudo umount /data
cat /etc/fstab   # permanent mounts (read at boot)
free -h          # memory

Ravindra Bagale's Tip

When the disk is 100% full, MySQL and Nginx give strange errors, and many students sit searching for the problem in their code. Whenever something strange happens, check df -h first. To find the big folders, use du -h --max-depth=1 | sort -h.

Practice task

Show free disk space, the size of /var/log, the three largest folders under /var, and the block devices with lsblk -f.