Posted under » Linux on 30 Sep 2020
To check disk usage
Know which folders take a lot of space.
df -H
Read related command 'lsblk' and 'lshw -C disk'.
du /home/
To get the summary of a grand total disk usage size of an directory use the option “-s”
Using “-a” flag with “du” command displays the disk usage of all the files and directories.
The output of the above command displays the number of disk blocks in the /home/ directory along with its sub-directories.
If there are many subdiretories, often you just want to see a bit.
-h stands for human readable format but if you want to know the file name in bytes, then
du -b file.jpg
To sort according to size and list only 10 rows
du -a /etc | sort -n -r | head -n 10
We often use the diff – to show you the difference between two computer files; compares files line by line but you can also use diff to compare file diretories.
diff -q directory-1/ directory-2/
You can alias the location of directory in case one of your main hardisk is full.
Read also Why df shows over 200G space used, while du only shows 50G used?.