英文:
Ubuntu 13.10 , Golang build and run, the terminal display error bash: ./filename : Permission denied
问题
我正在尝试在使用命令go build
后运行Go的可执行文件,而不是输入go run filename.go
。
我在存放Golang源文件的目录中输入了go build
。在可执行文件创建完成后,我输入./filename
来运行它。然后终端显示了一行:
bash: ./filename: 权限被拒绝
我尝试通过输入以下命令来更改文件名的权限:
chmod u+x filename
但是这个操作没有产生任何效果。每当我输入./filename
时,仍然会出现权限被拒绝的错误。
是否有其他方法可以从源代码构建Golang应用程序,然后从可执行文件中运行它?
如果我在Windows命令提示符中执行此任务,一切都很顺利。在输入go build
后,filename.exe
被创建,并且当我输入./filename.exe
时没有任何问题。
英文:
I am trying to run Go's executable file after using command go build
instead of typing go run filename.go
.
I typed go build
in the directory where the Golang source file resides. After the executable file had been created, I typed ./filename
to run it. Then the terminal displayed a line :
bash : ./filename : Permission denied
I had tried to change the permission of the filename by typing :
chmod u+x filename
But this action doesn't give any effects. The permission denied error still occurs whenever I type ./filename
.
Is there another way to build a Golang applications from source code, and then run it from executable file?
All things done well if I do this task in Windows command prompt, after typing go build
, the filename.exe
is created and there is no any problem when I run it by typing ./filename.exe
.
答案1
得分: 3
NTFS和FAT与Unix具有不同的权限模型。这意味着在这样的文件系统上没有可执行标志。调用chmod a+x FILE
是无效的。Linux通过为每个文件设置掩码来模拟经典的Unix权限,以解决NTFS文件系统上的这些问题。
要解决这些问题,可以将可执行文件移动到不同的文件系统,或者更改挂载标志以使用启用可执行标志的权限掩码(适用于所有文件)。
英文:
NTFS and FAT have different permission models than Unix. This especially means that there is no executable flag on such a file system. Calling chmod a+x FILE
is a no-op. Linux emulates classical Unix permissions on NTFS file systems by setting a mask for each file that contains the would-be permissions.
To fix these problemss, either move executables to a different file system or change the mount flags to use a permission mask that enables the executable-flag (for all files).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论