問題描述
可執行腳本在 Linux 機器上獲得權限被拒絕 (Executable script gets permission denied on Linux box)
嘗試在 Ubuntu 14.04 上運行腳本。
$ bash MirroirHome
運行良好
但是
$ ./MirroirHome
bash: ./MirroirHome: Permission denied
$ ls ‑l
total 32
‑rwxr‑xr‑x 1 gerald gerald 214 nov 14 15:44 MirroirHome
我是文件的所有者,權限位是上,發生了什麼?
這是腳本以防萬一。
#!/bin/bash
rsync \
‑‑archive \
‑‑verbose \
‑‑compress \
‑‑update \
‑‑delete \
/home/ /media/Data/MirroirHome
參考解法
方法 1:
This can happen if the partition is mounted with the noexec
flag on. You can verify this by running mount
: find the partition in the output, and in the list of flags, probably there will be noexec
.
To resolve this, remount the partition without the noexec
flag. Or, copy the script to another partition that's already mounted without noexec
.
(by user3515714、janos)