Ubuntu/Linux disk management commands
Here are the most commonly used Ubuntu/Linux disk management commands with a short explanation for each. These will help you check disk usage, list disks, inspect partitions, mount/unmount, and manage file systems.
✅ Basic disk usage commands
1. Show disk space usage (human-readable)
df -h
2. Show disk usage of a directory
du -sh /path/to/directory
3. Show usage of root folder (sorted)
sudo du -xh / | grep '[0-9\.]\+G' | sort -hr | head -30
✅ List disks and partitions
4. Detailed list of disks
lsblk
5. Show disk partitions
sudo fdisk -l
6. List partition UUIDs
blkid
7. Show S.M.A.R.T. disk health
sudo smartctl -a /dev/sda
(Requires sudo apt install smartmontools)
✅ Mounting & unmounting disks
8. Mount a disk
sudo mount /dev/sdX1 /mnt
9. Unmount a disk
sudo umount /dev/sdX1
10. Reload all mounts from /etc/fstab
sudo mount -a
✅ Disk formatting commands
11. Format as EXT4
sudo mkfs.ext4 /dev/sdX1
12. Format as FAT32
sudo mkfs.vfat -F 32 /dev/sdX1
13. Format as NTFS
sudo mkfs.ntfs /dev/sdX1
✅ File system checks and repair
14. Check a filesystem
sudo fsck /dev/sdX1
15. Force fsck on next reboot
sudo touch /forcefsck
✅ Disk performance
16. Test disk speed
sudo hdparm -Tt /dev/sda
(Requires sudo apt install hdparm)
✅ Disk creation & resizing
17. Partition manager (text UI)
sudo cfdisk /dev/sda
18. Resize a partition (CLI)
sudo parted /dev/sda