Linux

How to create a file of a certain size?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

There are a couple of ways to do that:

  • dd if=/dev/urandom of=new_file.txt bs=2MB count=1
  • truncate -s 2M new_file.txt
  • fallocate -l 2097152 new_file.txt