How does `ls -lh` differ from `ls -l`?

QuestionsQuestions8 SkillsProDec, 16 2025
0114

That's an excellent follow-up question! You've observed a key difference between ls -l and ls -lh.

The core difference is in how the file sizes are displayed:

  • ls -l: Displays file sizes in bytes. This gives you the exact byte count, which can sometimes be long and harder to read at a glance, especially for large files.

    ls -l

    Output example:

    total 8
    -rw-rw-r-- 1 labex labex 12 Dec 17 03:07 data_file.txt
    drwxrwxr-x 2 labex labex  6 Dec 17 03:07 test
    -rw-rw-r-- 1 labex labex 27 Dec 17 03:07 test_file.txt

    (Notice data_file.txt is 12 bytes, test_file.txt is 27 bytes).

  • ls -lh: The h stands for "human-readable". This option tells ls to display file sizes in a more user-friendly format, often using units like K (kilobytes), M (megabytes), G (gigabytes), etc.

    ls -lh

    Output example:

    total 8.0K
    -rw-rw-r-- 1 labex labex 12B Dec 17 03:07 data_file.txt
    drwxrwxr-x 2 labex labex 6B Dec 17 03:07 test
    -rw-rw-r-- 1 labex labex 27B Dec 17 03:07 test_file.txt

    (In this small example, it still shows bytes with a B suffix, but for larger files, you'd see K or M).

In short, ls -lh is identical to ls -l but with the added convenience of showing file sizes in a format that's easier for humans to understand quickly. It's a very commonly used combination of options!

Keep up the great work exploring these commands! Let me know if anything else comes to mind.

0 Comments

no data
Be the first to share your comment!