Today I tested the logrotation of a Linux server installation and therefore I needed a logfile that was larger then 10 MB. To create such a file of e.g. 11 MB size on the shell, I used this command:

dd if=/dev/urandom of=test.log bs=1M count=11

The content of the file are random characters. If you need a file filled with zeros, use this command:

dd if=/dev/zero of=test.log bs=1M count=11

The result is a file named test.log in the current directory with a size of 11 MB.

Create a file of a specific size with random content

Leave a Reply

Your email address will not be published. Required fields are marked *