我在计算机1和计算机2上运行Ubuntu。我在计算机1上编译了一个c++程序,我可以使用./program_name从终端执行它。它运行良好。
然而,当我尝试在计算机2上这样做时,它说:bash: ./program_name:权限被拒绝
出了什么问题,我能做些什么?
我在计算机1和计算机2上运行Ubuntu。我在计算机1上编译了一个c++程序,我可以使用./program_name从终端执行它。它运行良好。
然而,当我尝试在计算机2上这样做时,它说:bash: ./program_name:权限被拒绝
出了什么问题,我能做些什么?
当前回答
听起来好像你没有在文件权限上设置执行标志,请尝试:
chmod u+x program_name
其他回答
Chmod u+x program_name。然后执行它。
如果这不起作用,请将程序从USB设备复制到系统上的本机卷。然后在本地副本上执行chmod u+x program_name。
Unix和类Unix系统通常不会执行一个程序,除非它被标记了执行权限。您将文件从一个系统复制到另一个系统(或挂载外部卷)的方式可能关闭了执行权限(作为安全特性)。chmod u+x name命令为文件所属用户增加了执行该文件的权限。
That command only changes the permissions associated with the file; it does not change the security controls associated with the entire volume. If it is security controls on the volume that are interfering with execution (for example, a noexec option may be specified for a volume in the Unix fstab file, which says not to allow execute permission for files on the volume), then you can remount the volume with options to allow execution. However, copying the file to a local volume may be a quicker and easier solution.
听起来好像你没有在文件权限上设置执行标志,请尝试:
chmod u+x program_name
试试这个:
sudo chmod +x program_name
./program_name