初始化 shell 命令问题

0

【以下的问题经过翻译处理】 在Amazon AMI上这个可以工作: ec2.InitCommand.shellCommand('sudo ls /etc/resolv.conf')

这个也可以工作 ec2.InitFile.fromFileInline('/etc/resolv2.conf', './myContent/resolv2.conf')

这个也可以工作 ec2.InitCommand.shellCommand('sudo chmod 777 /etc/resolv.conf')

但是这个不行 ec2.InitCommand.shellCommand('sudo rm -f /etc/resolv.conf')

这个也不行 ec2.InitCommand.shellCommand('sudo sed -i "s/^nameserver/#nameserver/g" /etc/resolv.conf')

我想这是权限问题。ls -al的输出在这里:

-rw-r--r-- 1 root root 121 Apr 30 12:37 /etc/resolv.conf

文件内容是:

 ; generated by /sbin/dhclient-script

search eu-west-3.compute.internal

options timeout:2 attempts:5

nameserver 10.10.0.2

profile picture
专家
已提问 5 个月前22 查看次数
1 回答
0

【以下的回答经过翻译处理】 检查 "/var/log/cloud-init-output.log" 中的日志输出。查看是否有任何错误或其他问题。

另外,默认情况下,InitFile 作为 root 用户运行,因此不太可能出现权限相关的错误。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则