256 Kilobytes

How a File Can be Zero Bytes

Articles in Operating Systems | By August R. Garcia

Published | Last Update

When an empty file is created, how is it possible that its size can be listed as zero bytes?

572 views, 0 RAMs, and 0 comments

When an empty file is created, how is it possible that its size can be listed as zero bytes? Even an empty file named “a.txt” needs some amount of data to store:

  • The letters in its file name;
  • It’s creation time; and
  • Various other pieces of metadata.

Despite this, it is possible for a zero-sized files to exist. Creating two text files, one with text and one without, and then running ls -lha yields the following reply on Ubuntu:

  • -rw-rw-r-- 1 256-kilobytes 256-kilobytes    0 Apr 15 12:18 empty-file.md
  • -rw-rw-r-- 1 256-kilobytes 256-kilobytes 1.5K Apr 17 17:02 file-with-text.md

Which verifies that the empty file is, in fact, considered to be a zero byte file. This indicates that the previously mentioned metadata is not in fact stored in these files. Rather, the metadata is stored as an entry in the operating system’s file system.

Can you fill your hard drive entirely with empty files?

Sure. Run this command from the terminal, but make it an infinite loop:

for i in `seq 1 10`; do nice_dogs=`shuf -n 5 /usr/share/dict/words | tr '\n' '-'` && touch $nice_dogs$RANDOM; done
Download more RAM. 🐏 ⨉ 0Posted by August R. Garcia 1 year ago

Edit History

• [2019-04-17 17:16 PDT] August R. Garcia (1 year ago)
• [2019-04-17 17:16 PDT] August R. Garcia (1 year ago)
🕓 Posted at 17 April, 2019 17:16 PM PDT

Read More:
Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite Owner

August Garcia is some guy who used to sell Viagra on the Internet. He made this website to LARP as a sysadmin while posting about garbage like user-agent spoofing, spintax, the only good keyboard, virtual assitants from Pakistan, links with the rel="nofollow" attributeproxiessin, the developer console, literally every link building method, and other junk.

Available at arg@256kilobytes.com, via Twitter, or arg.256kilobytes.com. Open to business inquiries based on availability.

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account