Linux快速生成指定大小文件 使用dd命令 使用head命令

[root@centos7-18 ~]# dd if=/dev/zero of=test bs=1M count=2
2+0 records in
2+0 records out
2097152 bytes (2.1 MB) copied, 0.0075806 s, 277 MB/s
[root@centos7-18 ~]# ll -h test
-rw-r--r--. 1 root root 2.0M Jul 12 18:00 test

Linux快速生成指定大小文件
使用dd命令
使用head命令

使用head命令

[root@centos7-18 ~]# head -c 1000000 /dev/zero > test
[root@centos7-18 ~]# ll test
-rw-r--r--. 1 root root 1000000 Jul 12 17:58 test
[root@centos7-18 ~]# ll -h test
-rw-r--r--. 1 root root 977K Jul 12 17:58 test

Linux快速生成指定大小文件
使用dd命令
使用head命令