What is the default size unit in linux ls -l command

I wanted to know what is the unit(bytes, bits, kb) of the output of the ls -l command in Linux. Here is an example of what I've 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)?

2 Answers

That size is in bytes.

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

2

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 Kibibyte (KiB), M for Mebibyte (MiB) and so on.. Instead of bits they show information in bytes.

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

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like