Commands.page Logo

How to Show File Sizes in Kilobytes Using ls on Ubuntu

This article provides a concise guide on displaying file sizes in kilobytes within the Ubuntu terminal using the ls command. It identifies the specific command-line option required to adjust the default output and offers clear examples to help users manage file information effectively.

The option that allows the ls command to show file sizes in kilobytes is -k. By default, the ls command may display file sizes in bytes or blocks depending on your system configuration. Using the -k flag forces the command to assume 1024-byte blocks, effectively presenting the size in kilobytes.

To view a detailed list of files with sizes in kilobytes, you should combine the -k option with the -l flag for long listing format. Enter the following command in your terminal:

ls -lk

You can also use the long-form version of the option, --kilobytes, which functions identically. For example, ls -l --kilobytes will produce the same result. This ensures that the size column reflects kilobyte units rather than raw bytes.

For a more flexible view, consider using the -h option, which stands for “human-readable.” This displays file sizes in the most appropriate unit, such as K for kilobytes, M for megabytes, or G for gigabytes. The command ls -lh is often preferred for general use, but -k remains the specific choice for forcing kilobyte measurement.