使用 dd 和 /dev/random 在 linux 上创建一个随机文件

Create a random file on linux using dd and /dev/random

我执行了这个:

$ dd if=/dev/random of=foo bs=1G count=1
0+1 records in
0+1 records out
6 bytes (6 B) copied, 0.00016958 s, 35.4 kB/s

$ stat -c "%s" foo
6

这也行不通,我卡在了命令中:

$ head -c 500 /dev/random > foo

我的错误是什么?

我正在 Linux 薄荷。

/dev/random 将只提供随机数据,直到 RNG 的熵源耗尽。如果您想读取更大块的(伪)随机数据,您可以改为从 /dev/urandom 读取。