Commands handle storage space


Handle file space in Linux using commands like df, du.

How to check disk usage and free space?

# Check disk usage for all mounted filesystems
df -h

How to check the size of a specific directory or file?

# Check the size of a specific directory or file
du -sh /path/to/directory_or_file

How to display the size of each subdirectory in a directory?

# Display the size of each subdirectory in a directory
du -h --max-depth=1 /path/to/directory

Rewrite random bytes on free space

sudo apt-get install secure-delete
sfill /

Expand partition size

To make it take all the available space (run command twice)

lsblk
parted /dev/sda
(parted) resizepart 3 100%
(parted) quit
pvresize /dev/sda3
lvextend -l +100%FREE /dev/mapper/pool-root