gpt4 book ai didi

linux - 无法从安装的磁盘执行 .sh 脚本 (Ubuntu 18.04) : zsh: permission denied

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:55:10 28 4
gpt4 key购买 nike

Ubuntu 18.04 - 从 here 安装 Zsh 和 Oh-My-Zsh .

鉴于以下

echo '#!/bin/bash\n\nls ~;' >> myscript.sh
chmod 755 ./myscript.sh
./myscript.sh

在我的主文件夹中执行,一切按预期进行,它列出了我的主文件夹中的文件

output omitted for brevity -- it worked and listed files as the script intended

在辅助驱动器中执行我得到下面列出的输出(我的 fstab 配置在这个问题中列在下面)。

╭─user@host /media/user/raw/scripts
╰─$ echo '#!/bin/bash\n\nls ~;' >> myscript.sh
╭─user@host /media/user/raw/scripts
╰─$ chmod 755 ./myscript.sh
╭─user@host /media/user/raw/scripts
╰─$ ./myscript.sh
zsh: permission denied: ./myscript.sh

我的/etc/fstab

╭─user@host /media/user/raw/scripts  
╰─$ cat /etc/fstab 130 ↵
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdb2 during installation
UUID=<<some_uuid>> / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sdb1 during installation
UUID=<<some_uuid>> /boot/efi vfat umask=0077 0 1
/swapfile none swap sw 0 0
/dev/disk/by-uuid/<<some_uuid>> /media/user/raw auto user,rw,nofail,x-gvfs-show 0 0

因为这在我的主文件夹中执行正常,而不是在这个安装的驱动器上,我认为问题出在 fstab 配置中的某个地方。有什么想法吗?

最佳答案

您隐式指定了 noexec,这意味着设备上的任何文件都不可执行。

这是man mount:

user

Allow an ordinary user to mount the filesystem. The name of the mounting user is written to the mtab file (or to the private libmount file in /run/mount on systems without a regular mtab) so that this same user can unmount the filesystem again. This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).

同一段落还建议修复:使用 user,exec 重新启用用户可挂载 fs 中的执行。

关于linux - 无法从安装的磁盘执行 .sh 脚本 (Ubuntu 18.04) : zsh: permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51234334/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com