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 -lOutput 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.txtis 12 bytes,test_file.txtis 27 bytes). -
ls -lh: Thehstands for "human-readable". This option tellslsto display file sizes in a more user-friendly format, often using units like K (kilobytes), M (megabytes), G (gigabytes), etc.ls -lhOutput 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
Bsuffix, but for larger files, you'd seeKorM).
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.