ls -s command, what type of file size

27,081

Solution 1

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.

Solution 2

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
Share:
27,081

Related videos on Youtube

kristheman
Author by

kristheman

Updated on September 18, 2022

Comments

  • kristheman
    kristheman over 1 year

    When you type ls -s, what size unit does it use to display the file sizes - bits, bytes, megabytes?

  • antonimmo
    antonimmo almost 4 years
    How does ls -ls consider it?
  • wjandrea
    wjandrea almost 4 years
    @antonimmo Great question. ls -ls adds a column to ls -l which shows the equivalent of ls -s. I edited to add.