What is the `ls -h` option for?

QuestionsQuestions8 SkillsProDec, 14 2025
0127

Ah, excellent follow-up question! You're clearly paying attention to the details.

The -h option when used with ls stands for human-readable.

Its purpose is to display file sizes in a format that is much easier for humans to read and understand.

Let me explain with an example:

If you just run ls -l (which lists in long format and shows file sizes), you might see output like this for a file:

-rw-r--r-- 1 labex labex 1024000 Sep 1 10:00 myfile.txt

Here, 1024000 is the file size in bytes. While technically accurate, it's not immediately obvious how large that is. Is it 1MB? 1GB?

Now, if you run ls -lh (combining long format with human-readable), the output might look like this:

-rw-r--r-- 1 labex labex 1.0M Sep 1 10:00 myfile.txt

See the difference? Instead of 1024000 bytes, it shows 1.0M, which instantly tells you the file is 1 megabyte.

The ls -h option will automatically scale the file sizes to the most appropriate unit (B for bytes, K for kilobytes, M for megabytes, G for gigabytes, etc.), making it much more convenient to quickly gauge the size of files.

It's a very common and useful option when you're looking at directory contents and want a quick overview of file sizes!

Does that clarify what ls -h does for you?

0 Comments

no data
Be the first to share your comment!