ls -s command, what type of file size
When you type ls -s
, what size unit does it use to display the file sizes - bits, bytes, megabytes?
It shows the size of the file in blocks. I guess, it is in KBs. If you use -h
option along with -s
, like ls -sh
you could see the size in human readable format. For more info check the man page.
The units are KiBs (1024 bytes).
From man ls
:
-s, --size
print the allocated size of each file, in blocks
But how big is a block? From info coreutils ls
:
Normally the disk allocation is printed in units of 1024 bytes, but this can be overridden (see Block size).
It's also worth noting that ls -s
says symlinks take 0 space, while ls -l
doesn't. E.g. ls -l
gives the size of a link to /
as 1, /var
as 4, /home/username
as 14, etc. As well, ls -ls
adds a disk size column to ls -l
on the far left, for example:
$ ls -ls /bin/sh /bin/dash
152 -rwxr-xr-x 1 root root 154072 Feb 17 2016 /bin/dash
0 lrwxrwxrwx 1 root root 4 Feb 17 2016 /bin/sh -> dash