我正在尝试编写我的第一个 Linux 脚本(在 devmode 下在 chromebook 上运行)。它如下:
#!/bin/bash
echo 'hello world'
它存储在 中~/Downloads/app/run
。当我尝试运行它时,我得到以下信息:
chronos@localhost ~/Downloads/app $ ./run
bash: ./run: Permission denied
chronos@localhost ~/Downloads/app $ chmod 700 ./run
chronos@localhost ~/Downloads/app $ ./run
bash: ./run: Permission denied
chronos@localhost ~/Downloads/app $ sudo chmod 700 ./run
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
chronos@localhost ~/Downloads/app $ ./run
bash: ./run: Permission denied
我究竟做错了什么?
答案1
chmod +x <filename>
命令将使脚本可执行。
然后运行脚本:
./<filename>
答案2
您是否检查过父文件夹中的权限?
您应该对这些文件夹拥有执行权限,例如 755。
答案3
看来您必须与本地系统管理员核实如何运行脚本。
当你有控制权时,它应该这样工作:
$ cat>运行 /bin/bash #!/bin/bash 回显‘你好,世界’ ^D $ cat./运行 /bin/bash #!/bin/bash 回显‘你好,世界’ $ chmod 755./运行 $./运行 你好世界 $