Create a file of specific size in Linux

While testing an upload service for example you probably need to test it with a large file. On the Linux command-line you can create such a file with the dd command.

To generate a file of 10MB you can run the following command. This will create a file called largefile.txt in your current directory filled with zeros. If you prefer random data instead of zeros you will have to replace /dev/zero by /dev/urandom.

$ dd if=/dev/zero of=largefile.txt bs=1M count=10.

See Also

6 Non-Programming Books for Programmers