How do I display the file size in human-readable format using the ls command in Linux?

Published on Aug. 22, 2023, 12:17 p.m.

To display the file size in human-readable format using the ls command in Linux, you can use the -h option with the -l (long format) option. Here is an example command that will display the file size(s) for a given directory or file in a human-readable format:

ls -lh filename_or_directory

This will display the file sizes in a format that is easy to read by humans, using units such as “K” for kilobytes, “M” for megabytes, “G” for gigabytes, and so on. Another option is to use the -s option along with -h to display the size of each file, while still retaining the human-readable format. Here is an example command using both options:

ls -lsh filename_or_directory

This will display the size of each file or directory in the current directory in a human-readable format, along with other information such as the file permissions, ownership, etc.

Tags:

ls