Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to know what is the unit ( bytes ,bits , kb ) of the output of the ls -l command in linux. Heres an example of what i got :

-rw-rw-r--    1 guest    guest       39870 Feb 14 19:41 ser_cat
-rw-r--r--    1 guest    guest       19935 Feb 14 19:35 ser_cp
-rw-rw-r--    1 guest    guest       19935 Feb 14 19:29 ser_more

I wanted to know what is the unit of 39870 (the size of ser_cat) ?

share|improve this question

migrated from stackoverflow.com Feb 19 '13 at 5:00

This question came from our site for professional and enthusiast programmers.

up vote 37 down vote accepted

That size is in bytes.

You can use ls -lh to print the long listing with human readable file sizes.

share|improve this answer
5  
Just a note on the units: ls -h gives 1K (1024 bytes). ls --si gives 1k (1000 bytes). – Thomas Bratt May 29 '15 at 13:37

We need to add l(long listing option) to show human readable file sizes (ls -lh). In your case, size of file ser_cat is in 39870 bytes.

-rw-rw-r--    1 guest    guest       39870 Feb 14 19:41 ser_cat
-rw-r--r--    1 guest    guest       19935 Feb 14 19:35 ser_cp
-rw-rw-r--    1 guest    guest       19935 Feb 14 19:29 ser_more

ls -lh command shows all file size information as K for Kilobyte(KB), M for Megabyte (MB) and so on.. Instead of bits they show information as bytes.

ls -lh shows unit (size) information using single character instead of two characters. If no unit information is there, then that is bytes.

share|improve this answer
1  
The units for -h are actually Kibibytes and Mebibytes, not Kilobytes and Megabytes. If you want Kilobytes and Megabytes, use --si instead. – Ajedi32 May 16 at 21:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .