2

I have a directory, inside that, I have created 2 files and have written some content in these files when I run ls -l. It still displays the total as 0. Why? It should return some positive integer.

I already referred to this answer, and I am convinced with the explanation. But why total 0, I still didn't understand.

I am running this command in ubuntu (20.04 LTS) using Windows Subsystem for Linux on Windows 10.

ls output

4

2 Answers 2

3

I suppose that's because you're using WSL on a NTFS volume. NTFS will store small files directly in file's record inside MFT (Master File Table). For larger files this space in a file record would be reserved, but not used. So a small file is essentially taking no extra space on disk, except for what the file record would take anyway, therefore producing a total of 0.

3
  • so in native ubuntu, it will not show total 0?
    – Vivek Nuna
    Jan 20, 2021 at 12:29
  • @viveknuna It doesn't. i.stack.imgur.com/201Vl.png
    – gronostaj
    Jan 20, 2021 at 13:09
  • It shows up for me under the circumstances that OP described, but I'm using native Debian 11 and BTRFS.
    – ATLief
    May 7, 2023 at 18:03
0

What is "total" in the output of "ls" command? [duplicate]

total shows disk usage, not item count inside the directory!

The "total" is the disk usage of listed files (because of -a including the . and .. entries) in blocks (1024 bytes or if POSIXLY_CORRECT is set in 512 bytes), not including the content of subdirectories.

3
  • I don't think this answers the question any more than your other answer, the user talks about size. What are you tring to do here? I'm not quite following your answering attempt.
    – Destroy666
    Jul 12, 2023 at 17:15
  • When you do touch 1, 2, 3, 4 you create a zero length files. Therefore total size is 0 Jul 13, 2023 at 3:33
  • OP says he added content to files, and you can see they are 11 bytes and 2 bytes.
    – alexh
    Oct 3, 2023 at 13:46

You must log in to answer this question.

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