In a Linux terminal, to display the size of all files and subdirectories in the current directory, sorted by size, use the following common commands:
1. Display the size of all files/directories (including hidden files) and sort them.
du -sh .[!.]* * 2>/dev/null | sort -hrdu -sh: Calculate the size of each file (-s for summary, -h for human-readable format).[!.]* *Match hidden files (excluding );.;..) and non-hidden files2>/dev/nullIgnore error messages (e.g., when no matches are found)sort -hrSort by size in descending order
2. Displays only non-hidden files and directories within the current directory (most commonly used)
du -sh * | sort -hr3. Display the top-level subdirectories and the total size of the current directory (depth 1)
du -h --max-depth=1 | sort -hr4. List only regular files (does not display directories)
find . -maxdepth 1 -type f -exec ls -lh {} \; | sort -k5 -hr5. Use; ls View file size (excluding total directory size)
ls -lhS
-lDetails,-hreadable,-SSort by file size in descending order (the directory shows approximately 4 KB – this is approximate)
recommendDaily use; du -sh * | sort -hr The most intuitive approach.