x
dd if=/dev/urandom of=/tmp/r.bin bs=1M count=10
通过 bs, count 来确定要生成多大的文件
bs 支持的单位有 k (1024 字节), M(1024k),G(1024M)
x
root@AP-:~# dd if=/dev/urandom of=/tmp/r.bin bs=1M count=10
lbd: stopping daemon
10+0 records in
10+0 records out
10485760 bytes (10.0MB) copied, 3.671842 seconds, 2.7MB/s
root@AP-:~#
root@AP-:~# du -h /tmp/r.bin
10.0M /tmp/r.bin
root@AP-:~#
root@AP-:~# hexdump -C -n 128 /tmp/r.bin
00000000 61 01 b4 36 9e 4a 6e 90 c5 c0 8e 1a 94 be a1 84 |a..6.Jn.........|
00000010 0d b0 d3 f9 8d e0 bd d7 bb 95 e7 0d bf 12 41 3f |..............A?|
00000020 e3 b4 a2 13 5c d7 dc 05 aa 42 1d fd 10 c9 fc 52 |....\....B.....R|
00000030 5d 0f 96 19 e0 8d 9f 1d c7 11 38 f0 bb 79 3a 4b |].........8..y:K|
00000040 2f b5 59 5b b0 82 88 b8 4c 96 e1 cd 7a 98 3a 70 |/.Y[....L...z.:p|
00000050 18 1e 65 03 3c 51 db ed ff c3 41 e0 51 6e 4b 5e |..e.<Q....A.QnK^|
00000060 cc 44 03 f7 db cf 81 03 76 81 5c bf f8 c2 7f 07 |.D......v.\.....|
00000070 b3 7a 84 31 41 c1 78 ff 97 ae e4 cf 05 8f 13 aa |.z.1A.x.........|
00000080
root@AP-:~#
/dev/urandom 从 linux 内核 1.3.30 版本引入。它是用来访问内核随机数生成器的用户态接口。
The /dev/urandom interface returns bytes regardless of the amount of entropy available. It does not block on a read request due to lack of entropy. While bytes produced by the /dev/urandom interface are of lower quality than bytes produced by /dev/random, they are nonetheless suitable for less demanding and shorter term cryptographic uses such as short term session keys, paddings, and challenge strings.