Ubuntu说"bash:./程序许可被拒绝". [英] Ubuntu says "bash: ./program Permission denied"

查看:117
本文介绍了Ubuntu说"bash:./程序许可被拒绝".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在计算机1和计算机2上运行Ubuntu.我在计算机1上编译了C ++程序,并且可以使用./program_name从终端执行该程序.运行正常.

I am running Ubuntu on computer 1 and computer 2. I compiled a C++ program on computer 1, and I can execute it from the terminal using ./program_name. It runs fine.

但是,当我尝试在计算机2上执行此操作时,它显示:bash: ./program_name: permission denied

However, when I try to do this on computer 2, it says: bash: ./program_name: permission denied

出什么问题了,我该怎么办?

What's wrong and what can I do about it?

推荐答案

chmod u+x program_name.然后执行它.

如果这不起作用,请将程序从USB设备复制到系统上的本机卷.然后chmod u+x program_name在本地副本上并执行.

If that does not work, copy the program from the USB device to a native volume on the system. Then chmod u+x program_name on the local copy and execute that.

Unix和类似Unix的系统通常不会执行程序,除非该程序已标有执行许可.您将文件从一个系统复制到另一个系统(或装入外部卷)的方式可能已关闭了执行权限(作为安全功能). chmod u+x name命令为拥有该文件的用户添加执行权限.

Unix and Unix-like systems generally will not execute a program unless it is marked with permission to execute. The way you copied the file from one system to another (or mounted an external volume) may have turned off execute permission (as a safety feature). The command chmod u+x name adds permission for the user that owns the file to execute it.

该命令仅更改与文件关联的权限;它不会更改与整个卷关联的安全控制.如果是卷上的安全控件会干扰执行(例如,可以在Unix fstab文件中为卷指定noexec选项,该选项表示不允许对该卷上的文件执行执行权限),然后您可以使用选项重新挂载该卷以允许执行.但是,将文件复制到本地卷可能是一种更快,更轻松的解决方案.

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.

这篇关于Ubuntu说"bash:./程序许可被拒绝".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆