如何在脚本中执行需要 root 权限的命令?
我必须改变CPU的频率(通过滑动权限)。我已经编写了命令来更改脚本内的频率。但是,当我运行脚本时,我收到以下错误消息
#!/bin/bash
slide
for i in 0 1 2 3
do
echo 1600000 > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_setspeed
done
,它给出以下错误
./change_freq.sh: line 4: /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed: Permission denied
有什么建议吗?
I have to change the frequency of CPU (through slide privileges) . I have written the command to change frequencies inside a script .However , when I run the script, I get the following error message
#!/bin/bash
slide
for i in 0 1 2 3
do
echo 1600000 > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_setspeed
done
when I run the script , it gives following error
./change_freq.sh: line 4: /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed: Permission denied
Any suggestions ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道
slide
是如何工作的,但是使用sudo
产生相同类型错误的可能类似操作是:解决这个问题的方法是:
我会很想知道以下内容是否提供了有关
slide
起源的更多信息:I don't know how
slide
works, but a possibly similar action usingsudo
that produces the same kind of error would be:The way to solve that is:
I would be curious to know if any of the following provide further information on the origin of
slide
: