Display file or directory size


To display a human-readable file size in long format using ls:

$ ls -lh <file>

To display the size of files in a directory:

$ ls -lh <directory>


To sort by size in descending order:

$ ls -lhS <directory>

To sort by size in ascending order:

$ ls -lhrS <directory>


To get the size of a directory, use the du command:

$ du -sh <directory>

Please support this site and join our Discord!